Hi, I would like to represent an expression as a product of a scalar expression and a vector expression. This would enable me to extract these parts of the expression trivially instead of scanning the prod sequence (and hence is more optimal). However I am not clear how this can be done in ginac. For example, when multiplying a scalar expression with a rhs expression, I would like to absorb the scalar expression into the scalar expression of the rhs. This requires modifying operator*(ex,ex). Is there a better way to do it? I would appreciate any help. example use cases: symbol s1, s2, s3; // scalars vector v1, v2, v3; // vectors myex e1(s1, (s2*v3 + s1*v2)); // initialized to: e1.scalar = s1; e1.vector = (s2*v3 + s3*v2) myex e2 = s3 * e1; // should produce: e2.scalar = s3 * s1; e2.vector = (s2*v3 + s3*v2) myex e3 = cross_prod(e, v1); // should produce: e3.scalar = s1; e3.vector = cross_prod(s2*v3 + s3*v2, v1); thanks, Krishna.
participants (1)
-
Krishna Mohan Gundu