I have an application where I need to convert between SVector<3> objects (for matrix algebra) and GenVector XYZVector objects (for geometric functions). I am currently doing that ‘by hand’, ie
typedef ROOT::Math::SVector<double,3> SVector3;
XYZVector gv1, gv2;
SVector3 sv1, sv2;
sv1 = SVector3(gv1.X(), gv1.Y(), gv1.Z());
gv2 = XYZVector(sv2,sv2,sv2);
Is there a more elegant (less error-prone) way to perform these cross-constructions?
Thanks for your response. I had a vague recollection of this being supported or at least documented in earlier code, I’m glad to see I wasn’t completely wrong. I think it would be useful to have this functionality, it will result in cleaner, less fragile user code covering a legitimate and common use case. I suggest throwing if the dimensions don’t match exactly. What about the other direction? Could GenVector support operator ? That would allow cross-construction of SVector.