ZOOM| SPD Matrices | 1-Column Matrices | 2-Column Matrices |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* std::vector < double > is used to represent a 1-column matrix of arbitrary length.
A Vector may be constructed from from its elements, or from an array conaining them.
A BiVector may be constructed from two vectors, or from its elements in the order of first one vector than the other.
M = M1 + M2; bool OK = M.invert(); double d = M.determinant(); Vector5 eigenvals; Vector[5] eigenvecs[5]; // here we assume M is 5x5 M.diagonalize(eigenvals, eigenvecs); M.trace(); cout << M; // nicely formatted output M = M1 - M2; // See note M*v; M*w; v*M; w*M; v+v; v-v; w+w; w-w;Note that unless user knows M2 is small, the answer to M = M1 - M2 may not be positive definite. Nonetheless this operation is supplied because there are tracking algorithms that need to do this as one step, and which know that M2 is supposed to be small.
All elements of the upper part of the matrix, in row order, may be dumped into an array of doubles.
CovMatrix5 M; double elements[15]; M.dump(elements);
The bottom line is that for 5x5 and 6x6 matrices, inversion proceeds almost twice as fast using the CovMatrices package as it does using CLHEP Matrices.
Performing matrix addition timings table
(more condensed form of the same table: only
the minimum values are reported)
Performing matrix subtraction timings table
(more condensed form of the same table: only
the minimum values are reported)
Performing matrix to matrix multiplication
timings table (more condensed form
of the same table: only the minimum values are reported)
(Note: matrix*matrix can't be performed in CovMatrices)
Performing matrix to vector multiplication
timings table (more condensed form
of the same table: only the minimum values are reported)
Performing matrix to bivector multiplication
timings table (more condensed form of
the same table: only the minimum values are reported)
(Note: since matrix*bivector can't be performed in LinearAlgebra
and CLHEP, matrix*matrix with a 2-column matrix as the 2nd matrix was done)
Performing vector to vector multiplication
timings table (more condensed form
of the same table: only the minimum values are reported)
(Note: in order to perform vector*vector in CLHEP, we have to
transpose one of the two vectors. However, when we transpose a HepVector
we get back a HepMatrix. Thus, we end up performing vector*matrix multiplication
and not vector*vector.)
Performing matrix inversion timings table
(more condensed form of the same table: only
the minimum values are reported)
Performing random matrix inversion timings
table (more condensed form of the
same table: only the minimum values are reported)
Calculating matrix determinant timings
table (more condensed form of the
same table: only the minimum values are reported)
Calculating matrix trace timings table
(more condensed form of the same table: only
the minimum values are reported)
The following pages compare the results of various matrix operations
in CovMatrices with the same operations in LinearAlgebra and CLHEP.
The link on each matrix operation leads to a comparison summary for
the matrix operation, whereas the link on each package leads to the actual
test.
Matrix addition: LinearAlgebra,
CLHEP,
CLHEP
(Symmetric matrices), CovMatrices
Matrix subtraction: LinearAlgebra,
CLHEP,
CLHEP
(Symmetric matrices), CovMatrices
Matrix * Matrix multiplication: LinearAlgebra,
CLHEP,
CLHEP
(Symmetric matrices), CovMatrices
(dot product sums) (*)
Matrix * Vector multiplication: LinearAlgebra,
CLHEP,
CLHEP
(Symmetric matrices), CovMatrices
Vector * Matrix multiplication: LinearAlgebra,
CLHEP
(**),
CLHEP (Symmetric matrices)
(**), CovMatrices
(Column)Vector * (Row)Vector multiplication:
LinearAlgebra,
CLHEP
(***),
CovMatrices (dot product)
(*)
(Row)Vector * (Column)Vector multiplication:
LinearAlgebra,
CLHEP
(***),
CovMatrices (dot product)
(*)
Matrix trace: LinearAlgebra,
CLHEP,
CLHEP
(Symmetric matrices), CovMatrices
Matrix determinant: LinearAlgebra,
CLHEP,
CLHEP
(Symmetric matrices), CovMatrices
Matrix inversion: LinearAlgebra,
CLHEP,
CLHEP
(Symmetric matrices), CovMatrices
(*) Dot products do not test the ability of the package itself to perform
the clculations, they don't use/test a method native to the package; they
are provided for symmetry's sake.
(**) In order to perform vector*matrix in CLHEP we have to transpose
the vector. However, when we transpose a HepVector we get back a HepMatrix.
Thus, we end up performing matrix*matrix multiplication and not vector*matrix.
(***) In order to perform vector*vector in CLHEP we have to transpose
one of the two vectors. However, when we transpose a HepVector we get back
a HepMatrix. Thus, we end up performing vector*matrix multiplication and
not vector*vector.