@@ -664,24 +664,6 @@ namespace dynamicgraph {
664
664
665
665
/* --- MULTIPLICATION --------------------------------------------------- */
666
666
667
- template < typename T>
668
- struct Multiplier
669
- : public BinaryOpHeader<T,T,T>
670
- {
671
- void operator ()( const T& v1,const T& v2,T& res ) const { res = v1*v2; }
672
- };
673
- template <> void Multiplier<double >::
674
- operator ()( const double & v1,const double & v2,double & res ) const
675
- { res=v1; res*=v2; }
676
-
677
- REGISTER_BINARY_OP (Multiplier<dynamicgraph::Matrix>,Multiply_of_matrix);
678
- REGISTER_BINARY_OP (Multiplier<dynamicgraph::Vector>,Multiply_of_vector);
679
- REGISTER_BINARY_OP (Multiplier<MatrixRotation>,Multiply_of_matrixrotation);
680
- REGISTER_BINARY_OP (Multiplier<MatrixHomogeneous>,Multiply_of_matrixHomo);
681
- REGISTER_BINARY_OP (Multiplier<MatrixTwist>,Multiply_of_matrixtwist);
682
- REGISTER_BINARY_OP (Multiplier<VectorQuaternion>,Multiply_of_quaternion);
683
- REGISTER_BINARY_OP (Multiplier<double >,Multiply_of_double);
684
-
685
667
template < typename F,typename E>
686
668
struct Multiplier_FxE__E
687
669
: public BinaryOpHeader<F,E,E>
@@ -1011,6 +993,60 @@ namespace dynamicgraph {
1011
993
}
1012
994
};
1013
995
REGISTER_VARIADIC_OP (VectorMix,Mix_of_vector);
996
+
997
+ /* --- MULTIPLICATION --------------------------------------------------- */
998
+ template < typename T>
999
+ struct Multiplier
1000
+ : public VariadicOpHeader<T,T>
1001
+ {
1002
+ typedef VariadicOp<Multiplier> Base;
1003
+
1004
+ void operator ()( const std::vector<const T*>& vs,T& res ) const
1005
+ {
1006
+ if (vs.size () == 0 ) setIdentity (res);
1007
+ else {
1008
+ res = *vs[0 ];
1009
+ for (std::size_t i = 1 ; i < vs.size (); ++i) res *= *vs[i];
1010
+ }
1011
+ }
1012
+
1013
+ void setIdentity (T& res) const { res.setIdentity (); }
1014
+
1015
+ void initialize (Base* ent,
1016
+ Entity::CommandMap_t& commandMap )
1017
+ {
1018
+ using namespace dynamicgraph ::command;
1019
+
1020
+ ent->setSignalNumber (2 );
1021
+
1022
+ ADD_COMMAND ( " setSignalNumber" , makeCommandVoid1 (*(typename Base::Base*)ent, &Base::setSignalNumber,
1023
+ docCommandVoid1 (" set the number of input vector." , " int (size)" )));
1024
+
1025
+ commandMap.insert (std::make_pair ( " getSignalNumber" ,
1026
+ new Getter<Base, int > (*ent, &Base::getSignalNumber,
1027
+ " Get the number of input vector." )));
1028
+ }
1029
+ };
1030
+ template <> void Multiplier<double >::
1031
+ setIdentity (double & res) const { res = 1 ; }
1032
+ template <> void Multiplier<MatrixHomogeneous>::
1033
+ operator ()( const std::vector<const MatrixHomogeneous*>& vs, MatrixHomogeneous& res ) const
1034
+ {
1035
+ if (vs.size () == 0 ) setIdentity (res);
1036
+ else {
1037
+ res = *vs[0 ];
1038
+ for (std::size_t i = 1 ; i < vs.size (); ++i) res = res * *vs[i];
1039
+ }
1040
+ }
1041
+
1042
+ REGISTER_VARIADIC_OP (Multiplier<Matrix >,Multiply_of_matrix);
1043
+ REGISTER_VARIADIC_OP (Multiplier<Vector >,Multiply_of_vector);
1044
+ REGISTER_VARIADIC_OP (Multiplier<MatrixRotation >,Multiply_of_matrixrotation);
1045
+ REGISTER_VARIADIC_OP (Multiplier<MatrixHomogeneous>,Multiply_of_matrixHomo);
1046
+ REGISTER_VARIADIC_OP (Multiplier<MatrixTwist >,Multiply_of_matrixtwist);
1047
+ REGISTER_VARIADIC_OP (Multiplier<VectorQuaternion >,Multiply_of_quaternion);
1048
+ REGISTER_VARIADIC_OP (Multiplier<double >,Multiply_of_double);
1049
+
1014
1050
}
1015
1051
}
1016
1052
0 commit comments