1 \page MatVecFunctions Matrix and Vector Operators and
Functions
4 ## Matrix and Vector Operators
20 m3 =
a*m1; m3 = m1*
a; m3 = m1/
a;
24 ### Vector-Vector multiplication
28 ### Matrix - Vector multiplication
30 The _operator *
_ defines the matrix-vector multiplication,
\f$ y_i = \sum_{j} M_{ij}
x_j\f$:
38 It compiles only
if the matrix and the vectors have the right sizes.
39 **Matrix - Matrix multiplication** The _operator *
_ defines the matrix-matrix multiplication,
\f$ C_{ij} = \sum_{k} A_{ik} B_{kj}
\f$:
47 The 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.
51 The most used matrix functions are:
55 * **ROOT::Math::
Similarity**( U, M) : returns the matrix resulting from the product \
f$ U M U^
T \
f$. If M is symmetric, the returned resulting matrix is also symmetric
56 * **ROOT::Math::
SimilarityT**( U, M) : returns the matrix resulting from the product \
f$ U^
T M U \
f$. If M is symmetric, the returned resulting matrix is also symmetric
58 See \ref MatrixFunctions
for the documentation of all existing matrix functions in the package.
59 The major Vector functions are:
61 * **ROOT::Math::
Dot**( v1, v2) : returns the scalar value resulting from the vector dot product
62 * **ROOT::Math::
Cross**( v1, v2) : returns the vector cross product
for two vectors of size 3\. Note that the
Cross product is not defined
for other vector sizes
63 * **ROOT::Math::
Unit**(
v) : returns unit vector. One can use also the _v.
Unit()
_ method.
64 * **ROOT::Math::
TensorProd**(v1,v2) : returns
a general matrix M of size N1xN2 resulting from the [Tensor
Product](http:
66 See \ref VectFunction
for the list and documentation of all of them.
68 ### Matrix and Vector
I/O
70 One can print (or
write in an
output stream) Vectors (and also Matrices) using the
Print method or the << operator, like:
74 std::cout <<
v << std::endl;
78 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.
T Dot(const SVector< T, D > &lhs, const SVector< T, D > &rhs)
Vector dot product.
T Similarity(const SMatrix< T, D, D, R > &lhs, const SVector< T, D > &rhs)
Similarity Vector - Matrix Product: v^T * A * v returning a scalar value of type T ...
static Double_t Product(const Double_t *x, const Float_t *y)
Product.
double write(int n, const std::string &file_name, const std::string &vector_type, int compress=0)
writing
Expr< TransposeOp< SMatrix< T, D1, D2, R >, T, D1, D2 >, T, D2, D1, typename TranspPolicy< T, D1, D2, R >::RepType > Transpose(const SMatrix< T, D1, D2, R > &rhs)
Matrix Transpose B(i,j) = A(j,i) returning a matrix expression.
SMatrix: a generic fixed size D1 x D2 Matrix class.
Expr< TensorMulOp< SVector< T, D1 >, SVector< T, D2 > >, T, D1, D2 > TensorProd(const SVector< T, D1 > &lhs, const SVector< T, D2 > &rhs)
Tensor Vector Product : M(i,j) = v(i) * v(j) returning a matrix expression.
SVector< T, 3 > Cross(const SVector< T, 3 > &lhs, const SVector< T, 3 > &rhs)
Vector Cross Product (only for 3-dim vectors) .
Double_t Dot(const TGLVector3 &v1, const TGLVector3 &v2)
void Print(std::ostream &os, const OptionType &opt)
void Functions(TString type="Import")
SMatrix< T, D2, D2, MatRepSym< T, D2 > > SimilarityT(const SMatrix< T, D1, D2, R > &lhs, const SMatrix< T, D1, D1, MatRepSym< T, D1 > > &rhs)
Transpose Similarity Matrix Product : B = U^T * A * U for A symmetric returning a symmetric matrix ex...
TGLVector3 Cross(const TGLVector3 &v1, const TGLVector3 &v2)
SVector< T, D > Unit(const SVector< T, D > &rhs)
Unit.
SVector: a generic fixed size Vector class.