40template <
class DT>
class Tvec5;
41template <
class DT>
class Tmat4;
166 this->v[0] = this->v[1] = this->v[2] = this->v[3] = this->v[4] =
Tvec5<DT>(0);
172 this->v[0][0] = this->v[1][1] = this->v[2][2] = this->v[3][3] = this->v[4][4] =
diagValue;
173 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] =
174 this->v[3][2] = this->v[4][2] = this->v[4][3] = 0;
175 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] =
176 this->v[2][3] = this->v[2][4] = this->v[3][4] = 0;
194 this->v[0] =
mat.
v[0];
195 this->v[1] =
mat.v[1];
196 this->v[2] =
mat.v[2];
197 this->v[3] =
mat.v[3];
198 this->v[4] =
mat.v[4];
216 return Tmat5<DT>(val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val,
217 val, val, val, val, val);
223 this->v[0] = this->v[1] = this->v[2] = this->v[3] = this->v[4] =
Tvec5<DT>(val);
243 this->v[0] +=
m.
v[0];
244 this->v[1] +=
m.v[1];
245 this->v[2] +=
m.v[2];
246 this->v[3] +=
m.v[3];
247 this->v[4] +=
m.v[4];
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];
296 return Tmat5<DT>(a) *=
static_cast<DT
>(-1.0);
351 this->v[0][0] =
static_cast<DT
>(
in00);
352 this->v[0][1] =
static_cast<DT
>(
in01);
353 this->v[0][2] =
static_cast<DT
>(
in02);
354 this->v[0][3] =
static_cast<DT
>(
in03);
355 this->v[0][4] =
static_cast<DT
>(
in04);
356 this->v[1][0] =
static_cast<DT
>(
in10);
357 this->v[1][1] =
static_cast<DT
>(
in11);
358 this->v[1][2] =
static_cast<DT
>(
in12);
359 this->v[1][3] =
static_cast<DT
>(
in13);
360 this->v[1][4] =
static_cast<DT
>(
in14);
361 this->v[2][0] =
static_cast<DT
>(
in20);
362 this->v[2][1] =
static_cast<DT
>(
in21);
363 this->v[2][2] =
static_cast<DT
>(
in22);
364 this->v[2][3] =
static_cast<DT
>(
in23);
365 this->v[2][4] =
static_cast<DT
>(
in24);
366 this->v[3][0] =
static_cast<DT
>(
in30);
367 this->v[3][1] =
static_cast<DT
>(
in31);
368 this->v[3][2] =
static_cast<DT
>(
in32);
369 this->v[3][3] =
static_cast<DT
>(
in33);
370 this->v[3][4] =
static_cast<DT
>(
in34);
371 this->v[4][0] =
static_cast<DT
>(
in40);
372 this->v[4][1] =
static_cast<DT
>(
in41);
373 this->v[4][2] =
static_cast<DT
>(
in42);
374 this->v[4][3] =
static_cast<DT
>(
in43);
375 this->v[4][4] =
static_cast<DT
>(
in44);
385 this->v[0][0] =
static_cast<DT
>(
m[0]);
386 this->v[0][1] =
static_cast<DT
>(
m[1]);
387 this->v[0][2] =
static_cast<DT
>(
m[2]);
388 this->v[0][3] =
static_cast<DT
>(
m[3]);
389 this->v[0][4] =
static_cast<DT
>(
m[4]);
391 this->v[1][0] =
static_cast<DT
>(
m[5]);
392 this->v[1][1] =
static_cast<DT
>(
m[6]);
393 this->v[1][2] =
static_cast<DT
>(
m[7]);
394 this->v[1][3] =
static_cast<DT
>(
m[8]);
395 this->v[1][4] =
static_cast<DT
>(
m[9]);
397 this->v[2][0] =
static_cast<DT
>(
m[10]);
398 this->v[2][1] =
static_cast<DT
>(
m[11]);
399 this->v[2][2] =
static_cast<DT
>(
m[12]);
400 this->v[2][3] =
static_cast<DT
>(
m[13]);
401 this->v[2][4] =
static_cast<DT
>(
m[14]);
403 this->v[3][0] =
static_cast<DT
>(
m[15]);
404 this->v[3][1] =
static_cast<DT
>(
m[16]);
405 this->v[3][2] =
static_cast<DT
>(
m[17]);
406 this->v[3][3] =
static_cast<DT
>(
m[18]);
407 this->v[3][4] =
static_cast<DT
>(
m[19]);
409 this->v[4][0] =
static_cast<DT
>(
m[20]);
410 this->v[4][1] =
static_cast<DT
>(
m[21]);
411 this->v[4][2] =
static_cast<DT
>(
m[22]);
412 this->v[4][3] =
static_cast<DT
>(
m[23]);
413 this->v[4][4] =
static_cast<DT
>(
m[24]);
424 m[0] =
static_cast<float>(this->v[0][0]);
425 m[1] =
static_cast<float>(this->v[0][1]);
426 m[2] =
static_cast<float>(this->v[0][2]);
427 m[3] =
static_cast<float>(this->v[0][3]);
428 m[4] =
static_cast<float>(this->v[0][4]);
430 m[5] =
static_cast<float>(this->v[1][0]);
431 m[6] =
static_cast<float>(this->v[1][1]);
432 m[7] =
static_cast<float>(this->v[1][2]);
433 m[8] =
static_cast<float>(this->v[1][3]);
434 m[9] =
static_cast<float>(this->v[1][4]);
436 m[10] =
static_cast<float>(this->v[2][0]);
437 m[11] =
static_cast<float>(this->v[2][1]);
438 m[12] =
static_cast<float>(this->v[2][2]);
439 m[13] =
static_cast<float>(this->v[2][3]);
440 m[14] =
static_cast<float>(this->v[2][4]);
442 m[15] =
static_cast<float>(this->v[3][0]);
443 m[16] =
static_cast<float>(this->v[3][1]);
444 m[17] =
static_cast<float>(this->v[3][2]);
445 m[18] =
static_cast<float>(this->v[3][3]);
446 m[19] =
static_cast<float>(this->v[3][4]);
448 m[20] =
static_cast<float>(this->v[4][0]);
449 m[21] =
static_cast<float>(this->v[4][1]);
450 m[22] =
static_cast<float>(this->v[4][2]);
451 m[23] =
static_cast<float>(this->v[4][3]);
452 m[24] =
static_cast<float>(this->v[4][4]);
461 this->v[0][0] =
static_cast<DT
>(
m[0]);
462 this->v[0][1] =
static_cast<DT
>(
m[1]);
463 this->v[0][2] =
static_cast<DT
>(
m[2]);
464 this->v[0][3] =
static_cast<DT
>(
m[3]);
465 this->v[0][4] =
static_cast<DT
>(
m[4]);
467 this->v[1][0] =
static_cast<DT
>(
m[5]);
468 this->v[1][1] =
static_cast<DT
>(
m[6]);
469 this->v[1][2] =
static_cast<DT
>(
m[7]);
470 this->v[1][3] =
static_cast<DT
>(
m[8]);
471 this->v[1][4] =
static_cast<DT
>(
m[9]);
473 this->v[2][0] =
static_cast<DT
>(
m[10]);
474 this->v[2][1] =
static_cast<DT
>(
m[11]);
475 this->v[2][2] =
static_cast<DT
>(
m[12]);
476 this->v[2][3] =
static_cast<DT
>(
m[13]);
477 this->v[2][4] =
static_cast<DT
>(
m[14]);
479 this->v[3][0] =
static_cast<DT
>(
m[15]);
480 this->v[3][1] =
static_cast<DT
>(
m[16]);
481 this->v[3][2] =
static_cast<DT
>(
m[17]);
482 this->v[3][3] =
static_cast<DT
>(
m[18]);
483 this->v[3][4] =
static_cast<DT
>(
m[19]);
485 this->v[4][0] =
static_cast<DT
>(
m[20]);
486 this->v[4][1] =
static_cast<DT
>(
m[21]);
487 this->v[4][2] =
static_cast<DT
>(
m[22]);
488 this->v[4][3] =
static_cast<DT
>(
m[23]);
489 this->v[4][4] =
static_cast<DT
>(
m[24]);
498 m[0] =
static_cast<double>(this->v[0][0]);
499 m[1] =
static_cast<double>(this->v[0][1]);
500 m[2] =
static_cast<double>(this->v[0][2]);
501 m[3] =
static_cast<double>(this->v[0][3]);
502 m[4] =
static_cast<double>(this->v[0][4]);
504 m[5] =
static_cast<double>(this->v[1][0]);
505 m[6] =
static_cast<double>(this->v[1][1]);
506 m[7] =
static_cast<double>(this->v[1][2]);
507 m[8] =
static_cast<double>(this->v[1][3]);
508 m[9] =
static_cast<double>(this->v[1][4]);
510 m[10] =
static_cast<double>(this->v[2][0]);
511 m[11] =
static_cast<double>(this->v[2][1]);
512 m[12] =
static_cast<double>(this->v[2][2]);
513 m[13] =
static_cast<double>(this->v[2][3]);
514 m[14] =
static_cast<double>(this->v[2][4]);
516 m[15] =
static_cast<double>(this->v[3][0]);
517 m[16] =
static_cast<double>(this->v[3][1]);
518 m[17] =
static_cast<double>(this->v[3][2]);
519 m[18] =
static_cast<double>(this->v[3][3]);
520 m[19] =
static_cast<double>(this->v[3][4]);
522 m[20] =
static_cast<double>(this->v[4][0]);
523 m[21] =
static_cast<double>(this->v[4][1]);
524 m[22] =
static_cast<double>(this->v[4][2]);
525 m[23] =
static_cast<double>(this->v[4][3]);
526 m[24] =
static_cast<double>(this->v[4][4]);
535 this->v[0][0] = scale;
541 this->v[1][1] = scale;
547 this->v[2][2] = scale;
553 this->v[3][3] = scale;
559 this->v[4][4] = scale;
587 return (this->v[0][0] * determinantLower4(1, 2, 3, 4) - this->v[0][1] * determinantLower4(0, 2, 3, 4) +
588 this->v[0][2] * determinantLower4(0, 1, 3, 4) - this->v[0][3] * determinantLower4(0, 1, 2, 4) +
589 this->v[0][4] * determinantLower4(0, 1, 2, 3));
604 static const DT
Epsilon =
static_cast<DT
>(10e-13);
608 "Tmat5<DT> Tmat5<DT>::inverse(bool* isInvertible) const, matrix not invertable",
618 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]),
619 Tvec5<DT>(this->v[0][1], this->v[1][1], this->v[2][1], this->v[3][1], this->v[4][1]),
620 Tvec5<DT>(this->v[0][2], this->v[1][2], this->v[2][2], this->v[3][2], this->v[4][2]),
621 Tvec5<DT>(this->v[0][3], this->v[1][3], this->v[2][3], this->v[3][3], this->v[4][3]),
622 Tvec5<DT>(this->v[0][4], this->v[1][4], this->v[2][4], this->v[3][4], this->v[4][4]));
630 return Tmat5<DT>(
Tvec5<DT>(1, 0, 0, 0, 0),
Tvec5<DT>(0, 1, 0, 0, 0),
Tvec5<DT>(0, 0, 1, 0, 0),
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) \
650 a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j] + a[i][3] * b[3][j] + a[i][4] * b[4][j]
657 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)),
674 return (a[0] == b[0]) && (a[1] == b[1]) && (a[2] == b[2]) && (a[3] == b[3]) && (a[4] == b[4]);
710 template <
class DT>
inline std::ostream&
operator<<(std::ostream&
os,
const ML_LA_NAMESPACE::Tmat5<DT>&
m)
712 return os <<
m[0] <<
'\n' <<
m[1] <<
'\n' <<
m[2] <<
'\n' <<
m[3] <<
'\n' <<
m[4];
718 template <
class DT>
inline std::istream&
operator>>(std::istream& is, ML_LA_NAMESPACE::Tmat5<DT>&
m)
720 ML_LA_NAMESPACE::Tmat5<DT>
m_tmp;
Base class of all matrix classes that holds the data buffer and provides some general access methods.
VectorT v[size]
The rows constituting the matrix.
A 5x5 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)
Divides by a scalar constant d.
void set(const DT val)
Sets all values to val.
static Tmat5< DT > getMat(const double val)
Returns a matrix filled with values val.
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 zero elements.
DT ComponentType
A typedef to 'export' the type of components.
void setScaleMatrix(const DT scale)
Sets the diagonal matrix with scale on the diagonal.
DT det() const
Determinant.
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 the matrix of the five row vectors row0, ..., row5.
const Tmat5< DT > & operator=(const Tmat5< DT > &m)
Assigns from 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 scalar constant d.
Tmat5< DT > inverse(bool *isInvertible=nullptr) const
Returns the inverse Gauss-Jordan elimination with partial pivoting.
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 double array m.
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)
Builds a matrix that has the argument diagValue as the diagonal values, zero otherwise.
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 from double array m into *this.
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.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
double(* MLDblFuncPtr)(double)
A function pointer type to a function that 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 ? Returns 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 ? Returns 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.