rivet is hosted by Hepforge, IPPP Durham

General $ N $-dimensional mathematical matrix object. More...

#include <MatrixN.hh>

Inheritance diagram for Matrix< N >:

List of all members.

Public Member Functions

 Matrix ()
 Matrix (const Matrix< N > &other)
Matrixset (const size_t i, const size_t j, const double value)
double get (const size_t i, const size_t j) const
Vector< N > getRow (const size_t row) const
Matrix< N > & setRow (const size_t row, const Vector< N > &r)
Vector< N > getColumn (const size_t col) const
Matrix< N > & setColumn (const size_t col, const Vector< N > &c)
Matrix< N > transpose () const
Matrix< N > inverse () const
 Calculate inverse.
double det () const
 Calculate determinant.
double trace () const
 Calculate trace.
Matrix< N > operator- () const
 Negate.
size_t size () const
 Get dimensionality.
bool isZero (double tolerance=1E-5) const
 Index-wise check for nullness, allowing for numerical precision.
bool isEqual (Matrix< N > other) const
 Check for index-wise equality, allowing for numerical precision.
bool isSymm () const
 Check for symmetry under transposition.
bool isDiag () const
 Check that all off-diagonal elements are zero, allowing for numerical precision.
bool operator== (const Matrix< N > &a) const
bool operator!= (const Matrix< N > &a) const
bool operator< (const Matrix< N > &a) const
bool operator<= (const Matrix< N > &a) const
bool operator> (const Matrix< N > &a) const
bool operator>= (const Matrix< N > &a) const
Matrix< N > & operator*= (const Matrix< N > &m)
Matrix< N > & operator*= (const double a)
Matrix< N > & operator/= (const double a)
Matrix< N > & operator+= (const Matrix< N > &m)
Matrix< N > & operator-= (const Matrix< N > &m)

Static Public Member Functions

static Matrix< N > mkZero ()
static Matrix< N > mkDiag (Vector< N > diag)
static Matrix< N > mkIdentity ()

Protected Types

typedef Eigen::Matrix< double, N > EMatrix

Protected Attributes

EMatrix _matrix

Friends

template<size_t M>
Matrix< M > add (const Matrix< M > &, const Matrix< M > &)
template<size_t M>
Matrix< M > multiply (const double, const Matrix< M > &)
template<size_t M>
Matrix< M > multiply (const Matrix< M > &, const Matrix< M > &)
template<size_t M>
Vector< M > multiply (const Matrix< M > &, const Vector< M > &)
template<size_t M>
Matrix< M > divide (const Matrix< M > &, const double)

Detailed Description

template<size_t N>
class Rivet::Matrix< N >

General $ N $-dimensional mathematical matrix object.

Definition at line 30 of file MatrixN.hh.


Member Typedef Documentation

typedef Eigen::Matrix<double,N> EMatrix [protected]

Definition at line 253 of file MatrixN.hh.


Constructor & Destructor Documentation

Matrix ( ) [inline]

Definition at line 67 of file MatrixN.hh.

             {
      _matrix.loadZero();
    }
Matrix ( const Matrix< N > &  other) [inline]

Definition at line 71 of file MatrixN.hh.

                                   {
      _matrix = other._matrix;
    }

Member Function Documentation

double det ( ) const [inline]

Calculate determinant.

Definition at line 141 of file MatrixN.hh.

                        {
      return _matrix.determinant();
    }
double get ( const size_t  i,
const size_t  j 
) const [inline]

Definition at line 84 of file MatrixN.hh.

Referenced by FParameter::_calcFParameter(), Sphericity::_calcSphericity(), Rivet::diagonalize(), Rivet::fuzzyEquals(), LorentzTransform::mkMatrix4(), and Rivet::toString().

                                                     {
      if (i < N && j < N) {
        return _matrix(i, j);
      } else {
        throw std::runtime_error("Attempted get access outside matrix bounds.");
      }
    }
Vector<N> getColumn ( const size_t  col) const [inline]

Definition at line 107 of file MatrixN.hh.

Referenced by LorentzTransform::boost().

                                                {
      Vector<N> rtn;
      for (size_t i = 0; i < N; ++i) {
        rtn.set(i, _matrix(i,col));
      }
      return rtn;
    }
Vector<N> getRow ( const size_t  row) const [inline]

Definition at line 92 of file MatrixN.hh.

                                             {
      Vector<N> rtn;
      for (size_t i = 0; i < N; ++i) {
        rtn.set(i, _matrix(row,i));
      }
      return rtn;
    }
Matrix<N> inverse ( ) const [inline]

Calculate inverse.

Definition at line 134 of file MatrixN.hh.

Referenced by LorentzTransform::inverse(), Rivet::inverse(), and LorentzTransform::rotate().

                              {
      Matrix<N> tmp;
      tmp._matrix = _matrix.inverse();
      return tmp;
    }
bool isDiag ( ) const [inline]

Check that all off-diagonal elements are zero, allowing for numerical precision.

Definition at line 193 of file MatrixN.hh.

                        {
      for (size_t i=0; i < N; ++i) {
        for (size_t j=0; j < N; ++j) {
          if (i == j) continue;
          if (! Rivet::isZero(_matrix(i,j)) ) return false;
        }
      }
      return true;
    }
bool isEqual ( Matrix< N >  other) const [inline]

Check for index-wise equality, allowing for numerical precision.

Definition at line 178 of file MatrixN.hh.

Referenced by Matrix< 4 >::isSymm().

                                        {
      for (size_t i=0; i < N; ++i) {
        for (size_t j=i; j < N; ++j) {
          if (! Rivet::isZero(_matrix(i,j) - other._matrix(i,j)) ) return false;
        }
      }
      return true;
    }
bool isSymm ( ) const [inline]

Check for symmetry under transposition.

Definition at line 188 of file MatrixN.hh.

Referenced by FParameter::_calcFParameter(), and Sphericity::_calcSphericity().

                        {
      return isEqual(this->transpose());
    }
bool isZero ( double  tolerance = 1E-5) const [inline]

Index-wise check for nullness, allowing for numerical precision.

Definition at line 168 of file MatrixN.hh.

Referenced by Rivet::isZero().

                                             {
      for (size_t i=0; i < N; ++i) {
        for (size_t j=0; j < N; ++j) {
          if (! Rivet::isZero(_matrix(i,j), tolerance) ) return false;
        }
      }
      return true;
    }
static Matrix<N> mkDiag ( Vector< N >  diag) [inline, static]

Definition at line 48 of file MatrixN.hh.

                                            {
      Matrix<N> rtn;
      for (size_t i = 0; i < N; ++i) {
        rtn.set(i, i, diag[i]);
      }
      return rtn;
    }
static Matrix<N> mkIdentity ( ) [inline, static]

Definition at line 56 of file MatrixN.hh.

                                  {
      Matrix<N> rtn;
      for (size_t i = 0; i < N; ++i) {
        rtn.set(i, i, 1);
      }
      return rtn;
    }
static Matrix<N> mkZero ( ) [inline, static]

Definition at line 43 of file MatrixN.hh.

                              {
      Matrix<N> rtn;
      return rtn;
    }
bool operator!= ( const Matrix< N > &  a) const [inline]

Definition at line 207 of file MatrixN.hh.

                                              {
      return _matrix != a._matrix;
    }
Matrix<N>& operator*= ( const Matrix< N > &  m) [inline]

Definition at line 227 of file MatrixN.hh.

                                              {
      _matrix = _matrix * m._matrix;
      return *this;
    }
Matrix<N>& operator*= ( const double  a) [inline]

Definition at line 232 of file MatrixN.hh.

                                          {
      _matrix *= a;
      return *this;
    }
Matrix<N>& operator+= ( const Matrix< N > &  m) [inline]

Definition at line 242 of file MatrixN.hh.

                                              {
      _matrix += m._matrix;
      return *this;
    }
Matrix<N> operator- ( ) const [inline]

Negate.

Definition at line 156 of file MatrixN.hh.

                                {
      Matrix<N> rtn;
      rtn._matrix = -_matrix;
      return rtn;
    }
Matrix<N>& operator-= ( const Matrix< N > &  m) [inline]

Definition at line 247 of file MatrixN.hh.

                                              {
      _matrix -= m._matrix;
      return *this;
    }
Matrix<N>& operator/= ( const double  a) [inline]

Definition at line 237 of file MatrixN.hh.

                                          {
      _matrix /= a;
      return *this;
    }
bool operator< ( const Matrix< N > &  a) const [inline]

Definition at line 211 of file MatrixN.hh.

                                             {
      return _matrix < a._matrix;
    }
bool operator<= ( const Matrix< N > &  a) const [inline]

Definition at line 215 of file MatrixN.hh.

                                              {
      return _matrix <= a._matrix;
    }
bool operator== ( const Matrix< N > &  a) const [inline]

Definition at line 203 of file MatrixN.hh.

                                              {
      return _matrix == a._matrix;
    }
bool operator> ( const Matrix< N > &  a) const [inline]

Definition at line 219 of file MatrixN.hh.

                                             {
      return _matrix > a._matrix;
    }
bool operator>= ( const Matrix< N > &  a) const [inline]

Definition at line 223 of file MatrixN.hh.

                                              {
      return _matrix >= a._matrix;
    }
Matrix& set ( const size_t  i,
const size_t  j,
const double  value 
) [inline]

Definition at line 75 of file MatrixN.hh.

Referenced by FParameter::_calcFParameter(), Sphericity::_calcSphericity(), Matrix< 4 >::mkDiag(), Matrix< 4 >::mkIdentity(), LorentzTransform::mkMatrix4(), and LorentzTransform::setBoost().

                                                                    {
      if (i < N && j < N) {
        _matrix(i, j) = value;
      } else {
        throw std::runtime_error("Attempted set access outside matrix bounds.");
      }
      return *this;
    }
Matrix<N>& setColumn ( const size_t  col,
const Vector< N > &  c 
) [inline]

Definition at line 115 of file MatrixN.hh.

                                                               {
      for (size_t i = 0; i < N; ++i) {
        _matrix(i,col) = c.get(i);
      }
      return *this;
    }
Matrix<N>& setRow ( const size_t  row,
const Vector< N > &  r 
) [inline]

Definition at line 100 of file MatrixN.hh.

                                                            {
      for (size_t i = 0; i < N; ++i) {
        _matrix(row,i) = r.get(i);
      }
      return *this;
    }
size_t size ( ) const [inline]

Get dimensionality.

Definition at line 163 of file MatrixN.hh.

Referenced by Rivet::toString().

                        {
      return N;
    }
double trace ( ) const [inline]

Calculate trace.

Definition at line 146 of file MatrixN.hh.

Referenced by Rivet::trace().

                         {
      double tr = 0.0;
      for (size_t i = 0; i < N; ++i) {
        tr += _matrix(i,i);
      }
      return tr;
      // return _matrix.trace();
    }
Matrix<N> transpose ( ) const [inline]

Definition at line 122 of file MatrixN.hh.

Referenced by Matrix< 4 >::isSymm(), and Rivet::transpose().

                                {
      Matrix<N> tmp = *this;
      tmp._matrix.replaceWithAdjoint();
      return tmp;
    }

Friends And Related Function Documentation

Matrix<M> add ( const Matrix< M > &  ,
const Matrix< M > &   
) [friend]
Matrix<M> divide ( const Matrix< M > &  ,
const double   
) [friend]
Matrix<M> multiply ( const double  ,
const Matrix< M > &   
) [friend]
Matrix<M> multiply ( const Matrix< M > &  ,
const Matrix< M > &   
) [friend]
Vector<M> multiply ( const Matrix< M > &  ,
const Vector< M > &   
) [friend]

Member Data Documentation


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