40template <
class DT>
class Tvec5;
41template <
class DT>
class Tmat4;
76 Tmat5(
const double in00,
const double in01,
const double in02,
const double in03,
const double in04,
77 const double in10,
const double in11,
const double in12,
const double in13,
const double in14,
78 const double in20,
const double in21,
const double in22,
const double in23,
const double in24,
79 const double in30,
const double in31,
const double in32,
const double in33,
const double in34,
80 const double in40,
const double in41,
const double in42,
const double in43,
const double in44);
168 this->v[0] = this->v[1] = this->v[2] = this->v[3] = this->v[4] =
Tvec5<DT>(0);
175 this->v[0][0] = this->v[1][1] = this->v[2][2] = this->v[3][3] = this->v[4][4] = diagValue;
176 this->v[1][0] = this->v[2][0] = this->v[3][0] = this->v[4][0] = this->v[2][1] = this->v[3][1] = this->v[4][1] = this->v[3][2] = this->v[4][2] = this->v[4][3] = 0;
177 this->v[0][1] = this->v[0][2] = this->v[0][3] = this->v[0][4] = this->v[1][2] = this->v[1][3] = this->v[1][4] = this->v[2][3] = this->v[2][4] = this->v[3][4] = 0;
197 this->v[0] = mat.
v[0];
198 this->v[1] = mat.
v[1];
199 this->v[2] = mat.
v[2];
200 this->v[3] = mat.
v[3];
201 this->v[4] = mat.
v[4];
222 return Tmat5<DT>(val, val, val, val, val,
223 val, val, val, val, val,
224 val, val, val, val, val,
225 val, val, val, val, val,
226 val, val, val, val, val);
233 this->v[0] = this->v[1] = this->v[2] = this->v[3] = this->v[4] =
Tvec5<DT>(val);
255 this->v[0] += m.
v[0];
256 this->v[1] += m.
v[1];
257 this->v[2] += m.
v[2];
258 this->v[3] += m.
v[3];
259 this->v[4] += m.
v[4];
268 this->v[0] -= m.
v[0];
269 this->v[1] -= m.
v[1];
270 this->v[2] -= m.
v[2];
271 this->v[3] -= m.
v[3];
272 this->v[4] -= m.
v[4];
312 return Tmat5<DT>(a) *=
static_cast<DT
>(-1.0);
366Tmat5<DT>::Tmat5(
const double in00,
const double in01,
const double in02,
const double in03,
const double in04,
367 const double in10,
const double in11,
const double in12,
const double in13,
const double in14,
368 const double in20,
const double in21,
const double in22,
const double in23,
const double in24,
369 const double in30,
const double in31,
const double in32,
const double in33,
const double in34,
370 const double in40,
const double in41,
const double in42,
const double in43,
const double in44)
372 this->v[0][0]=
static_cast<DT
>(in00); this->v[0][1]=
static_cast<DT
>(in01); this->v[0][2]=
static_cast<DT
>(in02); this->v[0][3]=
static_cast<DT
>(in03); this->v[0][4]=
static_cast<DT
>(in04);
373 this->v[1][0]=
static_cast<DT
>(in10); this->v[1][1]=
static_cast<DT
>(in11); this->v[1][2]=
static_cast<DT
>(in12); this->v[1][3]=
static_cast<DT
>(in13); this->v[1][4]=
static_cast<DT
>(in14);
374 this->v[2][0]=
static_cast<DT
>(in20); this->v[2][1]=
static_cast<DT
>(in21); this->v[2][2]=
static_cast<DT
>(in22); this->v[2][3]=
static_cast<DT
>(in23); this->v[2][4]=
static_cast<DT
>(in24);
375 this->v[3][0]=
static_cast<DT
>(in30); this->v[3][1]=
static_cast<DT
>(in31); this->v[3][2]=
static_cast<DT
>(in32); this->v[3][3]=
static_cast<DT
>(in33); this->v[3][4]=
static_cast<DT
>(in34);
376 this->v[4][0]=
static_cast<DT
>(in40); this->v[4][1]=
static_cast<DT
>(in41); this->v[4][2]=
static_cast<DT
>(in42); this->v[4][3]=
static_cast<DT
>(in43); this->v[4][4]=
static_cast<DT
>(in44);
387 this->v[0][0] =
static_cast<DT
>(m[ 0]);
388 this->v[0][1] =
static_cast<DT
>(m[ 1]);
389 this->v[0][2] =
static_cast<DT
>(m[ 2]);
390 this->v[0][3] =
static_cast<DT
>(m[ 3]);
391 this->v[0][4] =
static_cast<DT
>(m[ 4]);
393 this->v[1][0] =
static_cast<DT
>(m[ 5]);
394 this->v[1][1] =
static_cast<DT
>(m[ 6]);
395 this->v[1][2] =
static_cast<DT
>(m[ 7]);
396 this->v[1][3] =
static_cast<DT
>(m[ 8]);
397 this->v[1][4] =
static_cast<DT
>(m[ 9]);
399 this->v[2][0] =
static_cast<DT
>(m[10]);
400 this->v[2][1] =
static_cast<DT
>(m[11]);
401 this->v[2][2] =
static_cast<DT
>(m[12]);
402 this->v[2][3] =
static_cast<DT
>(m[13]);
403 this->v[2][4] =
static_cast<DT
>(m[14]);
405 this->v[3][0] =
static_cast<DT
>(m[15]);
406 this->v[3][1] =
static_cast<DT
>(m[16]);
407 this->v[3][2] =
static_cast<DT
>(m[17]);
408 this->v[3][3] =
static_cast<DT
>(m[18]);
409 this->v[3][4] =
static_cast<DT
>(m[19]);
411 this->v[4][0] =
static_cast<DT
>(m[20]);
412 this->v[4][1] =
static_cast<DT
>(m[21]);
413 this->v[4][2] =
static_cast<DT
>(m[22]);
414 this->v[4][3] =
static_cast<DT
>(m[23]);
415 this->v[4][4] =
static_cast<DT
>(m[24]);
427 m[ 0] =
static_cast<float>(this->v[0][0]);
428 m[ 1] =
static_cast<float>(this->v[0][1]);
429 m[ 2] =
static_cast<float>(this->v[0][2]);
430 m[ 3] =
static_cast<float>(this->v[0][3]);
431 m[ 4] =
static_cast<float>(this->v[0][4]);
433 m[ 5] =
static_cast<float>(this->v[1][0]);
434 m[ 6] =
static_cast<float>(this->v[1][1]);
435 m[ 7] =
static_cast<float>(this->v[1][2]);
436 m[ 8] =
static_cast<float>(this->v[1][3]);
437 m[ 9] =
static_cast<float>(this->v[1][4]);
439 m[10] =
static_cast<float>(this->v[2][0]);
440 m[11] =
static_cast<float>(this->v[2][1]);
441 m[12] =
static_cast<float>(this->v[2][2]);
442 m[13] =
static_cast<float>(this->v[2][3]);
443 m[14] =
static_cast<float>(this->v[2][4]);
445 m[15] =
static_cast<float>(this->v[3][0]);
446 m[16] =
static_cast<float>(this->v[3][1]);
447 m[17] =
static_cast<float>(this->v[3][2]);
448 m[18] =
static_cast<float>(this->v[3][3]);
449 m[19] =
static_cast<float>(this->v[3][4]);
451 m[20] =
static_cast<float>(this->v[4][0]);
452 m[21] =
static_cast<float>(this->v[4][1]);
453 m[22] =
static_cast<float>(this->v[4][2]);
454 m[23] =
static_cast<float>(this->v[4][3]);
455 m[24] =
static_cast<float>(this->v[4][4]);
465 this->v[0][0] =
static_cast<DT
>(m[ 0]);
466 this->v[0][1] =
static_cast<DT
>(m[ 1]);
467 this->v[0][2] =
static_cast<DT
>(m[ 2]);
468 this->v[0][3] =
static_cast<DT
>(m[ 3]);
469 this->v[0][4] =
static_cast<DT
>(m[ 4]);
471 this->v[1][0] =
static_cast<DT
>(m[ 5]);
472 this->v[1][1] =
static_cast<DT
>(m[ 6]);
473 this->v[1][2] =
static_cast<DT
>(m[ 7]);
474 this->v[1][3] =
static_cast<DT
>(m[ 8]);
475 this->v[1][4] =
static_cast<DT
>(m[ 9]);
477 this->v[2][0] =
static_cast<DT
>(m[10]);
478 this->v[2][1] =
static_cast<DT
>(m[11]);
479 this->v[2][2] =
static_cast<DT
>(m[12]);
480 this->v[2][3] =
static_cast<DT
>(m[13]);
481 this->v[2][4] =
static_cast<DT
>(m[14]);
483 this->v[3][0] =
static_cast<DT
>(m[15]);
484 this->v[3][1] =
static_cast<DT
>(m[16]);
485 this->v[3][2] =
static_cast<DT
>(m[17]);
486 this->v[3][3] =
static_cast<DT
>(m[18]);
487 this->v[3][4] =
static_cast<DT
>(m[19]);
489 this->v[4][0] =
static_cast<DT
>(m[20]);
490 this->v[4][1] =
static_cast<DT
>(m[21]);
491 this->v[4][2] =
static_cast<DT
>(m[22]);
492 this->v[4][3] =
static_cast<DT
>(m[23]);
493 this->v[4][4] =
static_cast<DT
>(m[24]);
503 m[ 0] =
static_cast<double>(this->v[0][0]);
504 m[ 1] =
static_cast<double>(this->v[0][1]);
505 m[ 2] =
static_cast<double>(this->v[0][2]);
506 m[ 3] =
static_cast<double>(this->v[0][3]);
507 m[ 4] =
static_cast<double>(this->v[0][4]);
509 m[ 5] =
static_cast<double>(this->v[1][0]);
510 m[ 6] =
static_cast<double>(this->v[1][1]);
511 m[ 7] =
static_cast<double>(this->v[1][2]);
512 m[ 8] =
static_cast<double>(this->v[1][3]);
513 m[ 9] =
static_cast<double>(this->v[1][4]);
515 m[10] =
static_cast<double>(this->v[2][0]);
516 m[11] =
static_cast<double>(this->v[2][1]);
517 m[12] =
static_cast<double>(this->v[2][2]);
518 m[13] =
static_cast<double>(this->v[2][3]);
519 m[14] =
static_cast<double>(this->v[2][4]);
521 m[15] =
static_cast<double>(this->v[3][0]);
522 m[16] =
static_cast<double>(this->v[3][1]);
523 m[17] =
static_cast<double>(this->v[3][2]);
524 m[18] =
static_cast<double>(this->v[3][3]);
525 m[19] =
static_cast<double>(this->v[3][4]);
527 m[20] =
static_cast<double>(this->v[4][0]);
528 m[21] =
static_cast<double>(this->v[4][1]);
529 m[22] =
static_cast<double>(this->v[4][2]);
530 m[23] =
static_cast<double>(this->v[4][3]);
531 m[24] =
static_cast<double>(this->v[4][4]);
541 this->v[0][0] = scale; this->v[0][1] = 0; this->v[0][2] = 0; this->v[0][3] = 0; this->v[0][4] = 0;
542 this->v[1][0] = 0; this->v[1][1] = scale; this->v[1][2] = 0; this->v[1][3] = 0; this->v[1][4] = 0;
543 this->v[2][0] = 0; this->v[2][1] = 0; this->v[2][2] = scale; this->v[2][3] = 0; this->v[2][4] = 0;
544 this->v[3][0] = 0; this->v[3][1] = 0; this->v[3][2] = 0; this->v[3][3] = scale; this->v[3][4] = 0;
545 this->v[4][0] = 0; this->v[4][1] = 0; this->v[4][2] = 0; this->v[4][3] = 0; this->v[4][4] = scale;
563 return Tmat4<DT>(this->v[1][col1], this->v[1][col2], this->v[1][col3], this->v[1][col4],
564 this->v[2][col1], this->v[2][col2], this->v[2][col3], this->v[2][col4],
565 this->v[3][col1], this->v[3][col2], this->v[3][col3], this->v[3][col4],
566 this->v[4][col1], this->v[4][col2], this->v[4][col3], this->v[4][col4]).
det();
575 return ( this->v[0][0] * determinantLower4(1, 2, 3, 4)
576 - this->v[0][1] * determinantLower4(0, 2, 3, 4)
577 + this->v[0][2] * determinantLower4(0, 1, 3, 4)
578 - this->v[0][3] * determinantLower4(0, 1, 2, 4)
579 + this->v[0][4] * determinantLower4(0, 1, 2, 3));
595 static const DT Epsilon =
static_cast<DT
>(10e-13);
601 "Tmat5<DT> Tmat5<DT>::inverse(bool* isInvertible) const, matrix not invertable",
613 return Tmat5<DT>(
Tvec5<DT>(this->v[0][0], this->v[1][0], this->v[2][0], this->v[3][0], this->v[4][0]),
614 Tvec5<DT>(this->v[0][1], this->v[1][1], this->v[2][1], this->v[3][1], this->v[4][1]),
615 Tvec5<DT>(this->v[0][2], this->v[1][2], this->v[2][2], this->v[3][2], this->v[4][2]),
616 Tvec5<DT>(this->v[0][3], this->v[1][3], this->v[2][3], this->v[3][3], this->v[4][3]),
617 Tvec5<DT>(this->v[0][4], this->v[1][4], this->v[2][4], this->v[3][4], this->v[4][4]));
639 this->v[0].
apply(fct);
640 this->v[1].apply(fct);
641 this->v[2].apply(fct);
642 this->v[3].apply(fct);
643 this->v[4].apply(fct);
649#define _ML_MAT5_RC(i, j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j] + \
650a[i][3]*b[3][j] + a[i][4]*b[4][j]
657 return Tmat5<DT>(
Tvec5<DT>(
_ML_MAT5_RC(0,0),
_ML_MAT5_RC(0,1),
_ML_MAT5_RC(0,2),
_ML_MAT5_RC(0,3),
_ML_MAT5_RC(0,4)),
658 Tvec5<DT>(
_ML_MAT5_RC(1,0),
_ML_MAT5_RC(1,1),
_ML_MAT5_RC(1,2),
_ML_MAT5_RC(1,3),
_ML_MAT5_RC(1,4)),
659 Tvec5<DT>(
_ML_MAT5_RC(2,0),
_ML_MAT5_RC(2,1),
_ML_MAT5_RC(2,2),
_ML_MAT5_RC(2,3),
_ML_MAT5_RC(2,4)),
660 Tvec5<DT>(
_ML_MAT5_RC(3,0),
_ML_MAT5_RC(3,1),
_ML_MAT5_RC(3,2),
_ML_MAT5_RC(3,3),
_ML_MAT5_RC(3,4)),
675 return (a[0] == b[0]) &&
717 inline std::ostream&
operator<<(std::ostream& os,
const ML_LA_NAMESPACE::Tmat5<DT> & m)
719 return os << m[0] <<
'\n' << m[1] <<
'\n' << m[2] <<
'\n' << m[3] <<
'\n' << m[4];
726 inline std::istream&
operator>>(std::istream& is, ML_LA_NAMESPACE::Tmat5<DT> & m)
728 ML_LA_NAMESPACE::Tmat5<DT> m_tmp;
730 is >> m_tmp[0] >> m_tmp[1] >> m_tmp[2] >> m_tmp[3] >> m_tmp[4];
731 if (is){ m = m_tmp; }
Base class of all matrix classes which holds the data buffer and provides some general access methods...
VectorT v[size]
The rows constituting the matrix.
A four by four matrix class consisting of 4 row vectors.
DT det() const
Returns the determinant of *this.
A five by five matrix class of five row vectors.
Tmat5 transpose() const
Returns the transposed of this matrix.
const Tmat5< DT > & operator+=(const Tmat5< DT > &m)
Adds component wise by a Tmat5.
const Tmat5< DT > & operator/=(const DT d)
Divide by a constant. Division by zero is not handled and must be avoided by caller.
void set(const DT val)
Sets all values to val.
static Tmat5< DT > getMat(const double val)
Returns a matrix filled with values val, row by row.
static Tmat5 getIdentity()
Returns the identity matrix.
bool operator<(const Tmat5< DT > &) const
Dummy "lesser than operator" which always returns false.
Tmat5()
Builds a 5x5 matrix from 25 0 elements.
DT ComponentType
A typedef to "export" the type of components.
void setScaleMatrix(const DT scale)
Sets the diagonal matrix with scale on diagonal.
DT det() const
Returns the determinant of this matrix.
Tmat5(const float mat[25])
Constructor from 25 floats given as array mat, row by row.
Tmat5(const Tvec5< DT > &row0, const Tvec5< DT > &row1, const Tvec5< DT > &row2, const Tvec5< DT > &row3, const Tvec5< DT > &row4)
Builds a matrix of the five row vectors row0, ..., row4.
const Tmat5< DT > & operator=(const Tmat5< DT > &m)
Assigns by a Tmat5.
void setValues(const float m[25])
Copies the contents from float array m into *this.
const Tmat5< DT > & operator*=(const DT d)
Multiplies by a constant.
Tmat5< DT > inverse(bool *isInvertible=nullptr) const
Returns the inverse.
const Tmat5< DT > & apply(MLDblFuncPtr fct)
Applies the function fct to each component.
Tmat5(const double in00, const double in01, const double in02, const double in03, const double in04, const double in10, const double in11, const double in12, const double in13, const double in14, const double in20, const double in21, const double in22, const double in23, const double in24, const double in30, const double in31, const double in32, const double in33, const double in34, const double in40, const double in41, const double in42, const double in43, const double in44)
Initializes all matrix elements explicitly with scalars, filling it row by row.
Tmat5(const Tmat5< DT > &mat)
Copy constructor from the Tmat5 mat.
void getValues(double m[25]) const
Copies the contents of *this into m, where m must provide at least 25 accessible entries,...
void getValues(float m[25]) const
Copies the contents of *this into float array m.
const Tmat5< DT > & operator-=(const Tmat5< DT > &m)
Subtracts component wise by a Tmat5.
Tmat5(const DT diagValue)
Tmat5(const double mat[25])
Constructor from 25 doubles given as array mat, row by row.
void setValues(const double m[25])
Copies the contents of m into *this, where m must provide at least 25 accessible entries,...
DT determinantLower4(const int col1, const int col2, const int col3, const int col4) const
Determines the (sub)determinant of columns given by col1, col2, col3 and col4.
Forward declarations to resolve header file dependencies.
#define ML_CHECK_FLOAT_THROW(x)
#define _ML_MAT5_RC(i, j)
Internal helper macro to multiply two matrices, do not use.
double(* MLDblFuncPtr)(double)
A function pointer type to a function which returns a double and takes a double as argument.
FloatingPointVector< T, size, DataContainer > operator/(FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs)
Component wise division of lhs by specialized rhs of type MLdouble.
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Return true if yes.
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
bool operator!=(const Tmat2< DT > &a, const Tmat2< DT > &b)
a != b ? Return true if yes.
FloatingPointVector< T, size, DataContainer > operator-(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component wise subtraction of rhs from lhs.
BASE_TYPE MLInverseMatHelper(const BASE_TYPE &origMat, bool *isInvertible, const typename BASE_TYPE::ComponentType, const char *const ZeroDetErrString, const BASE_TYPE &Identity, const size_t Dim)
Computes an N dimensional inverse from given default parameters.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator "<<" for stream output of Field objects.
istream & operator>>(istream &is, ml::FloatingPointVector< T, size, DataContainer > &v)
Reads a vector from std::istream.