Public Types | Static Public Member Functions | Static Public Attributes | List of all members
lar::util::details::FastMatrixOperations< T, 3 > Struct Template Reference

Routines for 3x3 matrices. More...

#include <FastMatrixMathHelper.h>

Inheritance diagram for lar::util::details::FastMatrixOperations< T, 3 >:
lar::util::details::FastMatrixOperationsBase< T, 3 >

Public Types

using Base_t = FastMatrixOperationsBase< T, 3 >
 
using Data_t = typename Base_t::Data_t
 
using Matrix_t = typename Base_t::Matrix_t
 
- Public Types inherited from lar::util::details::FastMatrixOperationsBase< T, 3 >
using Data_t = T
 
using Matrix_t = std::array< Data_t, Dim *Dim >
 
using Vector_t = std::array< Data_t, Dim >
 

Static Public Member Functions

static Data_t Determinant (Matrix_t const &mat)
 Computes the determinant of a matrix. More...
 
static Matrix_t InvertMatrix (Matrix_t const &mat, Data_t det)
 Computes the determinant of a matrix, using the provided determinant. More...
 
static Matrix_t InvertSymmetricMatrix (Matrix_t const &mat, Data_t det)
 
static Matrix_t InvertMatrix (Matrix_t const &mat)
 Computes the determinant of a matrix. More...
 
static Matrix_t InvertSymmetricMatrix (Matrix_t const &mat)
 Computes the determinant of a matrix. More...
 
- Static Public Member Functions inherited from lar::util::details::FastMatrixOperationsBase< T, 3 >
static Vector_t MatrixVectorProduct (Matrix_t const &mat, Vector_t const &vec)
 Returns the product of a square matrix times a column vector. More...
 
static constexpr Data_t sqr (Data_t v)
 

Static Public Attributes

static constexpr unsigned int Dim = Base_t::Dim
 
- Static Public Attributes inherited from lar::util::details::FastMatrixOperationsBase< T, 3 >
static constexpr unsigned int Dim
 matrix dimensions More...
 

Detailed Description

template<typename T>
struct lar::util::details::FastMatrixOperations< T, 3 >

Routines for 3x3 matrices.

Definition at line 286 of file FastMatrixMathHelper.h.

Member Typedef Documentation

template<typename T >
using lar::util::details::FastMatrixOperations< T, 3 >::Base_t = FastMatrixOperationsBase<T, 3>

Definition at line 289 of file FastMatrixMathHelper.h.

template<typename T >
using lar::util::details::FastMatrixOperations< T, 3 >::Data_t = typename Base_t::Data_t

Definition at line 291 of file FastMatrixMathHelper.h.

template<typename T >
using lar::util::details::FastMatrixOperations< T, 3 >::Matrix_t = typename Base_t::Matrix_t

Definition at line 292 of file FastMatrixMathHelper.h.

Member Function Documentation

template<typename T >
static Data_t lar::util::details::FastMatrixOperations< T, 3 >::Determinant ( Matrix_t const &  mat)
inlinestatic

Computes the determinant of a matrix.

Definition at line 295 of file FastMatrixMathHelper.h.

296  {
297  return
299  }
static T compute(T const *data)
template<typename T >
auto lar::util::details::FastMatrixOperations< T, 3 >::InvertMatrix ( Matrix_t const &  mat,
Data_t  det 
)
static

Computes the determinant of a matrix, using the provided determinant.

Definition at line 405 of file FastMatrixMathHelper.h.

406 {
407  Data_t const* data = mat.data();
408  Matrix_t Inverse;
409  //
410  // Basically using Cramer's rule;
411  // each element [r,c] gets assigned the determinant of the submatrix
412  // after removing c from the rows and r from the columns
413  // (effectively assigning the transpose of the minor matrix)
414  // with the usual sign -1^(r+c)
415  //
416  //
417  Inverse[0 * Dim + 0] = DeterminantHelper<T, 3, 1, 2, 1, 2>::compute(data)/det;
418  Inverse[0 * Dim + 1] = -DeterminantHelper<T, 3, 0, 2, 1, 2>::compute(data)/det;
419  Inverse[0 * Dim + 2] = DeterminantHelper<T, 3, 0, 1, 1, 2>::compute(data)/det;
420  Inverse[1 * Dim + 0] = -DeterminantHelper<T, 3, 1, 2, 0, 2>::compute(data)/det;
421  Inverse[1 * Dim + 1] = DeterminantHelper<T, 3, 0, 2, 0, 2>::compute(data)/det;
422  Inverse[1 * Dim + 2] = -DeterminantHelper<T, 3, 0, 1, 0, 2>::compute(data)/det;
423  Inverse[2 * Dim + 0] = DeterminantHelper<T, 3, 1, 2, 0, 1>::compute(data)/det;
424  Inverse[2 * Dim + 1] = -DeterminantHelper<T, 3, 0, 2, 0, 1>::compute(data)/det;
425  Inverse[2 * Dim + 2] = DeterminantHelper<T, 3, 0, 1, 0, 1>::compute(data)/det;
426  return Inverse;
427 } // FastMatrixOperations<T, 3>::InvertMatrix()
static T compute(T const *data)
template<typename T >
static Matrix_t lar::util::details::FastMatrixOperations< T, 3 >::InvertMatrix ( Matrix_t const &  mat)
inlinestatic

Computes the determinant of a matrix.

Definition at line 309 of file FastMatrixMathHelper.h.

310  { return InvertMatrix(mat, Determinant(mat)); }
static Matrix_t InvertMatrix(Matrix_t const &mat, Data_t det)
Computes the determinant of a matrix, using the provided determinant.
static Data_t Determinant(Matrix_t const &mat)
Computes the determinant of a matrix.
template<typename T >
auto lar::util::details::FastMatrixOperations< T, 3 >::InvertSymmetricMatrix ( Matrix_t const &  mat,
Data_t  det 
)
static

Computes the determinant of a symmatric matrix, using the provided determinant

Definition at line 432 of file FastMatrixMathHelper.h.

433 {
434  //
435  // Same algorithm as InvertMatrix(), but use the fact that the result is
436  // also symmetric
437  //
438  Data_t const* data = mat.data();
439  Matrix_t Inverse;
440  Inverse[0 * Dim + 0] = DeterminantHelper<T, 3, 1, 2, 1, 2>::compute(data)/det;
441  Inverse[0 * Dim + 1] =
442  Inverse[1 * Dim + 0] = -DeterminantHelper<T, 3, 1, 2, 0, 2>::compute(data)/det;
443  Inverse[0 * Dim + 2] =
444  Inverse[2 * Dim + 0] = DeterminantHelper<T, 3, 1, 2, 0, 1>::compute(data)/det;
445  Inverse[1 * Dim + 1] = DeterminantHelper<T, 3, 0, 2, 0, 2>::compute(data)/det;
446  Inverse[1 * Dim + 2] =
447  Inverse[2 * Dim + 1] = -DeterminantHelper<T, 3, 0, 2, 0, 1>::compute(data)/det;
448  Inverse[2 * Dim + 2] = DeterminantHelper<T, 3, 0, 1, 0, 1>::compute(data)/det;
449  return Inverse;
450 } // FastMatrixOperations<T, 3>::InvertSymmetricMatrix()
static T compute(T const *data)
template<typename T >
static Matrix_t lar::util::details::FastMatrixOperations< T, 3 >::InvertSymmetricMatrix ( Matrix_t const &  mat)
inlinestatic

Computes the determinant of a matrix.

Definition at line 313 of file FastMatrixMathHelper.h.

314  { return InvertSymmetricMatrix(mat, Determinant(mat)); }
static Matrix_t InvertSymmetricMatrix(Matrix_t const &mat, Data_t det)
static Data_t Determinant(Matrix_t const &mat)
Computes the determinant of a matrix.

Member Data Documentation

template<typename T >
constexpr unsigned int lar::util::details::FastMatrixOperations< T, 3 >::Dim = Base_t::Dim
static

Definition at line 290 of file FastMatrixMathHelper.h.


The documentation for this struct was generated from the following file: