The ROOT::Math::SVector and ROOT::Math::SMatrix classes defines the following operators described below. The m1,m2,m3 are vectors or matrices of the same type (and size) and a is a scalar value:
m1 == m2 // returns whether m1 is equal to m2 (element by element comparison) m1 != m2 // returns whether m1 is NOT equal to m2 (element by element comparison) m1 < m2 // returns whether m1 is less than m2 (element wise comparison) m1 > m2 // returns whether m1 is greater than m2 (element wise comparison) // in the following m1 and m3 can be general and m2 symmetric, but not vice-versa m1 += m2 // add m2 to m1 m1 -= m2 // subtract m2 to m1 m3 = m1 + m2 // addition m1 - m2 // subtraction
// Multiplication and division via a scalar value a m3 = a*m1; m3 = m1*a; m3 = m1/a;
The operator * defines an element by element multiplication between vectors. For the standard vector-vector multiplication,
, (dot product) one must use the ROOT::Math::Dot function. In addition, the Cross (only for vector sizes of 3), ROOT::Math::Cross, and the Tensor product, ROOT::Math::TensorProd, are defined.
The operator * defines the matrix-vector multiplication,
:
// M is a N1xN2 matrix, x is a N2 size vector, y is a N1 size vector y = M * xIt compiles only if the matrix and the vectors have the right sizes.
: // A is a N1xN2 matrix, B is a N2xN3 matrix and C is a N1xN3 matrix C = A * BThe operation compiles only if the matrices have the right size. In the case that A and B are symmetric matrices, C is a general one, since their product is not guaranteed to be symmetric.
The most used matrix functions are:
. If M is symmetric, the returned resulting matrix is also symmetric
. If M is symmetric, the returned resulting matrix is also symmetric
One can print (or write in an output stream) Vectors (and also Matrices) using the Print method or the << operator, like:
v.Print(std::cout); std::cout << v << std::endl;In the ROOT distribution, the CINT dictionary is generated for SMatrix and SVector for double types and sizes up to 5. This allows the storage of them in a ROOT file.
1.4.6