ROOT  6.06/08
Reference Guide
math/smatrix/doc/Functions.md
Go to the documentation of this file.
1 // Matrix and Vector Functions doc
2 
3 /**
4 
5 \page MatVecFunctions Matrix and Vector Operators and Functions
6 
7 
8 ## Matrix and Vector Operators
9 
10 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:
11 
12 <pre>m1 == m2 _// returns whether m1 is equal to m2 (element by element comparison)_
13 m1 != m2 _// returns whether m1 is NOT equal to m2 (element by element comparison)_
14 m1 < m2 _// returns whether m1 is less than m2 (element wise comparison)_
15 m1 > m2 _// returns whether m1 is greater than m2 (element wise comparison)_
16 _// in the following m1 and m3 can be general and m2 symmetric, but not vice-versa_
17 m1 += m2 _// add m2 to m1_
18 m1 -= m2 _// subtract m2 to m1_
19 m3 = m1 + m2 _// addition_
20 m1 - m2 _// subtraction_
21 
22 _// Multiplication and division via a scalar value a_
23 m3 = a*m1; m3 = m1*a; m3 = m1/a;
24 </pre>
25 
26 ### Vector-Vector multiplication
27 
28 The _operator *_ defines an element by element multiplication between vectors. For the standard vector-vector multiplication, \f$ a = v^T v \f$, (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.
29 
30 ### Matrix - Vector multiplication
31 
32 The _operator *_ defines the matrix-vector multiplication, \f$ y_i = \sum_{j} M_{ij} x_j\f$:
33 
34 <pre>_// M is a N1xN2 matrix, x is a N2 size vector, y is a N1 size vector_
35 y = M * x
36 </pre>
37 
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$:
40 
41 <pre>_// A is a N1xN2 matrix, B is a N2xN3 matrix and C is a N1xN3 matrix_
42 C = A * B
43 </pre>
44 
45 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.
46 
47 ### Matrix and Vector Functions
48 
49 The most used matrix functions are:
50 
51 * **ROOT::Math::Transpose**(M) : return the transpose matrix, \f$ M^T \f$
52 * **ROOT::Math::Similarity**( v, M) : returns the scalar value resulting from the matrix- vector product \f$ v^T M v \f$
53 * **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
54 * **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
55 
56 See \ref MatrixFunctions for the documentation of all existing matrix functions in the package.
57 The major Vector functions are:
58 
59 * **ROOT::Math::Dot**( v1, v2) : returns the scalar value resulting from the vector dot product
60 * **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
61 * **ROOT::Math::Unit**( v) : returns unit vector. One can use also the _v.Unit()_ method.
62 * **ROOT::Math::TensorProd**(v1,v2) : returns a general matrix M of size N1xN2 resulting from the [Tensor Product](http://en.wikipedia.org/wiki/Tensor_product) between the vector v1 of size N1) and v2 of size N2
63 
64 See \ref VectFunction for the list and documentation of all of them.
65 
66 ### Matrix and Vector I/O
67 
68 One can print (or write in an output stream) Vectors (and also Matrices) using the Print method or the << operator, like:
69 
70 <pre>v.Print(std::cout);
71 std::cout << v << std::endl;
72 </pre>
73 
74 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.
75 
76 */
77 
78 */