Linear algebra




Most of the mathematical operations used for reconstruction need powerful vector and matrix classes. There are several packages providing such a functionality. The package chosen is CLHEP, which constitutes the only RecPack external dependency. The classes EVector and EMatrix, which are typedefs of the CLHEP classes HepVector and HepMatrix are used. On the other hand, in reconstruction processes, which imply experimental errors, a vector has usually associated a covariance matrix. This is the case of the measurement vector or the vector of parameters resulting from a fit to a given model. RecPack provides a class call HyperVector that is the aggregation of an EVector and an EMatrix.

Being EVector and EMatrix typedefs of the classes of an external package, one could replace CLHEP by another external package. To do that the numerical operations with EVector and EMatrix used in the RecPack code should be available in the new package. If this is not the case the user should implement the corresponding interface. This interface should be implemented in the file util/EAlgebra.h/cpp. The algebraic operations used in RecPack, which are provided directly by CLHEP are:

  • dot(v1,v2): scalar product between two vectors
  • v1+v2: sum of vectors
  • v1-v2: subtraction of vectors
  • a*v: product of vector times scalar
  • M1*M2: product of matrices
  • M1+M2: sum of matrices
  • M1-M2: subtraction of matrices
  • a*M: scalar times matrix
  • v*M: vector times matrix
  • M*v: matrix times vector


  • There are other EVector and EMatrix functions that should be available:

  • num_rows(): number of rows of a vector or a matrix
  • M.T(): transpose of a matrix
  • M.inverse(): inverse of a matrix
  • v[], M[][]: access to vector and matrix elements