LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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
 
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 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
 

Detailed Description

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

Routines for 4x4 matrices.

Definition at line 322 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 323 of file FastMatrixMathHelper.h.

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

Definition at line 325 of file FastMatrixMathHelper.h.

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

Definition at line 326 of file FastMatrixMathHelper.h.

using lar::util::details::FastMatrixOperationsBase< T, DIM >::Vector_t = std::array<Data_t, Dim>
inherited

Definition at line 39 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 329 of file FastMatrixMathHelper.h.

References lar::util::details::DeterminantHelper< T, N, RnC >::compute(), and mat.

330  {
332  }
static T compute(T const *data)
Float_t mat
Definition: plot.C:38
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 448 of file FastMatrixMathHelper.h.

References lar::util::details::DeterminantHelper< T, N, RnC >::compute(), lar::util::details::FastMatrixOperationsBase< T, DIM >::Dim, and mat.

450 {
451  //
452  // Basically using Cramer's rule;
453  // each element [r,c] gets assigned the determinant of the submatrix
454  // after removing c from the rows and r from the columns
455  // (effectively assigning the transpose of the minor matrix)
456  // with the usual sign -1^(r+c)
457  //
458  //
459  Data_t const* data = mat.data();
460  Matrix_t Inverse;
461  Inverse[0 * Dim + 0] = DeterminantHelper<T, 4, 1, 2, 3, 1, 2, 3>::compute(data) / det;
462  Inverse[0 * Dim + 1] = -DeterminantHelper<T, 4, 0, 2, 3, 1, 2, 3>::compute(data) / det;
463  Inverse[0 * Dim + 2] = DeterminantHelper<T, 4, 0, 1, 3, 1, 2, 3>::compute(data) / det;
464  Inverse[0 * Dim + 3] = -DeterminantHelper<T, 4, 0, 1, 2, 1, 2, 3>::compute(data) / det;
465  Inverse[1 * Dim + 0] = -DeterminantHelper<T, 4, 1, 2, 3, 0, 2, 3>::compute(data) / det;
466  Inverse[1 * Dim + 1] = DeterminantHelper<T, 4, 0, 2, 3, 0, 2, 3>::compute(data) / det;
467  Inverse[1 * Dim + 2] = -DeterminantHelper<T, 4, 0, 1, 3, 0, 2, 3>::compute(data) / det;
468  Inverse[1 * Dim + 3] = DeterminantHelper<T, 4, 0, 1, 2, 0, 2, 3>::compute(data) / det;
469  Inverse[2 * Dim + 0] = DeterminantHelper<T, 4, 1, 2, 3, 0, 1, 3>::compute(data) / det;
470  Inverse[2 * Dim + 1] = -DeterminantHelper<T, 4, 0, 2, 3, 0, 1, 3>::compute(data) / det;
471  Inverse[2 * Dim + 2] = DeterminantHelper<T, 4, 0, 1, 3, 0, 1, 3>::compute(data) / det;
472  Inverse[2 * Dim + 3] = -DeterminantHelper<T, 4, 0, 1, 2, 0, 1, 3>::compute(data) / det;
473  Inverse[3 * Dim + 0] = -DeterminantHelper<T, 4, 1, 2, 3, 0, 1, 2>::compute(data) / det;
474  Inverse[3 * Dim + 1] = DeterminantHelper<T, 4, 0, 2, 3, 0, 1, 2>::compute(data) / det;
475  Inverse[3 * Dim + 2] = -DeterminantHelper<T, 4, 0, 1, 3, 0, 1, 2>::compute(data) / det;
476  Inverse[3 * Dim + 3] = DeterminantHelper<T, 4, 0, 1, 2, 0, 1, 2>::compute(data) / det;
477  return Inverse;
478 } // FastMatrixOperations<T, 4>::InvertMatrix()
static T compute(T const *data)
Float_t mat
Definition: plot.C:38
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 342 of file FastMatrixMathHelper.h.

343  {
344  return InvertMatrix(mat, Determinant(mat));
345  }
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.
Float_t mat
Definition: plot.C:38
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 481 of file FastMatrixMathHelper.h.

References lar::util::details::DeterminantHelper< T, N, RnC >::compute(), lar::util::details::FastMatrixOperationsBase< T, DIM >::Dim, and mat.

483 {
484  //
485  // Same algorithm as InvertMatrix(), but use the fact that the result is
486  // also symmetric
487  //
488  Data_t const* data = mat.data();
489  Matrix_t Inverse;
490  Inverse[0 * Dim + 0] = DeterminantHelper<T, 4, 1, 2, 3, 1, 2, 3>::compute(data) / det;
491  Inverse[0 * Dim + 1] = Inverse[1 * Dim + 0] =
493  Inverse[0 * Dim + 2] = Inverse[2 * Dim + 0] =
495  Inverse[0 * Dim + 3] = Inverse[3 * Dim + 0] =
497  Inverse[1 * Dim + 1] = DeterminantHelper<T, 4, 0, 2, 3, 0, 2, 3>::compute(data) / det;
498  Inverse[1 * Dim + 2] = Inverse[2 * Dim + 1] =
500  Inverse[1 * Dim + 3] = Inverse[3 * Dim + 1] =
502  Inverse[2 * Dim + 2] = DeterminantHelper<T, 4, 0, 1, 3, 0, 1, 3>::compute(data) / det;
503  Inverse[2 * Dim + 3] = Inverse[3 * Dim + 2] =
505  Inverse[3 * Dim + 3] = DeterminantHelper<T, 4, 0, 1, 2, 0, 1, 2>::compute(data) / det;
506  return Inverse;
507 } // FastMatrixOperations<T, 4>::InvertSymmetricMatrix()
static T compute(T const *data)
Float_t mat
Definition: plot.C:38
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  {
351  }
static Data_t Determinant(Matrix_t const &mat)
Computes the determinant of a matrix.
Float_t mat
Definition: plot.C:38
static Matrix_t InvertSymmetricMatrix(Matrix_t const &mat, Data_t det)
static Vector_t lar::util::details::FastMatrixOperationsBase< T, DIM >::MatrixVectorProduct ( Matrix_t const &  mat,
Vector_t const &  vec 
)
staticinherited

Returns the product of a square matrix times a column vector.

static constexpr Data_t lar::util::details::FastMatrixOperationsBase< T, DIM >::sqr ( Data_t  v)
inlinestaticinherited

Definition at line 44 of file FastMatrixMathHelper.h.

44 { return v * v; }

Member Data Documentation

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

Definition at line 324 of file FastMatrixMathHelper.h.


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