General -dimensional mathematical matrix object.
More...
#include <MatrixN.hh>
Public Member Functions | |
Matrix () | |
Matrix (const Matrix< N > &other) | |
Matrix & | set (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) |
General -dimensional mathematical matrix object.
Definition at line 30 of file MatrixN.hh.
typedef Eigen::Matrix<double,N> EMatrix [protected] |
Definition at line 253 of file MatrixN.hh.
Matrix | ( | ) | [inline] |
Definition at line 67 of file MatrixN.hh.
00067 { 00068 _matrix.loadZero(); 00069 }
Definition at line 71 of file MatrixN.hh.
00071 { 00072 _matrix = other._matrix; 00073 }
double det | ( | ) | const [inline] |
Calculate determinant.
Definition at line 141 of file MatrixN.hh.
00141 { 00142 return _matrix.determinant(); 00143 }
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().
00084 { 00085 if (i < N && j < N) { 00086 return _matrix(i, j); 00087 } else { 00088 throw std::runtime_error("Attempted get access outside matrix bounds."); 00089 } 00090 }
Vector<N> getColumn | ( | const size_t | col | ) | const [inline] |
Definition at line 107 of file MatrixN.hh.
Referenced by LorentzTransform::boost().
00107 { 00108 Vector<N> rtn; 00109 for (size_t i = 0; i < N; ++i) { 00110 rtn.set(i, _matrix(i,col)); 00111 } 00112 return rtn; 00113 }
Vector<N> getRow | ( | const size_t | row | ) | const [inline] |
Definition at line 92 of file MatrixN.hh.
00092 { 00093 Vector<N> rtn; 00094 for (size_t i = 0; i < N; ++i) { 00095 rtn.set(i, _matrix(row,i)); 00096 } 00097 return rtn; 00098 }
Matrix<N> inverse | ( | ) | const [inline] |
Calculate inverse.
Definition at line 134 of file MatrixN.hh.
Referenced by Rivet::inverse(), LorentzTransform::inverse(), and LorentzTransform::rotate().
00134 { 00135 Matrix<N> tmp; 00136 tmp._matrix = _matrix.inverse(); 00137 return tmp; 00138 }
bool isDiag | ( | ) | const [inline] |
Check that all off-diagonal elements are zero, allowing for numerical precision.
Definition at line 193 of file MatrixN.hh.
00193 { 00194 for (size_t i=0; i < N; ++i) { 00195 for (size_t j=0; j < N; ++j) { 00196 if (i == j) continue; 00197 if (! Rivet::isZero(_matrix(i,j)) ) return false; 00198 } 00199 } 00200 return true; 00201 }
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().
00178 { 00179 for (size_t i=0; i < N; ++i) { 00180 for (size_t j=i; j < N; ++j) { 00181 if (! Rivet::isZero(_matrix(i,j) - other._matrix(i,j)) ) return false; 00182 } 00183 } 00184 return true; 00185 }
bool isSymm | ( | ) | const [inline] |
Check for symmetry under transposition.
Definition at line 188 of file MatrixN.hh.
Referenced by FParameter::_calcFParameter(), and Sphericity::_calcSphericity().
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().
00168 { 00169 for (size_t i=0; i < N; ++i) { 00170 for (size_t j=0; j < N; ++j) { 00171 if (! Rivet::isZero(_matrix(i,j), tolerance) ) return false; 00172 } 00173 } 00174 return true; 00175 }
Definition at line 48 of file MatrixN.hh.
static Matrix<N> mkIdentity | ( | ) | [inline, static] |
Definition at line 56 of file MatrixN.hh.
static Matrix<N> mkZero | ( | ) | [inline, static] |
Definition at line 43 of file MatrixN.hh.
bool operator!= | ( | const Matrix< N > & | a | ) | const [inline] |
Definition at line 207 of file MatrixN.hh.
00207 { 00208 return _matrix != a._matrix; 00209 }
Matrix<N>& operator*= | ( | const double | a | ) | [inline] |
Definition at line 232 of file MatrixN.hh.
00232 { 00233 _matrix *= a; 00234 return *this; 00235 }
Definition at line 227 of file MatrixN.hh.
Definition at line 242 of file MatrixN.hh.
Matrix<N> operator- | ( | ) | const [inline] |
Negate.
Definition at line 156 of file MatrixN.hh.
00156 { 00157 Matrix<N> rtn; 00158 rtn._matrix = -_matrix; 00159 return rtn; 00160 }
Definition at line 247 of file MatrixN.hh.
Matrix<N>& operator/= | ( | const double | a | ) | [inline] |
Definition at line 237 of file MatrixN.hh.
00237 { 00238 _matrix /= a; 00239 return *this; 00240 }
bool operator< | ( | const Matrix< N > & | a | ) | const [inline] |
Definition at line 211 of file MatrixN.hh.
00211 { 00212 return _matrix < a._matrix; 00213 }
bool operator<= | ( | const Matrix< N > & | a | ) | const [inline] |
Definition at line 215 of file MatrixN.hh.
00215 { 00216 return _matrix <= a._matrix; 00217 }
bool operator== | ( | const Matrix< N > & | a | ) | const [inline] |
Definition at line 203 of file MatrixN.hh.
00203 { 00204 return _matrix == a._matrix; 00205 }
bool operator> | ( | const Matrix< N > & | a | ) | const [inline] |
Definition at line 219 of file MatrixN.hh.
00219 { 00220 return _matrix > a._matrix; 00221 }
bool operator>= | ( | const Matrix< N > & | a | ) | const [inline] |
Definition at line 223 of file MatrixN.hh.
00223 { 00224 return _matrix >= a._matrix; 00225 }
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().
00075 { 00076 if (i < N && j < N) { 00077 _matrix(i, j) = value; 00078 } else { 00079 throw std::runtime_error("Attempted set access outside matrix bounds."); 00080 } 00081 return *this; 00082 }
Definition at line 115 of file MatrixN.hh.
00115 { 00116 for (size_t i = 0; i < N; ++i) { 00117 _matrix(i,col) = c.get(i); 00118 } 00119 return *this; 00120 }
Definition at line 100 of file MatrixN.hh.
00100 { 00101 for (size_t i = 0; i < N; ++i) { 00102 _matrix(row,i) = r.get(i); 00103 } 00104 return *this; 00105 }
size_t size | ( | ) | const [inline] |
double trace | ( | ) | const [inline] |
Calculate trace.
Definition at line 146 of file MatrixN.hh.
Referenced by Rivet::trace().
00146 { 00147 double tr = 0.0; 00148 for (size_t i = 0; i < N; ++i) { 00149 tr += _matrix(i,i); 00150 } 00151 return tr; 00152 // return _matrix.trace(); 00153 }
Matrix<N> transpose | ( | ) | const [inline] |
Definition at line 122 of file MatrixN.hh.
Referenced by Matrix< 4 >::isSymm(), and Rivet::transpose().
Definition at line 254 of file MatrixN.hh.
Referenced by Rivet::add(), Matrix< 4 >::det(), Matrix< 4 >::get(), Matrix< 4 >::getColumn(), Matrix< 4 >::getRow(), Matrix< 4 >::inverse(), Matrix< 4 >::isDiag(), Matrix< 4 >::isEqual(), Matrix< 4 >::isZero(), Matrix< 4 >::Matrix(), Rivet::multiply(), Matrix< 4 >::operator!=(), Matrix< 4 >::operator*=(), Matrix< 4 >::operator+=(), Matrix< 4 >::operator-(), Matrix< 4 >::operator-=(), Matrix< 4 >::operator/=(), Matrix< 4 >::operator<(), Matrix< 4 >::operator<=(), Matrix< 4 >::operator==(), Matrix< 4 >::operator>(), Matrix< 4 >::operator>=(), Matrix< 4 >::set(), Matrix< 4 >::setColumn(), Matrix< 4 >::setRow(), Matrix< 4 >::trace(), and Matrix< 4 >::transpose().