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

Routines for 4x4 matrices. More...

#include <FastMatrixMathHelper.h>

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

Public Types

using Base_t = FastMatrixOperationsBase< T, 4 >
 
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, 4 >
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, 4 >
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, 4 >
static constexpr unsigned int Dim
 matrix dimensions More...
 

Detailed Description

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

Routines for 4x4 matrices.

Definition at line 321 of file FastMatrixMathHelper.h.

Member Typedef Documentation

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

Definition at line 324 of file FastMatrixMathHelper.h.

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

Definition at line 326 of file FastMatrixMathHelper.h.

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

Definition at line 327 of file FastMatrixMathHelper.h.

Member Function Documentation

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

Computes the determinant of a matrix.

Definition at line 330 of file FastMatrixMathHelper.h.

331  {
333  (mat.data());
334  }
static T compute(T const *data)
template<typename T >
auto lar::util::details::FastMatrixOperations< T, 4 >::InvertMatrix ( Matrix_t const &  mat,
Data_t  det 
)
static

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

Definition at line 455 of file FastMatrixMathHelper.h.

456 {
457  //
458  // Basically using Cramer's rule;
459  // each element [r,c] gets assigned the determinant of the submatrix
460  // after removing c from the rows and r from the columns
461  // (effectively assigning the transpose of the minor matrix)
462  // with the usual sign -1^(r+c)
463  //
464  //
465  Data_t const* data = mat.data();
466  Matrix_t Inverse;
467  Inverse[0 * Dim + 0] = DeterminantHelper<T, 4, 1, 2, 3, 1, 2, 3>::compute(data)/det;
468  Inverse[0 * Dim + 1] = -DeterminantHelper<T, 4, 0, 2, 3, 1, 2, 3>::compute(data)/det;
469  Inverse[0 * Dim + 2] = DeterminantHelper<T, 4, 0, 1, 3, 1, 2, 3>::compute(data)/det;
470  Inverse[0 * Dim + 3] = -DeterminantHelper<T, 4, 0, 1, 2, 1, 2, 3>::compute(data)/det;
471  Inverse[1 * Dim + 0] = -DeterminantHelper<T, 4, 1, 2, 3, 0, 2, 3>::compute(data)/det;
472  Inverse[1 * Dim + 1] = DeterminantHelper<T, 4, 0, 2, 3, 0, 2, 3>::compute(data)/det;
473  Inverse[1 * Dim + 2] = -DeterminantHelper<T, 4, 0, 1, 3, 0, 2, 3>::compute(data)/det;
474  Inverse[1 * Dim + 3] = DeterminantHelper<T, 4, 0, 1, 2, 0, 2, 3>::compute(data)/det;
475  Inverse[2 * Dim + 0] = DeterminantHelper<T, 4, 1, 2, 3, 0, 1, 3>::compute(data)/det;
476  Inverse[2 * Dim + 1] = -DeterminantHelper<T, 4, 0, 2, 3, 0, 1, 3>::compute(data)/det;
477  Inverse[2 * Dim + 2] = DeterminantHelper<T, 4, 0, 1, 3, 0, 1, 3>::compute(data)/det;
478  Inverse[2 * Dim + 3] = -DeterminantHelper<T, 4, 0, 1, 2, 0, 1, 3>::compute(data)/det;
479  Inverse[3 * Dim + 0] = -DeterminantHelper<T, 4, 1, 2, 3, 0, 1, 2>::compute(data)/det;
480  Inverse[3 * Dim + 1] = DeterminantHelper<T, 4, 0, 2, 3, 0, 1, 2>::compute(data)/det;
481  Inverse[3 * Dim + 2] = -DeterminantHelper<T, 4, 0, 1, 3, 0, 1, 2>::compute(data)/det;
482  Inverse[3 * Dim + 3] = DeterminantHelper<T, 4, 0, 1, 2, 0, 1, 2>::compute(data)/det;
483  return Inverse;
484 } // FastMatrixOperations<T, 4>::InvertMatrix()
static T compute(T const *data)
template<typename T >
static Matrix_t lar::util::details::FastMatrixOperations< T, 4 >::InvertMatrix ( Matrix_t const &  mat)
inlinestatic

Computes the determinant of a matrix.

Definition at line 344 of file FastMatrixMathHelper.h.

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

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

Definition at line 489 of file FastMatrixMathHelper.h.

490 {
491  //
492  // Same algorithm as InvertMatrix(), but use the fact that the result is
493  // also symmetric
494  //
495  Data_t const* data = mat.data();
496  Matrix_t Inverse;
497  Inverse[0 * Dim + 0] = DeterminantHelper<T, 4, 1, 2, 3, 1, 2, 3>::compute(data)/det;
498  Inverse[0 * Dim + 1] =
499  Inverse[1 * Dim + 0] = -DeterminantHelper<T, 4, 1, 2, 3, 0, 2, 3>::compute(data)/det;
500  Inverse[0 * Dim + 2] =
501  Inverse[2 * Dim + 0] = DeterminantHelper<T, 4, 1, 2, 3, 0, 1, 3>::compute(data)/det;
502  Inverse[0 * Dim + 3] =
503  Inverse[3 * Dim + 0] = -DeterminantHelper<T, 4, 1, 2, 3, 0, 1, 2>::compute(data)/det;
504  Inverse[1 * Dim + 1] = DeterminantHelper<T, 4, 0, 2, 3, 0, 2, 3>::compute(data)/det;
505  Inverse[1 * Dim + 2] =
506  Inverse[2 * Dim + 1] = -DeterminantHelper<T, 4, 0, 2, 3, 3, 0, 1>::compute(data)/det;
507  Inverse[1 * Dim + 3] =
508  Inverse[3 * Dim + 1] = DeterminantHelper<T, 4, 0, 2, 3, 0, 1, 2>::compute(data)/det;
509  Inverse[2 * Dim + 2] = DeterminantHelper<T, 4, 0, 1, 3, 0, 1, 3>::compute(data)/det;
510  Inverse[2 * Dim + 3] =
511  Inverse[3 * Dim + 2] = -DeterminantHelper<T, 4, 0, 1, 3, 0, 1, 2>::compute(data)/det;
512  Inverse[3 * Dim + 3] = DeterminantHelper<T, 4, 0, 1, 2, 0, 1, 2>::compute(data)/det;
513  return Inverse;
514 } // FastMatrixOperations<T, 4>::InvertSymmetricMatrix()
static T compute(T const *data)
template<typename T >
static Matrix_t lar::util::details::FastMatrixOperations< T, 4 >::InvertSymmetricMatrix ( Matrix_t const &  mat)
inlinestatic

Computes the determinant of a matrix.

Definition at line 348 of file FastMatrixMathHelper.h.

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

Member Data Documentation

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

Definition at line 325 of file FastMatrixMathHelper.h.


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