8 #ifndef META_OCEAN_MATH_STATIC_MATRIX_H
9 #define META_OCEAN_MATH_STATIC_MATRIX_H
32 template <
typename T,
size_t tRows,
size_t tColumns>
72 StaticMatrix(
const T* values,
const bool valuesRowAligned);
79 static inline size_t rows();
99 inline const T*
row(
const size_t index)
const;
106 inline T*
row(
const size_t index);
113 template <
size_t tIndex>
114 inline const T*
row()
const;
121 template <
size_t tIndex>
130 template <
size_t tRow,
size_t tColumn>
131 inline const T&
element()
const;
139 template <
size_t tRow,
size_t tColumn>
146 inline const T*
data()
const;
193 inline void setData(
const T* values,
const bool valuesRowAligned);
226 template <
size_t tColumns2>
235 template <
size_t tColumns2>
247 template <
size_t tColumns2>
337 template <
size_t tColumns2>
360 inline T
operator()(
const size_t row,
const size_t column)
const;
376 inline T
operator[](
const size_t index)
const;
392 template <
typename T,
size_t tRows,
size_t tColumns>
398 template <
typename T,
size_t tRows,
size_t tColumns>
401 for (
size_t n = 0; n < tRows * tColumns; ++n)
403 matrixValues[n] = value;
407 template <
typename T,
size_t tRows,
size_t tColumns>
410 ocean_assert(matrixValues);
412 memset(matrixValues, 0,
sizeof(T) * elements());
416 for (
size_t n = 0; n < elements(); ++n)
418 ocean_assert(matrixValues[n] == T());
424 for (
size_t n = 0; n < min(tRows, tColumns); ++n)
426 (*this)(n, n) = T(1);
431 template <
typename T,
size_t tRows,
size_t tColumns>
434 ocean_assert(matrixValues);
435 memcpy(matrixValues, values,
sizeof(T) * tRows * tColumns);
438 template <
typename T,
size_t tRows,
size_t tColumns>
441 setData(values, valuesRowAligned);
444 template <
typename T,
size_t tRows,
size_t tColumns>
450 template <
typename T,
size_t tRows,
size_t tColumns>
456 template <
typename T,
size_t tRows,
size_t tColumns>
459 return tRows * tColumns;
462 template <
typename T,
size_t tRows,
size_t tColumns>
465 ocean_assert(index < tRows);
466 return matrixValues + index * tColumns;
469 template <
typename T,
size_t tRows,
size_t tColumns>
472 ocean_assert(index < tRows);
473 return matrixValues + index * tColumns;
476 template <
typename T,
size_t tRows,
size_t tColumns>
477 template <
size_t tIndex>
480 static_assert(tIndex < tRows,
"Invalid row index");
481 return matrixValues + tIndex * tColumns;
484 template <
typename T,
size_t tRows,
size_t tColumns>
485 template <
size_t tIndex>
488 static_assert(tIndex < tRows,
"Invalid row index");
489 return matrixValues + tIndex * tColumns;
492 template <
typename T,
size_t tRows,
size_t tColumns>
493 template <
size_t tRow,
size_t tColumn>
496 static_assert(tRow < tRows,
"Invalid row index");
497 static_assert(tColumn < tColumns,
"Invalid row index");
499 return matrixValues[tRow * tColumns + tColumn];
502 template <
typename T,
size_t tRows,
size_t tColumns>
503 template <
size_t tRow,
size_t tColumn>
506 static_assert(tRow < tRows,
"Invalid row index");
507 static_assert(tColumn < tColumns,
"Invalid row index");
509 return matrixValues[tRow * tColumns + tColumn];
512 template <
typename T,
size_t tRows,
size_t tColumns>
518 template <
typename T,
size_t tRows,
size_t tColumns>
524 template <
typename T,
size_t tRows,
size_t tColumns>
527 for (
size_t n = 0; n < elements(); ++n)
538 template <
typename T,
size_t tRows,
size_t tColumns>
541 const T* pointer = matrixValues;
543 for (
size_t r = 0; r < tRows; ++r)
545 for (
size_t c = 0; c < tColumns; ++c)
567 template <
typename T,
size_t tRows,
size_t tColumns>
570 for (
size_t n = 0u; n < elements(); ++n)
581 template <
typename T,
size_t tRows,
size_t tColumns>
584 if constexpr (tRows != tColumns)
589 for (
size_t r = 0; r < tRows; ++r)
591 for (
size_t c = 0; c < tRows; ++c)
603 template <
typename T,
size_t tRows,
size_t tColumns>
606 for (
size_t n = 0; n < elements(); ++n)
608 matrixValues[n] = T(0);
612 template <
typename T,
size_t tRows,
size_t tColumns>
615 ocean_assert(tRows == 0 || tColumns == 0 || values);
617 if (valuesRowAligned)
619 memcpy(matrixValues, values,
sizeof(T) * tRows * tColumns);
623 for (
size_t c = 0u; c < tColumns; ++c)
625 for (
size_t r = 0u; r < tRows; ++r)
627 matrixValues[r * tColumns + c] = *values++;
633 template <
typename T,
size_t tRows,
size_t tColumns>
636 ocean_assert(isSymmetric());
640 for (
unsigned int i = 0u; i < tRows; ++i)
643 matrixR(i, i) = matrixValues[i * tColumns + i];
645 for (
unsigned int k = 0u; k < i; ++k)
647 matrixR(i, i) -= matrixR(i, k) * matrixR(i, k);
658 for (
unsigned int j = i + 1u; j < tRows; ++j)
660 matrixR(i, j) = matrixValues[i * tColumns + j];
662 for (
unsigned int k = 0u; k < i; ++k)
664 matrixR(i, j) -= matrixR(k, i) * matrixR(k, j);
669 matrixR(i, j) /= matrixR(i, i);
671 matrixR(j, i) = matrixR(i, j);
677 for (
unsigned int i = 0u; i < tRows; ++i)
679 matrixY(i, 0) = vectorB[i];
681 for (
unsigned int k = 0; k < i; ++k)
683 matrixY(i, 0) -= matrixY(k, 0) * matrixR(k, i);
688 matrixY(i, 0) /= matrixR(i, i);
692 for (
int y =
int(tRows - 1u); y >= 0; --y)
694 vectorX(y, 0) = matrixY(y, 0);
696 for (
unsigned int i = y + 1u; i < tRows; ++i)
698 vectorX(y, 0) -= vectorX(i, 0) * matrixR(i, y);
703 vectorX(y, 0) /= matrixR(y, y);
709 template <
typename T,
size_t tRows,
size_t tColumns>
713 const T* thisData = matrixValues;
715 const T*
const thisDataEnd = thisData + tRows * tColumns;
717 while (thisData != thisDataEnd)
719 ocean_assert(thisData < thisDataEnd);
720 *targetData++ += *thisData++;
724 template <
typename T,
size_t tRows,
size_t tColumns>
727 const T* data = matrixValues;
729 for (
size_t r = 0; r < tRows; ++r)
731 for (
size_t c = 0; c < tColumns; ++c)
733 target(c, r) += *data++;
738 template <
typename T,
size_t tRows,
size_t tColumns>
739 template <
size_t tColumns2>
742 multiply(matrix, target.
data());
745 template <
typename T,
size_t tRows,
size_t tColumns>
746 template <
size_t tColumns2>
749 ocean_assert(target);
751 for (
size_t r = 0; r < tRows; ++r)
753 for (
size_t c = 0; c < tColumns2; ++c)
757 for (
size_t n = 0; n < tColumns; ++n)
759 value += (*this)(r, n) * matrix(n, c);
768 template <
typename T,
size_t tRows,
size_t tColumns>
769 template <
size_t tColumns2>
772 ocean_assert(target);
774 for (
size_t r = 0; r < tRows; ++r)
776 for (
size_t c = 0; c < tColumns2; ++c)
780 for (
size_t n = 0; n < tColumns; ++n)
782 value += (*this)(r, n) * matrix(n, c);
792 template <
typename T,
size_t tRows,
size_t tColumns>
796 multiplyWithTransposedLeft(result);
801 template <
typename T,
size_t tRows,
size_t tColumns>
804 static_assert(tRows != 0 && tColumns != 0,
"Invalid matrix dimension");
807 T* target = result.
data();
809 for (
size_t r = 0; r < tColumns; ++r)
811 for (
size_t c = 0; c < tColumns; ++c)
813 intermediate = (*this)(0, r) * (*
this)(0, c);
815 for (
size_t i = 1; i < tRows; ++i)
817 intermediate += (*this)(i, r) * (*
this)(i, c);
820 *target++ = intermediate;
825 template <
typename T,
size_t tRows,
size_t tColumns>
829 multiplyWithTransposedRight(result);
834 template <
typename T,
size_t tRows,
size_t tColumns>
837 static_assert(tRows != 0 && tColumns != 0,
"Invalid matrix dimension");
840 T* target = result.
data();
842 for (
size_t r = 0; r < tRows; ++r)
844 const T*
const rowElements = matrixValues + r * tColumns;
846 for (
size_t c = 0; c < tRows; ++c)
848 const T*
const columnElements = matrixValues + c * tColumns;
850 intermediate = rowElements[0] * columnElements[0];
852 for (
size_t i = 1; i < tColumns; ++i)
854 intermediate += rowElements[i] * columnElements[i];
857 *target++ = intermediate;
862 template <
typename T,
size_t tRows,
size_t tColumns>
865 static_assert(tRows != 0 && tColumns != 0,
"Invalid matrix dimension");
868 T* target = result.
data();
870 for (
size_t r = 0; r < tColumns; ++r)
872 for (
size_t c = 0; c < tColumns; ++c)
874 intermediate = (*this)(0, r) * (*
this)(0, c);
876 for (
size_t i = 1; i < tRows; ++i)
878 intermediate += (*this)(i, r) * (*
this)(i, c);
881 *target++ += intermediate;
886 template <
typename T,
size_t tRows,
size_t tColumns>
889 static_assert(tRows != 0 && tColumns != 0,
"Invalid matrix dimension");
892 T* target = result.
data();
894 for (
size_t r = 0; r < tRows; ++r)
896 const T*
const rowElements = matrixValues + r * tColumns;
898 for (
size_t c = 0; c < tRows; ++c)
900 const T*
const columnElements = matrixValues + c * tColumns;
902 intermediate = rowElements[0] * columnElements[0];
904 for (
size_t i = 1; i < tColumns; ++i)
906 intermediate += rowElements[i] * columnElements[i];
909 *target++ += intermediate;
914 template <
typename T,
size_t tRows,
size_t tColumns>
923 template <
typename T,
size_t tRows,
size_t tColumns>
926 for (
size_t r = 0u; r < tRows; ++r)
928 for (
size_t c = 0u; c < tColumns; ++c)
930 result(c, r) = (*this)(r, c);
935 template <
typename T,
size_t tRows,
size_t tColumns>
940 const T* thisData = matrixValues;
944 const T*
const thisDataEnd = thisData + tRows * tColumns;
946 while (thisData != thisDataEnd)
948 *resultData++ = *thisData++ + *matrixData++;
954 template <
typename T,
size_t tRows,
size_t tColumns>
961 template <
typename T,
size_t tRows,
size_t tColumns>
966 const T* thisData = matrixValues;
970 const T*
const thisDataEnd = thisData + tRows * tColumns;
972 while (thisData != thisDataEnd)
974 ocean_assert(thisData < thisDataEnd);
975 *resultData++ = *thisData++ - *matrixData++;
981 template <
typename T,
size_t tRows,
size_t tColumns>
984 T* thisData = matrixValues;
987 T*
const thisDataEnd = thisData + tRows * tColumns;
989 while (thisData != thisDataEnd)
991 ocean_assert(thisData < thisDataEnd);
992 *thisData++ -= *matrixData++;
998 template <
typename T,
size_t tRows,
size_t tColumns>
999 template <
size_t tColumns2>
1002 static_assert(tRows != 0 && tColumns != 0,
"Invalid matrix dimension");
1006 for (
size_t r = 0; r < tRows; ++r)
1008 for (
size_t c = 0; c < tColumns2; ++c)
1010 T value = (*this)(r, 0) * matrix(0, c);
1012 for (
size_t n = 1; n < tColumns; ++n)
1014 value += (*this)(r, n) * matrix(n, c);
1017 result(r, c) = value;
1024 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
1026 #if defined(OCEAN_HARDWARE_AVX_VERSION) && OCEAN_HARDWARE_AVX_VERSION >= 10
1042 __m256d v = _mm256_loadu_pd(vector.
data());
1045 __m256d r0 = _mm256_loadu_pd(matrixValues + 0);
1048 r0 = _mm256_mul_pd(r0, v);
1051 __m256d r1 = _mm256_loadu_pd(matrixValues + 4);
1052 r1 = _mm256_mul_pd(r1, v);
1055 __m256d sum_interleaved_r0_r1 = _mm256_hadd_pd(r0, r1);
1057 #ifdef OCEAN_COMPILER_MSC
1058 ocean_assert(
NumericD::isEqual(sum_interleaved_r0_r1.m256d_f64[0], matrixValues[0 + 0] * vector[0] + matrixValues[0 + 1] * vector[1],
NumericD::eps() * 10));
1059 ocean_assert(
NumericD::isEqual(sum_interleaved_r0_r1.m256d_f64[1], matrixValues[4 + 0] * vector[0] + matrixValues[4 + 1] * vector[1],
NumericD::eps() * 10));
1060 ocean_assert(
NumericD::isEqual(sum_interleaved_r0_r1.m256d_f64[2], matrixValues[0 + 2] * vector[2] + matrixValues[0 + 3] * vector[3],
NumericD::eps() * 10));
1061 ocean_assert(
NumericD::isEqual(sum_interleaved_r0_r1.m256d_f64[3], matrixValues[4 + 2] * vector[2] + matrixValues[4 + 3] * vector[3],
NumericD::eps() * 10));
1065 __m256d r2 = _mm256_loadu_pd(matrixValues + 8);
1066 r2 = _mm256_mul_pd(r2, v);
1069 __m256d r3 = _mm256_loadu_pd(matrixValues + 12);
1070 r3 = _mm256_mul_pd(r3, v);
1073 __m256d sum_interleaved_r2_r3 = _mm256_hadd_pd(r2, r3);
1075 #ifdef OCEAN_COMPILER_MSC
1076 ocean_assert(
NumericD::isEqual(sum_interleaved_r2_r3.m256d_f64[0], matrixValues[ 8 + 0] * vector[0] + matrixValues[ 8 + 1] * vector[1],
NumericD::eps() * 10));
1077 ocean_assert(
NumericD::isEqual(sum_interleaved_r2_r3.m256d_f64[1], matrixValues[12 + 0] * vector[0] + matrixValues[12 + 1] * vector[1],
NumericD::eps() * 10));
1078 ocean_assert(
NumericD::isEqual(sum_interleaved_r2_r3.m256d_f64[2], matrixValues[ 8 + 2] * vector[2] + matrixValues[ 8 + 3] * vector[3],
NumericD::eps() * 10));
1079 ocean_assert(
NumericD::isEqual(sum_interleaved_r2_r3.m256d_f64[3], matrixValues[12 + 2] * vector[2] + matrixValues[12 + 3] * vector[3],
NumericD::eps() * 10));
1083 __m256d sum_first = _mm256_permute2f128_pd(sum_interleaved_r0_r1, sum_interleaved_r2_r3, 0x20);
1084 __m256d sum_second = _mm256_permute2f128_pd(sum_interleaved_r0_r1, sum_interleaved_r2_r3, 0x31);
1087 __m256d sum = _mm256_add_pd(sum_first, sum_second);
1090 _mm256_storeu_pd(result.
data(), sum);
1092 ocean_assert(
NumericD::isEqual(result[0], matrixValues[ 0] * vector[0] + matrixValues[ 1] * vector[1] + matrixValues[ 2] * vector[2] + matrixValues[ 3] * vector[3],
NumericD::eps() * 100));
1093 ocean_assert(
NumericD::isEqual(result[1], matrixValues[ 4] * vector[0] + matrixValues[ 5] * vector[1] + matrixValues[ 6] * vector[2] + matrixValues[ 7] * vector[3],
NumericD::eps() * 100));
1094 ocean_assert(
NumericD::isEqual(result[2], matrixValues[ 8] * vector[0] + matrixValues[ 9] * vector[1] + matrixValues[10] * vector[2] + matrixValues[11] * vector[3],
NumericD::eps() * 100));
1095 ocean_assert(
NumericD::isEqual(result[3], matrixValues[12] * vector[0] + matrixValues[13] * vector[1] + matrixValues[14] * vector[2] + matrixValues[15] * vector[3],
NumericD::eps() * 100));
1118 __m128d va = _mm_loadu_pd(vector.
data());
1119 __m128d vb = _mm_loadu_pd(vector.
data() + 2);
1122 __m128d r0a = _mm_loadu_pd(matrixValues + 0);
1123 __m128d r0b = _mm_loadu_pd(matrixValues + 2);
1126 r0a = _mm_mul_pd(r0a, va);
1127 r0b = _mm_mul_pd(r0b, vb);
1128 r0a = _mm_add_pd(r0a, r0b);
1131 __m128d r1a = _mm_loadu_pd(matrixValues + 4);
1132 __m128d r1b = _mm_loadu_pd(matrixValues + 6);
1135 r1a = _mm_mul_pd(r1a, va);
1136 r1b = _mm_mul_pd(r1b, vb);
1137 r1a = _mm_add_pd(r1a, r1b);
1140 __m128d result0 = _mm_hadd_pd(r0a, r1a);
1143 _mm_storeu_pd(result.
data(), result0);
1145 __m128d r2a = _mm_loadu_pd(matrixValues + 8);
1146 __m128d r2b = _mm_loadu_pd(matrixValues + 10);
1148 r2a = _mm_mul_pd(r2a, va);
1149 r2b = _mm_mul_pd(r2b, vb);
1150 r2a = _mm_add_pd(r2a, r2b);
1152 __m128d r3a = _mm_loadu_pd(matrixValues + 12);
1153 __m128d r3b = _mm_loadu_pd(matrixValues + 14);
1155 r3a = _mm_mul_pd(r3a, va);
1156 r3b = _mm_mul_pd(r3b, vb);
1157 r3a = _mm_add_pd(r3a, r3b);
1159 __m128d result1 = _mm_hadd_pd(r2a, r3a);
1161 _mm_storeu_pd(result.
data() + 2, result1);
1163 ocean_assert(
NumericD::isEqual(result[0], matrixValues[0] * vector[0] + matrixValues[1] * vector[1] + matrixValues[2] * vector[2] + matrixValues[3] * vector[3],
NumericD::eps() * 100));
1164 ocean_assert(
NumericD::isEqual(result[1], matrixValues[4] * vector[0] + matrixValues[5] * vector[1] + matrixValues[6] * vector[2] + matrixValues[7] * vector[3],
NumericD::eps() * 100));
1165 ocean_assert(
NumericD::isEqual(result[2], matrixValues[8] * vector[0] + matrixValues[9] * vector[1] + matrixValues[10] * vector[2] + matrixValues[11] * vector[3],
NumericD::eps() * 100));
1166 ocean_assert(
NumericD::isEqual(result[3], matrixValues[12] * vector[0] + matrixValues[13] * vector[1] + matrixValues[14] * vector[2] + matrixValues[15] * vector[3],
NumericD::eps() * 100));
1188 __m128 v = _mm_loadu_ps(vector.
data());
1191 __m128 r0 = _mm_loadu_ps(matrixValues + 0);
1192 __m128 r1 = _mm_loadu_ps(matrixValues + 4);
1193 __m128 r2 = _mm_loadu_ps(matrixValues + 8);
1194 __m128 r3 = _mm_loadu_ps(matrixValues + 12);
1197 r0 = _mm_dp_ps(r0, v, 0xF1);
1200 r1 = _mm_dp_ps(r1, v, 0xF2);
1201 r2 = _mm_dp_ps(r2, v, 0xF4);
1202 r3 = _mm_dp_ps(r3, v, 0xF8);
1205 __m128 result01 = _mm_or_ps(r0, r1);
1206 __m128 result23 = _mm_or_ps(r2, r3);
1207 __m128 result03 = _mm_or_ps(result01, result23);
1210 _mm_storeu_ps(result.
data(), result03);
1217 template <
typename T,
size_t tRows,
size_t tColumns>
1222 T* target = result.
data();
1223 const T* source = data();
1225 const T*
const targetEnd = target + elements();
1227 while (target != targetEnd)
1229 *target++ = *source++ * value;
1235 template <
typename T,
size_t tRows,
size_t tColumns>
1238 T* data = matrixValues;
1239 T*
const dataEnd = data + elements();
1241 while (data != dataEnd)
1249 template <
typename T,
size_t tRows,
size_t tColumns>
1252 ocean_assert(row < tRows && column < tColumns);
1253 return matrixValues[row * tColumns + column];
1256 template <
typename T,
size_t tRows,
size_t tColumns>
1259 ocean_assert(row < tRows && column < tColumns);
1260 return matrixValues[row * tColumns + column];
1263 template <
typename T,
size_t tRows,
size_t tColumns>
1266 ocean_assert(index < tRows * tColumns);
1267 return matrixValues[index];
1270 template <
typename T,
size_t tRows,
size_t tColumns>
1273 ocean_assert(index < tRows * tColumns);
1274 return matrixValues[index];
This class provides basic numeric functionalities.
Definition: Numeric.h:57
static T sqrt(const T value)
Returns the square root of a given value.
Definition: Numeric.h:1533
static constexpr T eps()
Returns a small epsilon.
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition: Numeric.h:2386
This class implements a matrix with static dimensions.
Definition: StaticMatrix.h:34
void multiplyWithTransposedRightAndAdd(StaticMatrix< T, tRows, tRows > &target) const
Multiplies this matrix (left) with the transposed matrix (right) and adds the resulting matrix to a g...
Definition: StaticMatrix.h:887
bool isNull() const
Returns whether all elements of this matrix are zero.
Definition: StaticMatrix.h:525
void multiplyWithTransposedLeftAndAdd(StaticMatrix< T, tColumns, tColumns > &target) const
Multiplies this matrix (right) with the transposed matrix (left) and adds the resulting matrix to a g...
Definition: StaticMatrix.h:863
StaticMatrix< T, tRows, tColumns > & operator-=(const StaticMatrix< T, tRows, tColumns > &matrix)
Subtracts a given matrix from this matrix.
Definition: StaticMatrix.h:982
T matrixValues[tRows *tColumns]
Matrix elements.
Definition: StaticMatrix.h:389
bool isEqual(const StaticMatrix< T, tRows, tColumns > &matrix, const T eps=NumericT< T >::eps()) const
Returns whether two matrices are almost identical up to a specified epsilon.
Definition: StaticMatrix.h:568
T Type
Definition of the matrix element type.
Definition: StaticMatrix.h:38
StaticMatrix< T, tRows, tColumns > operator+(const StaticMatrix< T, tRows, tColumns > &matrix) const
Adds a given matrix to this matrix.
Definition: StaticMatrix.h:936
StaticMatrix< T, tRows, tColumns2 > operator*(const StaticMatrix< T, tColumns, tColumns2 > &matrix) const
Multiplies this matrix with a second matrix objects and returns the result.
Definition: StaticMatrix.h:1000
StaticMatrix< T, tRows, tColumns > & operator*=(const T &value)
Multiplies this matrix with a scalar value element-wise.
Definition: StaticMatrix.h:1236
static size_t rows()
Returns the number of rows this matrix holds.
Definition: StaticMatrix.h:445
void add(StaticMatrix< T, tRows, tColumns > &target) const
Adds this matrix to a given matrix.
Definition: StaticMatrix.h:710
const T * data() const
Returns the pointer to the internal element buffer.
Definition: StaticMatrix.h:513
void toNull()
Sets the matrix to a zero matrix.
Definition: StaticMatrix.h:604
const T * row() const
Returns a pointer to a specified row.
Definition: StaticMatrix.h:478
StaticMatrix< T, tRows, tColumns > operator-(const StaticMatrix< T, tRows, tColumns > &matrix) const
Subtracts a given matrix from this matrix.
Definition: StaticMatrix.h:962
void multiply(const StaticMatrix< T, tColumns, tColumns2 > &matrix, StaticMatrix< T, tRows, tColumns2 > &result) const
Multiplies this matrix with a second matrix and assigns the results to a matrix.
Definition: StaticMatrix.h:740
void addTransposed(StaticMatrix< T, tColumns, tRows > &target) const
Adds this matrix transposed to a given matrix.
Definition: StaticMatrix.h:725
bool isSymmetric(const T eps=NumericT< T >::eps()) const
Returns whether this matrix is symmetric (and whether this matrix is a square matrix).
Definition: StaticMatrix.h:582
static size_t columns()
Returns the number of columsn this matrix holds.
Definition: StaticMatrix.h:451
StaticMatrix< T, tRows, tRows > multiplyWithTransposedRight() const
Multiplies this matrix (left) with the transposed matrix (right).
Definition: StaticMatrix.h:826
void setData(const T *values, const bool valuesRowAligned)
Sets the elements of this matrix by copying the values from a given buffer.
Definition: StaticMatrix.h:613
static size_t elements()
Returns the number of elements this matrix stores.
Definition: StaticMatrix.h:457
bool isIdentity() const
Returns whether this matrix is an identity matrix.
Definition: StaticMatrix.h:539
T operator[](const size_t index) const
Returns a specified element of this matrix object.
Definition: StaticMatrix.h:1264
bool solveCholesky(const StaticMatrix< T, tRows, 1 > &vectorB, StaticMatrix< T, tRows, 1 > &vectorX) const
Solves the given linear system by application of the cholesky distribution.
Definition: StaticMatrix.h:634
T operator()(const size_t row, const size_t column) const
Returns a specified element of this matrix object.
Definition: StaticMatrix.h:1250
StaticMatrix< T, tColumns, tColumns > multiplyWithTransposedLeft() const
Multiplies this matrix (right) with the transposed matrix (left).
Definition: StaticMatrix.h:793
StaticMatrix< T, tRows, tColumns > & operator+=(const StaticMatrix< T, tRows, tColumns > &matrix)
Adds a given matrix to this matrix.
Definition: StaticMatrix.h:955
StaticMatrix()
Creates a new matrix object without initializing the matrix elements.
Definition: StaticMatrix.h:393
const T & element() const
Returns a pointer to a specified element.
Definition: StaticMatrix.h:494
StaticMatrix< T, tColumns, tRows > transposed() const
Returns the transposed matrix of this matrix.
Definition: StaticMatrix.h:915
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15