@@ -30,7 +30,9 @@ void exposeComposites() {
3030 bp::class_<QuadResCost, bp::bases<CostAbstract>>(
3131 " QuadraticResidualCost" , " Weighted 2-norm of a given residual function." ,
3232 bp::init<ManifoldPtr, PolyFunction, const ConstMatrixRef &>(
33- bp::args (" self" , " space" , " function" , " weights" )))
33+ bp::args (" self" , " space" , " function" , " weights" ))
34+ [bp::with_custodian_and_ward<1 , 2 ,
35+ bp::with_custodian_and_ward<1 , 3 >>()])
3436 .def_readwrite (" residual" , &QuadResCost::residual_)
3537 .def_readwrite (" weights" , &QuadResCost::weights_)
3638 .def (CopyableVisitor<QuadResCost>())
@@ -39,9 +41,12 @@ void exposeComposites() {
3941 bp::class_<LogResCost, bp::bases<CostAbstract>>(
4042 " LogResidualCost" , " Weighted log-cost composite cost." ,
4143 bp::init<ManifoldPtr, PolyFunction, const ConstVectorRef &>(
42- bp::args (" self" , " space" , " function" , " barrier_weights" )))
44+ bp::args (" self" , " space" , " function" , " barrier_weights" ))
45+ [bp::with_custodian_and_ward<1 , 2 ,
46+ bp::with_custodian_and_ward<1 , 3 >>()])
4347 .def (bp::init<ManifoldPtr, PolyFunction, Scalar>(
44- bp::args (" self" , " function" , " scale" )))
48+ bp::args (" self" , " function" , " scale" ))[bp::with_custodian_and_ward<
49+ 1 , 2 , bp::with_custodian_and_ward<1 , 3 >>()])
4550 .def_readwrite (" residual" , &LogResCost::residual_)
4651 .def_readwrite (" weights" , &LogResCost::barrier_weights_)
4752 .def (CopyableVisitor<LogResCost>())
@@ -62,20 +67,22 @@ void exposeComposites() {
6267 bp::args (" self" , " resdl" , " weights" )))
6368 .def (bp::init<ManifoldPtr, const int , const ConstVectorRef &,
6469 const MatrixXs &>(
65- bp::args (" self" , " space" , " nu" , " target" , " weights" )))
70+ bp::args (" self" , " space" , " nu" , " target" ,
71+ " weights" ))[bp::with_custodian_and_ward<1 , 2 >()])
6672 .add_property (" target" , &QuadStateCost::getTarget,
6773 &QuadStateCost::setTarget,
6874 " Target of the quadratic distance." )
6975 .def (visitor);
7076
7177 bp::class_<QuadControlCost, bp::bases<QuadResCost>>(
7278 " QuadraticControlCost" , " Quadratic control cost." , bp::no_init)
73- .def (bp::init<ManifoldPtr, ConstVectorRef, const MatrixXs &>(
74- bp::args ( " space" , " target" , " weights" )))
79+ .def (bp::init<ManifoldPtr, ConstVectorRef, const MatrixXs &>(bp::args (
80+ " space" , " target" , " weights" ))[bp::with_custodian_and_ward< 1 , 2 >()] )
7581 .def (bp::init<ManifoldPtr, QuadControlCost::Error, const MatrixXs &>(
76- bp::args (" self" , " space" , " resdl" , " weights" )))
77- .def (bp::init<ManifoldPtr, int , const MatrixXs &>(
78- bp::args (" space" , " nu" , " weights" )))
82+ bp::args (" self" , " space" , " resdl" ,
83+ " weights" ))[bp::with_custodian_and_ward<1 , 2 >()])
84+ .def (bp::init<ManifoldPtr, int , const MatrixXs &>(bp::args (
85+ " space" , " nu" , " weights" ))[bp::with_custodian_and_ward<1 , 2 >()])
7986 .add_property (" target" , &QuadControlCost::getTarget,
8087 &QuadControlCost::setTarget,
8188 " Reference of the control cost." )
0 commit comments