8#ifndef META_OCEAN_MATH_SQUARE_MATRIX_4_H
9#define META_OCEAN_MATH_SQUARE_MATRIX_4_H
23template <
typename T>
class AnyCameraT;
26template <
typename T>
class HomogenousMatrixT4;
29template <
typename T>
class SquareMatrixT3;
32template <
typename T>
class SquareMatrixT4;
114 template <
typename U>
128 template <
typename U>
143 template <
typename U>
292 template <
typename U>
437 inline T
operator()(
const unsigned int row,
const unsigned int column)
const;
446 inline T&
operator()(
const unsigned int row,
const unsigned int column);
551 template <
typename U>
561 template <
typename U>
571 void swapRows(
const unsigned int row0,
const unsigned int row1);
586 void addRows(
const unsigned int targetRow,
const unsigned int sourceRow,
const T scalar);
604 for (
unsigned int n = 0u; n < 16u; ++n)
606 values[n] = T(matrix.
values[n]);
627 ocean_assert(arrayValues);
629 for (
unsigned int n = 0u; n < 16u; ++n)
631 values[n] = T(arrayValues[n]);
638 ocean_assert(arrayValues);
639 memcpy(values, arrayValues,
sizeof(T) * 16);
646 ocean_assert(arrayValues);
648 if (valuesRowAligned)
650 values[ 0] = T(arrayValues[ 0]);
651 values[ 1] = T(arrayValues[ 4]);
652 values[ 2] = T(arrayValues[ 8]);
653 values[ 3] = T(arrayValues[12]);
654 values[ 4] = T(arrayValues[ 1]);
655 values[ 5] = T(arrayValues[ 5]);
656 values[ 6] = T(arrayValues[ 9]);
657 values[ 7] = T(arrayValues[13]);
658 values[ 8] = T(arrayValues[ 2]);
659 values[ 9] = T(arrayValues[ 6]);
660 values[10] = T(arrayValues[10]);
661 values[11] = T(arrayValues[14]);
662 values[12] = T(arrayValues[ 3]);
663 values[13] = T(arrayValues[ 7]);
664 values[14] = T(arrayValues[11]);
665 values[15] = T(arrayValues[15]);
669 for (
unsigned int n = 0u; n < 16u; ++n)
671 values[n] = T(arrayValues[n]);
679 ocean_assert(arrayValues);
681 if (valuesRowAligned)
683 values[ 0] = arrayValues[ 0];
684 values[ 1] = arrayValues[ 4];
685 values[ 2] = arrayValues[ 8];
686 values[ 3] = arrayValues[12];
687 values[ 4] = arrayValues[ 1];
688 values[ 5] = arrayValues[ 5];
689 values[ 6] = arrayValues[ 9];
690 values[ 7] = arrayValues[13];
691 values[ 8] = arrayValues[ 2];
692 values[ 9] = arrayValues[ 6];
693 values[10] = arrayValues[10];
694 values[11] = arrayValues[14];
695 values[12] = arrayValues[ 3];
696 values[13] = arrayValues[ 7];
697 values[14] = arrayValues[11];
698 values[15] = arrayValues[15];
702 memcpy(values, arrayValues,
sizeof(T) * 16);
709 memcpy(values, transformation(),
sizeof(T) * 16);
723 memcpy(values, subMatrix(),
sizeof(T) * 3);
724 memcpy(values + 4, subMatrix() + 3,
sizeof(T) * 3);
725 memcpy(values + 8, subMatrix() + 6,
sizeof(T) * 3);
731 values[ 0] = diagonal[0];
736 values[ 5] = diagonal[1];
741 values[10] = diagonal[2];
746 values[15] = diagonal[3];
766 result.
values[1] = values[4];
767 result.
values[4] = values[1];
769 result.
values[2] = values[8];
770 result.
values[8] = values[2];
772 result.
values[3] = values[12];
773 result.
values[12] = values[3];
775 result.
values[6] = values[9];
776 result.
values[9] = values[6];
778 result.
values[7] = values[13];
779 result.
values[13] = values[7];
781 result.
values[11] = values[14];
782 result.
values[14] = values[11];
792 values[4] = tmp.
values[1];
793 values[1] = tmp.
values[4];
795 values[8] = tmp.
values[2];
796 values[2] = tmp.
values[8];
798 values[12] = tmp.
values[3];
799 values[3] = tmp.
values[12];
801 values[9] = tmp.
values[6];
802 values[6] = tmp.
values[9];
804 values[13] = tmp.
values[7];
805 values[7] = tmp.
values[13];
807 values[14] = tmp.
values[11];
808 values[11] = tmp.
values[14];
816 if (!invert(invertedMatrix))
818 ocean_assert(
false &&
"Could not invert matrix.");
822 return invertedMatrix;
830 if (!invert(invertedMatrix))
835 *
this = invertedMatrix;
848 for (
unsigned int col = 0; col < 4u; ++col)
853 unsigned int selectedRow = 0u;
855 for (
unsigned int row = col; row < 4u; ++row)
858 if (absolute < value)
873 if (selectedRow != col)
876 invertedMatrix.
swapRows(col, selectedRow);
882 const T divisor = T(1.0) / source(col, col);
883 ocean_assert(divisor != T(0.0));
890 for (
unsigned int row = 0; row < 4u; ++row)
894 const T value = -source(row, col);
896 source.
addRows(row, col, value);
897 invertedMatrix.
addRows(row, col, value);
908 const T v6_15 = values[6] * values[15];
909 const T v10_15 = values[10] * values[15];
910 const T v11_14 = values[11] * values[14];
911 const T v7_10 = values[7] * values[10];
912 const T v9_14 = values[9] * values[14];
913 const T v6_13 = values[6] * values[13];
914 const T v2_13 = values[2] * values[13];
915 const T v2_9 = values[2] * values[9];
916 const T v3_10 = values[3] * values[10];
917 const T v2_5 = values[2] * values[5];
919 return values[0] * (values[5] * v10_15 - values[13] * v7_10
920 + v9_14 * values[7] - values[5] * v11_14
921 + v6_13 * values[11] - values[9] * v6_15)
922 - values[4] * (v9_14 * values[3] - values[1] * v11_14
923 + v2_13 * values[11] - v2_9 * values[15]
924 + values[1] * v10_15 - values[13] * v3_10)
925 + values[8] * (values[1] * v6_15 - v6_13 * values[3]
926 + values[5] * values[14] * values[3] - values[1] * values[14] * values[7]
927 + v2_13 * values[7] - v2_5 * values[15])
928 - values[12] * (values[1] * values[6] * values[11] - values[9] * values[6] * values[3]
929 + values[5] * v3_10 - values[1] * v7_10
930 + v2_9 * values[7] - v2_5 * values[11]);
936 return values[0] + values[5] + values[10] + values[15];
963 for (
unsigned int n = 0u; n < 16u; ++n)
996 ocean_assert(epsilon >= T(0));
1002template <
typename T>
1015template <
typename T>
1018 ocean_assert(eigenValues !=
nullptr && eigenVectors !=
nullptr);
1045 const T a = values[0];
1046 const T b = values[1];
1047 const T c = values[2];
1048 const T d = values[3];
1049 const T e = values[4];
1050 const T f = values[5];
1051 const T g = values[6];
1052 const T h = values[7];
1053 const T i = values[8];
1054 const T j = values[9];
1055 const T k = values[10];
1056 const T l = values[11];
1057 const T m = values[12];
1058 const T n = values[13];
1059 const T o = values[14];
1060 const T p = values[15];
1063 const T a2 = -a - f - k - p;
1064 const T a3 = -b * e + a * f - c * i - g * j + a * k + f * k - d * m - h * n - l * o + a * p + f * p + k * p;
1065 const T a4 = c * f * i - b * g * i - c * e * j + a * g * j + b * e * k - a * f * k + d * f * m - b * h * m
1066 + d * k * m - c * l * m - d * e * n + a * h * n + h * k * n - g * l * n - d * i * o - h * j * o
1067 + a * l * o + f * l * o + b * e * p - a * f * p + c * i * p + g * j * p - a * k * p - f * k * p;
1068 const T a5 = d * g * j * m - c * h * j * m - d * f * k * m + b * h * k * m + c * f * l * m - b * g * l * m
1069 - d * g * i * n + c * h * i * n + d * e * k * n - a * h * k * n - c * e * l * n + a * g * l * n
1070 + d * f * i * o - b * h * i * o - d * e * j * o + a * h * j * o + b * e * l * o - a * f * l * o
1071 - c * f * i * p + b * g * i * p + c * e * j * p - a * g * j * p - b * e * k * p + a * f * k * p;
1078 if (solutions != 4u)
1083 for (
unsigned int iEigen = 0u; iEigen < solutions && iEigen < 4u; ++iEigen)
1085 eigenValues[iEigen] = T(x[iEigen]);
1088 for (
unsigned int iEigen = solutions; iEigen < 4u; ++iEigen)
1090 eigenValues[iEigen] = T(0);
1105 for (
unsigned int nSolution = 0u; nSolution < solutions; ++nSolution)
1107 const T lambda = eigenValues[nSolution];
1123 for (
unsigned int freeIndex = 0u; freeIndex < 4u; ++freeIndex)
1127 candidate[freeIndex] = T(1);
1131 unsigned int rowIndices[4] = {0, 1, 2, 3};
1134 for (
unsigned int rowNum = 0u; rowNum < 4u; ++rowNum)
1140 for (
unsigned int row = 0u; row < 3u; ++row)
1142 for (
unsigned int row2 = row + 1u; row2 < 4u; ++row2)
1144 if (rowScores[row2] > rowScores[row])
1146 std::swap(rowScores[row], rowScores[row2]);
1147 std::swap(rowIndices[row], rowIndices[row2]);
1154 T coeffMatrix[3][3];
1156 unsigned int unknownIndices[3];
1157 unsigned int idx = 0u;
1159 for (
unsigned int col = 0u; col < 4u; ++col)
1161 if (col != freeIndex)
1163 unknownIndices[idx++] = col;
1167 for (
unsigned int rowIdx = 0u; rowIdx < 3u; ++rowIdx)
1169 const VectorT4<T>& row = rows[rowIndices[rowIdx]];
1170 rhs[rowIdx] = -row[freeIndex];
1172 for (
unsigned int colIdx = 0u; colIdx < 3u; ++colIdx)
1174 coeffMatrix[rowIdx][colIdx] = row[unknownIndices[colIdx]];
1182 for (
unsigned int rowIdx = 0u; rowIdx < 3u; ++rowIdx)
1185 for (
unsigned int colIdx = 0u; colIdx < 3u; ++colIdx)
1187 augmented[rowIdx][colIdx] = coeffMatrix[rowIdx][colIdx];
1189 augmented[rowIdx][3] = rhs[rowIdx];
1193 for (
unsigned int colIdx = 0u; colIdx < 4u; ++colIdx)
1195 maxRowVal = std::max(maxRowVal,
NumericT<T>::abs(augmented[rowIdx][colIdx]));
1198 rowScales[rowIdx] = maxRowVal;
1203 const T scale = T(1) / maxRowVal;
1204 for (
unsigned int colIdx = 0u; colIdx < 4u; ++colIdx)
1206 augmented[rowIdx][colIdx] *= scale;
1212 for (
unsigned int pivot = 0u; pivot < 3u; ++pivot)
1215 unsigned int maxRow = pivot;
1218 for (
unsigned int rowIdx = pivot + 1u; rowIdx < 3u; ++rowIdx)
1229 if (maxRow != pivot)
1231 for (
unsigned int colIdx = 0u; colIdx < 4u; ++colIdx)
1233 std::swap(augmented[pivot][colIdx], augmented[maxRow][colIdx]);
1247 for (
unsigned int rowIdx = pivot + 1u; rowIdx < 3u; ++rowIdx)
1249 const T factor = augmented[rowIdx][pivot] / augmented[pivot][pivot];
1250 for (
unsigned int colIdx = pivot; colIdx < 4u; ++colIdx)
1252 augmented[rowIdx][colIdx] -= factor * augmented[pivot][colIdx];
1258 T solution[3] = {T(0), T(0), T(0)};
1260 for (
int rowIdx = 2; rowIdx >= 0; --rowIdx)
1262 T sum = augmented[rowIdx][3];
1264 for (
unsigned int colIdx = rowIdx + 1u; colIdx < 3u; ++colIdx)
1266 sum -= augmented[rowIdx][colIdx] * solution[colIdx];
1272 solution[rowIdx] = sum / augmented[rowIdx][rowIdx];
1278 for (
unsigned int idx2 = 0u; idx2 < 3u; ++idx2)
1280 candidate[unknownIndices[idx2]] = solution[idx2];
1286 const T residual = (Av - lambdaV).length();
1288 if (residual < bestResidual)
1290 bestResidual = residual;
1291 eigenvector = candidate;
1299 eigenvector =
VectorT4<T>(T(0), T(0), T(0), T(0));
1300 eigenvector[nSolution % 4u] = T(1);
1303 eigenVectors[nSolution] = eigenvector;
1309template <
typename T>
1310template <
typename U>
1313 ocean_assert(arrayValues !=
nullptr);
1315 for (
unsigned int n = 0u; n < 16u; ++n)
1317 arrayValues[n] = U(values[n]);
1321template <
typename T>
1324 ocean_assert(arrayValues !=
nullptr);
1326 memcpy(arrayValues, values,
sizeof(T) * 16);
1329template <
typename T>
1332 return !(*
this == matrix);
1335template <
typename T>
1338 *
this = *
this * matrix;
1342template <
typename T>
1345 *
this = *
this * matrix;
1349template <
typename T>
1352 ocean_assert(index < 16u);
1353 return values[index];
1356template <
typename T>
1359 ocean_assert(index < 16u);
1360 return values[index];
1363template <
typename T>
1366 ocean_assert(row < 4u && column < 4u);
1367 return values[(column << 2) + row];
1370template <
typename T>
1373 ocean_assert(row < 4u && column < 4u);
1374 return values[(column << 2) + row];
1377template <
typename T>
1380 ocean_assert(index < 16u);
1381 return values[index];
1384template <
typename T>
1387 ocean_assert(index < 16u);
1388 return values[index];
1391template <
typename T>
1397template <
typename T>
1403template <
typename T>
1406 size_t seed = std::hash<T>{}(matrix.
values[0]);
1408 for (
unsigned int n = 1u; n < 16u; ++n)
1410 seed ^= std::hash<T>{}(matrix.
values[n]) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
1416template <
typename T>
1422template <
typename T>
1425 return isEqual(matrix);
1428template <
typename T>
1438template <
typename T>
1441 for (
unsigned int n = 0u; n < 16u; ++n)
1443 values[n] += matrix.
values[n];
1449template <
typename T>
1459template <
typename T>
1462 for (
unsigned int n = 0u; n < 16u; ++n)
1464 values[n] -= matrix.
values[n];
1470template <
typename T>
1475 for (
unsigned int n = 0u; n < 16u; ++n)
1477 result.
values[n] = -values[n];
1483template <
typename T>
1500 result.
values[10] = values[2] * matrix.
values[8] + values[6] * matrix.
values[9] + values[10] * matrix.
values[10] + values[14] * matrix.
values[11];
1501 result.
values[11] = values[3] * matrix.
values[8] + values[7] * matrix.
values[9] + values[11] * matrix.
values[10] + values[15] * matrix.
values[11];
1503 result.
values[12] = values[0] * matrix.
values[12] + values[4] * matrix.
values[13] + values[8] * matrix.
values[14] + values[12] * matrix.
values[15];
1504 result.
values[13] = values[1] * matrix.
values[12] + values[5] * matrix.
values[13] + values[9] * matrix.
values[14] + values[13] * matrix.
values[15];
1505 result.
values[14] = values[2] * matrix.
values[12] + values[6] * matrix.
values[13] + values[10] * matrix.
values[14] + values[14] * matrix.
values[15];
1506 result.
values[15] = values[3] * matrix.
values[12] + values[7] * matrix.
values[13] + values[11] * matrix.
values[14] + values[15] * matrix.
values[15];
1511#if defined(OCEAN_HARDWARE_AVX_VERSION) && OCEAN_HARDWARE_AVX_VERSION >= 10
1529 __m256d c0 = _mm256_loadu_pd(values + 0);
1530 __m256d c1 = _mm256_loadu_pd(values + 4);
1531 __m256d c2 = _mm256_loadu_pd(values + 8);
1532 __m256d c3 = _mm256_loadu_pd(values + 12);
1536 __m256d v0 = _mm256_broadcast_sd(matrix.
data() + 0);
1537 __m256d r0 = _mm256_mul_pd(c0, v0);
1539 __m256d v1 = _mm256_broadcast_sd(matrix.
data() + 1);
1540 __m256d r1 = _mm256_mul_pd(c1, v1);
1542 r0 = _mm256_add_pd(r0, r1);
1544 __m256d v2 = _mm256_broadcast_sd(matrix.
data() + 2);
1545 __m256d r2 = _mm256_mul_pd(c2, v2);
1547 r0 = _mm256_add_pd(r0, r2);
1549 __m256d v3 = _mm256_broadcast_sd(matrix.
data() + 3);
1550 __m256d r3 = _mm256_mul_pd(c3, v3);
1552 r0 = _mm256_add_pd(r0, r3);
1556 _mm256_storeu_pd(result.
data(), r0);
1560 __m256d v4 = _mm256_broadcast_sd(matrix.
data() + 4);
1561 __m256d r4 = _mm256_mul_pd(c0, v4);
1563 __m256d v5 = _mm256_broadcast_sd(matrix.
data() + 5);
1564 __m256d r5 = _mm256_mul_pd(c1, v5);
1566 r4 = _mm256_add_pd(r4, r5);
1568 __m256d v6 = _mm256_broadcast_sd(matrix.
data() + 6);
1569 __m256d r6 = _mm256_mul_pd(c2, v6);
1571 r4 = _mm256_add_pd(r4, r6);
1573 __m256d v7 = _mm256_broadcast_sd(matrix.
data() + 7);
1574 __m256d r7 = _mm256_mul_pd(c3, v7);
1576 r4 = _mm256_add_pd(r4, r7);
1578 _mm256_storeu_pd(result.
data() + 4, r4);
1582 __m256d v8 = _mm256_broadcast_sd(matrix.
data() + 8);
1583 __m256d r8 = _mm256_mul_pd(c0, v8);
1585 __m256d v9 = _mm256_broadcast_sd(matrix.
data() + 9);
1586 __m256d r9 = _mm256_mul_pd(c1, v9);
1588 r8 = _mm256_add_pd(r8, r9);
1590 __m256d v10 = _mm256_broadcast_sd(matrix.
data() + 10);
1591 __m256d r10 = _mm256_mul_pd(c2, v10);
1593 r8 = _mm256_add_pd(r8, r10);
1595 __m256d v11 = _mm256_broadcast_sd(matrix.
data() + 11);
1596 __m256d r11 = _mm256_mul_pd(c3, v11);
1598 r8 = _mm256_add_pd(r8, r11);
1600 _mm256_storeu_pd(result.
data() + 8, r8);
1604 __m256d v12 = _mm256_broadcast_sd(matrix.
data() + 12);
1605 __m256d r12 = _mm256_mul_pd(c0, v12);
1607 __m256d v13 = _mm256_broadcast_sd(matrix.
data() + 13);
1608 __m256d r13 = _mm256_mul_pd(c1, v13);
1610 r12 = _mm256_add_pd(r12, r13);
1612 __m256d v14 = _mm256_broadcast_sd(matrix.
data() + 14);
1613 __m256d r14 = _mm256_mul_pd(c2, v14);
1615 r12 = _mm256_add_pd(r12, r14);
1617 __m256d v15 = _mm256_broadcast_sd(matrix.
data() + 15);
1618 __m256d r15 = _mm256_mul_pd(c3, v15);
1620 r12 = _mm256_add_pd(r12, r15);
1622 _mm256_storeu_pd(result.
data() + 12, r12);
1636 __m256 c0 = _mm256_broadcast_ps((
const __m128*)values + 0);
1637 __m256 c1 = _mm256_broadcast_ps((
const __m128*)values + 1);
1638 __m256 c2 = _mm256_broadcast_ps((
const __m128*)values + 2);
1639 __m256 c3 = _mm256_broadcast_ps((
const __m128*)values + 3);
1641 __m256 m01 = _mm256_loadu_ps(matrix.
data() + 0);
1642 __m256 m23 = _mm256_loadu_ps(matrix.
data() + 8);
1646 __m256 v0_4 = _mm256_permute_ps(m01, 0x00);
1647 __m256 r0 = _mm256_mul_ps(c0, v0_4);
1649#ifdef OCEAN_COMPILER_MSC
1661 __m256 v1_5 = _mm256_permute_ps(m01, 0x55);
1662 __m256 r1 = _mm256_mul_ps(c1, v1_5);
1664#ifdef OCEAN_COMPILER_MSC
1676 r0 = _mm256_add_ps(r0, r1);
1679 __m256 v2_6 = _mm256_permute_ps(m01, 0xAA);
1680 __m256 r2 = _mm256_mul_ps(c2, v2_6);
1682 r0 = _mm256_add_ps(r0, r2);
1685 __m256 v3_7 = _mm256_permute_ps(m01, 0xFF);
1686 __m256 r3 = _mm256_mul_ps(c3, v3_7);
1688 r0 = _mm256_add_ps(r0, r3);
1692 _mm256_storeu_ps(result.
data(), r0);
1697 __m256 v8_12 = _mm256_permute_ps(m23, 0x00);
1698 __m256 r8 = _mm256_mul_ps(c0, v8_12);
1701 __m256 v9_13 = _mm256_permute_ps(m23, 0x55);
1702 __m256 r9 = _mm256_mul_ps(c1, v9_13);
1704 r8 = _mm256_add_ps(r8, r9);
1707 __m256 v10_14 = _mm256_permute_ps(m23, 0xAA);
1708 __m256 r10 = _mm256_mul_ps(c2, v10_14);
1710 r8 = _mm256_add_ps(r8, r10);
1713 __m256 v11_15 = _mm256_permute_ps(m23, 0xFF);
1714 __m256 r11 = _mm256_mul_ps(c3, v11_15);
1716 r8 = _mm256_add_ps(r8, r11);
1718 _mm256_storeu_ps(result.
data() + 8, r8);
1725#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 10
1743 __m128 c0 = _mm_loadu_ps(values + 0);
1744 __m128 c1 = _mm_loadu_ps(values + 4);
1745 __m128 c2 = _mm_loadu_ps(values + 8);
1746 __m128 c3 = _mm_loadu_ps(values + 12);
1750 __m128 v0 = _mm_load1_ps(matrix.
data() + 0);
1751 __m128 r0 = _mm_mul_ps(c0, v0);
1753 __m128 v1 = _mm_load1_ps(matrix.
data() + 1);
1754 __m128 r1 = _mm_mul_ps(c1, v1);
1756 r0 = _mm_add_ps(r0, r1);
1758 __m128 v2 = _mm_load1_ps(matrix.
data() + 2);
1759 __m128 r2 = _mm_mul_ps(c2, v2);
1761 r0 = _mm_add_ps(r0, r2);
1763 __m128 v3 = _mm_load1_ps(matrix.
data() + 3);
1764 __m128 r3 = _mm_mul_ps(c3, v3);
1766 r0 = _mm_add_ps(r0, r3);
1770 _mm_storeu_ps(result.
data(), r0);
1774 __m128 v4 = _mm_load1_ps(matrix.
data() + 4);
1775 __m128 r4 = _mm_mul_ps(c0, v4);
1777 __m128 v5 = _mm_load1_ps(matrix.
data() + 5);
1778 __m128 r5 = _mm_mul_ps(c1, v5);
1780 r4 = _mm_add_ps(r4, r5);
1782 __m128 v6 = _mm_load1_ps(matrix.
data() + 6);
1783 __m128 r6 = _mm_mul_ps(c2, v6);
1785 r4 = _mm_add_ps(r4, r6);
1787 __m128 v7 = _mm_load1_ps(matrix.
data() + 7);
1788 __m128 r7 = _mm_mul_ps(c3, v7);
1790 r4 = _mm_add_ps(r4, r7);
1792 _mm_storeu_ps(result.
data() + 4, r4);
1796 __m128 v8 = _mm_load1_ps(matrix.
data() + 8);
1797 __m128 r8 = _mm_mul_ps(c0, v8);
1799 __m128 v9 = _mm_load1_ps(matrix.
data() + 9);
1800 __m128 r9 = _mm_mul_ps(c1, v9);
1802 r8 = _mm_add_ps(r8, r9);
1804 __m128 v10 = _mm_load1_ps(matrix.
data() + 10);
1805 __m128 r10 = _mm_mul_ps(c2, v10);
1807 r8 = _mm_add_ps(r8, r10);
1809 __m128 v11 = _mm_load1_ps(matrix.
data() + 11);
1810 __m128 r11 = _mm_mul_ps(c3, v11);
1812 r8 = _mm_add_ps(r8, r11);
1814 _mm_storeu_ps(result.
data() + 8, r8);
1818 __m128 v12 = _mm_load1_ps(matrix.
data() + 12);
1819 __m128 r12 = _mm_mul_ps(c0, v12);
1821 __m128 v13 = _mm_load1_ps(matrix.
data() + 13);
1822 __m128 r13 = _mm_mul_ps(c1, v13);
1824 r12 = _mm_add_ps(r12, r13);
1826 __m128 v14 = _mm_load1_ps(matrix.
data() + 14);
1827 __m128 r14 = _mm_mul_ps(c2, v14);
1829 r12 = _mm_add_ps(r12, r14);
1831 __m128 v15 = _mm_load1_ps(matrix.
data() + 15);
1832 __m128 r15 = _mm_mul_ps(c3, v15);
1834 r12 = _mm_add_ps(r12, r15);
1836 _mm_storeu_ps(result.
data() + 12, r12);
1845template <
typename T>
1850 result.
values[0] = values[0] * matrix[0] + values[4] * matrix[1] + values[8] * matrix[2];
1851 result.
values[1] = values[1] * matrix[0] + values[5] * matrix[1] + values[9] * matrix[2];
1852 result.
values[2] = values[2] * matrix[0] + values[6] * matrix[1] + values[10] * matrix[2];
1853 result.
values[3] = values[3] * matrix[0] + values[7] * matrix[1] + values[11] * matrix[2];
1855 result.
values[4] = values[0] * matrix[4] + values[4] * matrix[5] + values[8] * matrix[6];
1856 result.
values[5] = values[1] * matrix[4] + values[5] * matrix[5] + values[9] * matrix[6];
1857 result.
values[6] = values[2] * matrix[4] + values[6] * matrix[5] + values[10] * matrix[6];
1858 result.
values[7] = values[3] * matrix[4] + values[7] * matrix[5] + values[11] * matrix[6];
1860 result.
values[8] = values[0] * matrix[8] + values[4] * matrix[9] + values[8] * matrix[10];
1861 result.
values[9] = values[1] * matrix[8] + values[5] * matrix[9] + values[9] * matrix[10];
1862 result.
values[10] = values[2] * matrix[8] + values[6] * matrix[9] + values[10] * matrix[10];
1863 result.
values[11] = values[3] * matrix[8] + values[7] * matrix[9] + values[11] * matrix[10];
1865 result.
values[12] = values[0] * matrix[12] + values[4] * matrix[13] + values[8] * matrix[14] + values[12];
1866 result.
values[13] = values[1] * matrix[12] + values[5] * matrix[13] + values[9] * matrix[14] + values[13];
1867 result.
values[14] = values[2] * matrix[12] + values[6] * matrix[13] + values[10] * matrix[14] + values[14];
1868 result.
values[15] = values[3] * matrix[12] + values[7] * matrix[13] + values[11] * matrix[14] + values[15];
1873template <
typename T>
1876 const T w = values[3] * vector[0] + values[7] * vector[1] + values[11] * vector[2] + values[15];
1879 const T factor = 1 / w;
1881 return VectorT3<T>((values[0] * vector[0] + values[4] * vector[1] + values[8] * vector[2] + values[12]) * factor,
1882 (values[1] * vector[0] + values[5] * vector[1] + values[9] * vector[2] + values[13]) * factor,
1883 (values[2] * vector[0] + values[6] * vector[1] + values[10] * vector[2] + values[14]) * factor);
1886template <
typename T>
1889 return VectorT4<T>(values[0] * vector[0] + values[4] * vector[1] + values[8] * vector[2] + values[12] * vector[3],
1890 values[1] * vector[0] + values[5] * vector[1] + values[9] * vector[2] + values[13] * vector[3],
1891 values[2] * vector[0] + values[6] * vector[1] + values[10] * vector[2] + values[14] * vector[3],
1892 values[3] * vector[0] + values[7] * vector[1] + values[11] * vector[2] + values[15] * vector[3]);
1895#if defined(OCEAN_HARDWARE_AVX_VERSION) && OCEAN_HARDWARE_AVX_VERSION >= 10
1897#ifdef OCEAN_USE_SLOWER_IMPLEMENTATION
1915 __m256d row0 = _mm256_loadu_pd(values + 0);
1916 __m256d row1 = _mm256_loadu_pd(values + 4);
1917 __m256d row2 = _mm256_loadu_pd(values + 8);
1918 __m256d row3 = _mm256_loadu_pd(values + 12);
1921 __m256d v = _mm256_loadu_pd(vector.
data());
1931 __m256d temp0 = _mm256_shuffle_pd(row0, row1, 0x00);
1933 __m256d temp2 = _mm256_shuffle_pd(row0, row1, 0x0F);
1935 __m256d temp1 = _mm256_shuffle_pd(row2, row3, 0x00);
1937 __m256d temp3 = _mm256_shuffle_pd(row2, row3, 0x0F);
1940 row0 = _mm256_permute2f128_pd(temp0, temp1, 0x20);
1942 row1 = _mm256_permute2f128_pd(temp2, temp3, 0x20);
1944 row2 = _mm256_permute2f128_pd(temp0, temp1, 0x31);
1946 row3 = _mm256_permute2f128_pd(temp2, temp3, 0x31);
1948#ifdef OCEAN_COMPILER_MSC
1949 ocean_assert(row0.m256d_f64[0] == values[0] && row0.m256d_f64[1] == values[4] && row0.m256d_f64[2] == values[ 8] && row0.m256d_f64[3] == values[12]);
1950 ocean_assert(row1.m256d_f64[0] == values[1] && row1.m256d_f64[1] == values[5] && row1.m256d_f64[2] == values[ 9] && row1.m256d_f64[3] == values[13]);
1951 ocean_assert(row2.m256d_f64[0] == values[2] && row2.m256d_f64[1] == values[6] && row2.m256d_f64[2] == values[10] && row2.m256d_f64[3] == values[14]);
1952 ocean_assert(row3.m256d_f64[0] == values[3] && row3.m256d_f64[1] == values[7] && row3.m256d_f64[2] == values[11] && row3.m256d_f64[3] == values[15]);
1957 __m256d r0v = _mm256_mul_pd(row0, v);
1958 __m256d r1v = _mm256_mul_pd(row1, v);
1959 __m256d r2v = _mm256_mul_pd(row2, v);
1960 __m256d r3v = _mm256_mul_pd(row3, v);
1963 __m256d sum_interleaved_r0_r1 = _mm256_hadd_pd(r0v, r1v);
1964 __m256d sum_interleaved_r2_r3 = _mm256_hadd_pd(r2v, r3v);
1967 __m256d sum_first = _mm256_permute2f128_pd(sum_interleaved_r0_r1, sum_interleaved_r2_r3, 0x20);
1968 __m256d sum_second = _mm256_permute2f128_pd(sum_interleaved_r0_r1, sum_interleaved_r2_r3, 0x31);
1971 __m256d sum = _mm256_add_pd(sum_first, sum_second);
1974 _mm256_storeu_pd(result.
data(), sum);
1976 ocean_assert(
NumericD::isEqual(result[0], values[0] * vector[0] + values[4] * vector[1] + values[ 8] * vector[2] + values[12] * vector[3],
NumericD::eps() * 100));
1977 ocean_assert(
NumericD::isEqual(result[1], values[1] * vector[0] + values[5] * vector[1] + values[ 9] * vector[2] + values[13] * vector[3],
NumericD::eps() * 100));
1978 ocean_assert(
NumericD::isEqual(result[2], values[2] * vector[0] + values[6] * vector[1] + values[10] * vector[2] + values[14] * vector[3],
NumericD::eps() * 100));
1979 ocean_assert(
NumericD::isEqual(result[3], values[3] * vector[0] + values[7] * vector[1] + values[11] * vector[2] + values[15] * vector[3],
NumericD::eps() * 100));
2001 __m256d v0 = _mm256_broadcast_sd(vector.
data() + 0);
2004 __m256d c0 = _mm256_loadu_pd(values + 0);
2007 __m256d r0 = _mm256_mul_pd(c0, v0);
2011 __m256d v1 = _mm256_broadcast_sd(vector.
data() + 1);
2012 __m256d c1 = _mm256_loadu_pd(values + 4);
2013 __m256d r1 = _mm256_mul_pd(c1, v1);
2016 r0 = _mm256_add_pd(r0, r1);
2020 __m256d v2 = _mm256_broadcast_sd(vector.
data() + 2);
2021 __m256d c2 = _mm256_loadu_pd(values + 8);
2022 __m256d r2 = _mm256_mul_pd(c2, v2);
2025 r0 = _mm256_add_pd(r0, r2);
2029 __m256d v3 = _mm256_broadcast_sd(vector.
data() + 3);
2030 __m256d c3 = _mm256_loadu_pd(values + 12);
2031 __m256d r3 = _mm256_mul_pd(c3, v3);
2034 r0 = _mm256_add_pd(r0, r3);
2039 _mm256_storeu_pd(result.
data(), r0);
2048#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 20
2073 __m128d v0 = _mm_load1_pd(vector.
data() + 0);
2076 __m128d c0a = _mm_loadu_pd(values + 0);
2077 __m128d c0b = _mm_loadu_pd(values + 2);
2080 __m128d r0a = _mm_mul_pd(c0a, v0);
2081 __m128d r0b = _mm_mul_pd(c0b, v0);
2085 __m128d v1 = _mm_load1_pd(vector.
data() + 1);
2087 __m128d c1a = _mm_loadu_pd(values + 4);
2088 __m128d c1b = _mm_loadu_pd(values + 6);
2090 __m128d r1a = _mm_mul_pd(c1a, v1);
2091 __m128d r1b = _mm_mul_pd(c1b, v1);
2094 r0a = _mm_add_pd(r0a, r1a);
2095 r0b = _mm_add_pd(r0b, r1b);
2099 __m128d v2 = _mm_load1_pd(vector.
data() + 2);
2101 __m128d c2a = _mm_loadu_pd(values + 8);
2102 __m128d c2b = _mm_loadu_pd(values + 10);
2104 __m128d r2a = _mm_mul_pd(c2a, v2);
2105 __m128d r2b = _mm_mul_pd(c2b, v2);
2108 r0a = _mm_add_pd(r0a, r2a);
2109 r0b = _mm_add_pd(r0b, r2b);
2113 __m128d v3 = _mm_load1_pd(vector.
data() + 3);
2115 __m128d c3a = _mm_loadu_pd(values + 12);
2116 __m128d c3b = _mm_loadu_pd(values + 14);
2118 __m128d r3a = _mm_mul_pd(c3a, v3);
2119 __m128d r3b = _mm_mul_pd(c3b, v3);
2122 r0a = _mm_add_pd(r0a, r3a);
2123 r0b = _mm_add_pd(r0b, r3b);
2128 _mm_storeu_pd(result.
data() + 0, r0a);
2129 _mm_storeu_pd(result.
data() + 2, r0b);
2138#ifdef OCEAN_USE_SLOWER_IMPLEMENTATION
2142#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
2159 __m128 row0 = _mm_loadu_ps(values + 0);
2160 __m128 row1 = _mm_loadu_ps(values + 4);
2161 __m128 row2 = _mm_loadu_ps(values + 8);
2162 __m128 row3 = _mm_loadu_ps(values + 12);
2165 __m128 v = _mm_loadu_ps(vector.
data());
2175 __m128 temp0 = _mm_shuffle_ps(row0, row1, 0x44);
2177 __m128 temp2 = _mm_shuffle_ps(row0, row1, 0xEE);
2179 __m128 temp1 = _mm_shuffle_ps(row2, row3, 0x44);
2181 __m128 temp3 = _mm_shuffle_ps(row2, row3, 0xEE);
2184 row0 = _mm_shuffle_ps(temp0, temp1, 0x88);
2186 row1 = _mm_shuffle_ps(temp0, temp1, 0xDD);
2188 row2 = _mm_shuffle_ps(temp2, temp3, 0x88);
2190 row3 = _mm_shuffle_ps(temp2, temp3, 0xDD);
2192#ifdef OCEAN_COMPILER_MSC
2193 ocean_assert(row0.m128_f32[0] == values[0] && row0.m128_f32[1] == values[4] && row0.m128_f32[2] == values[ 8] && row0.m128_f32[3] == values[12]);
2194 ocean_assert(row1.m128_f32[0] == values[1] && row1.m128_f32[1] == values[5] && row1.m128_f32[2] == values[ 9] && row1.m128_f32[3] == values[13]);
2195 ocean_assert(row2.m128_f32[0] == values[2] && row2.m128_f32[1] == values[6] && row2.m128_f32[2] == values[10] && row2.m128_f32[3] == values[14]);
2196 ocean_assert(row3.m128_f32[0] == values[3] && row3.m128_f32[1] == values[7] && row3.m128_f32[2] == values[11] && row3.m128_f32[3] == values[15]);
2200 row0 = _mm_dp_ps(row0, v, 0xF1);
2203 row1 = _mm_dp_ps(row1, v, 0xF2);
2204 row2 = _mm_dp_ps(row2, v, 0xF4);
2205 row3 = _mm_dp_ps(row3, v, 0xF8);
2208 __m128 result01 = _mm_or_ps(row0, row1);
2209 __m128 result23 = _mm_or_ps(row2, row3);
2210 __m128 result03 = _mm_or_ps(result01, result23);
2213 _mm_storeu_ps(result.
data(), result03);
2222#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 10
2248 __m128 v0 = _mm_load1_ps(vector.
data() + 0);
2251 __m128 c0 = _mm_loadu_ps(values + 0);
2254 __m128 r0 = _mm_mul_ps(c0, v0);
2258 __m128 v1 = _mm_load1_ps(vector.
data() + 1);
2259 __m128 c1 = _mm_loadu_ps(values + 4);
2260 __m128 r1 = _mm_mul_ps(c1, v1);
2263 r0 = _mm_add_ps(r0, r1);
2267 __m128 v2 = _mm_load1_ps(vector.
data() + 2);
2268 __m128 c2 = _mm_loadu_ps(values + 8);
2269 __m128 r2 = _mm_mul_ps(c2, v2);
2272 r0 = _mm_add_ps(r0, r2);
2276 __m128 v3 = _mm_load1_ps(vector.
data() + 3);
2277 __m128 c3 = _mm_loadu_ps(values + 12);
2278 __m128 r3 = _mm_mul_ps(c3, v3);
2281 r0 = _mm_add_ps(r0, r3);
2286 _mm_storeu_ps(result.
data(), r0);
2295#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
2315 float64x2_t v0 = vld1q_dup_f64(vector.
data() + 0);
2318 float64x2_t c0a = vld1q_f64(values + 0);
2319 float64x2_t c0b = vld1q_f64(values + 2);
2322 float64x2_t r0a = vmulq_f64(c0a, v0);
2323 float64x2_t r0b = vmulq_f64(c0b, v0);
2327 float64x2_t v1 = vld1q_dup_f64(vector.
data() + 1);
2329 float64x2_t c1a = vld1q_f64(values + 4);
2330 float64x2_t c1b = vld1q_f64(values + 6);
2332 float64x2_t r1a = vmulq_f64(c1a, v1);
2333 float64x2_t r1b = vmulq_f64(c1b, v1);
2336 r0a = vaddq_f64(r0a, r1a);
2337 r0b = vaddq_f64(r0b, r1b);
2341 float64x2_t v2 = vld1q_dup_f64(vector.
data() + 2);
2343 float64x2_t c2a = vld1q_f64(values + 8);
2344 float64x2_t c2b = vld1q_f64(values + 10);
2346 float64x2_t r2a = vmulq_f64(c2a, v2);
2347 float64x2_t r2b = vmulq_f64(c2b, v2);
2350 r0a = vaddq_f64(r0a, r2a);
2351 r0b = vaddq_f64(r0b, r2b);
2355 float64x2_t v3 = vld1q_dup_f64(vector.
data() + 3);
2357 float64x2_t c3a = vld1q_f64(values + 12);
2358 float64x2_t c3b = vld1q_f64(values + 14);
2360 float64x2_t r3a = vmulq_f64(c3a, v3);
2361 float64x2_t r3b = vmulq_f64(c3b, v3);
2364 r0a = vaddq_f64(r0a, r3a);
2365 r0b = vaddq_f64(r0b, r3b);
2370 vst1q_f64(result.
data() + 0, r0a);
2371 vst1q_f64(result.
data() + 2, r0b);
2394 float32x4_t v0 = vld1q_dup_f32(vector.
data() + 0);
2397 float32x4_t c0 = vld1q_f32(values + 0);
2400 float32x4_t r0 = vmulq_f32(c0, v0);
2404 float32x4_t v1 = vld1q_dup_f32(vector.
data() + 1);
2405 float32x4_t c1 = vld1q_f32(values + 4);
2406 float32x4_t r1 = vmulq_f32(c1, v1);
2409 r0 = vaddq_f32(r0, r1);
2413 float32x4_t v2 = vld1q_dup_f32(vector.
data() + 2);
2414 float32x4_t c2 = vld1q_f32(values + 8);
2415 float32x4_t r2 = vmulq_f32(c2, v2);
2418 r0 = vaddq_f32(r0, r2);
2422 float32x4_t v3 = vld1q_dup_f32(vector.
data() + 3);
2423 float32x4_t c3 = vld1q_f32(values + 12);
2424 float32x4_t r3 = vmulq_f32(c3, v3);
2427 r0 = vaddq_f32(r0, r3);
2432 vst1q_f32(result.
data(), r0);
2439template <
typename T>
2444 result.
values[0] *= value;
2445 result.
values[1] *= value;
2446 result.
values[2] *= value;
2447 result.
values[3] *= value;
2448 result.
values[4] *= value;
2449 result.
values[5] *= value;
2450 result.
values[6] *= value;
2451 result.
values[7] *= value;
2452 result.
values[8] *= value;
2453 result.
values[9] *= value;
2454 result.
values[10] *= value;
2455 result.
values[11] *= value;
2456 result.
values[12] *= value;
2457 result.
values[13] *= value;
2458 result.
values[14] *= value;
2459 result.
values[15] *= value;
2464template <
typename T>
2477 values[10] *= value;
2478 values[11] *= value;
2479 values[12] *= value;
2480 values[13] *= value;
2481 values[14] *= value;
2482 values[15] *= value;
2487template <
typename T>
2506 ocean_assert(aspectRatio > 0);
2507 ocean_assert(nearDistance > 0);
2508 ocean_assert(nearDistance < farDistance);
2513 ocean_assert(matrix(1, 0) == 0 && matrix(2, 0) == 0 && matrix(3, 0) == 0);
2514 ocean_assert(matrix(0, 1) == 0 && matrix(2, 1) == 0 && matrix(3, 1) == 0);
2515 ocean_assert(matrix(0, 2) == 0 && matrix(1, 2) == 0);
2516 ocean_assert(matrix(0, 3) == 0 && matrix(1, 3) == 0 && matrix(3, 3) == 0);
2521 const T factor = T(1.0) / (nearDistance - farDistance);
2523 matrix(0, 0) = f / aspectRatio;
2525 matrix(2, 2) = (farDistance + nearDistance) * factor;
2526 matrix(3, 2) = -T(1.0);
2527 matrix(2, 3) = (T(2.0) * farDistance * nearDistance) * factor;
2532template <
typename T>
2550 ocean_assert(anyCamera.
isValid());
2552 ocean_assert(nearDistance > 0);
2553 ocean_assert(nearDistance < farDistance);
2557 ocean_assert(fxPixel > T(1) && fyPixel > T(1));
2562 const T width_2 = T(anyCamera.
width()) / T(2);
2563 const T height_2 = T(anyCamera.
height()) / T(2);
2568 const T fx = fxPixel / width_2;
2569 const T fy = fyPixel / height_2;
2571 const T mx = (mxPixel - width_2) / width_2;
2572 const T my = (myPixel - height_2) / height_2;
2574 const T factor = T(1.0) / (nearDistance - farDistance);
2582 matrix(2, 2) = (farDistance + nearDistance) * factor;
2583 matrix(3, 2) = -T(1);
2584 matrix(2, 3) = (T(2) * farDistance * nearDistance) * factor;
2589template <
typename T>
2610 ocean_assert(matrix(1, 0) == 0 && matrix(2, 0) == 0 && matrix(3, 0) == 0);
2611 ocean_assert(matrix(0, 1) == 0 && matrix(2, 1) == 0 && matrix(3, 1) == 0);
2612 ocean_assert(matrix(0, 3) == 0 && matrix(1, 3) == 0 && matrix(3, 3) == 0);
2614 const T rightLeft = T(1.0) / (right - left);
2615 const T near2 = nearDistance * T(2.0);
2617 matrix(0, 0) = near2 * rightLeft;
2618 matrix(0, 2) = (right + left) * rightLeft;
2620 const T topBottom = T(1.0) / (top - bottom);
2622 matrix(1, 1) = near2 * topBottom;
2623 matrix(1, 2) = (top + bottom) * topBottom;
2625 const T farNear = T(1.0) / (farDistance - nearDistance);
2627 matrix(2, 2) = -(farDistance + nearDistance) * farNear;
2628 matrix(2, 3) = -T(2.0) * farDistance * nearDistance * farNear;
2630 matrix(3, 2) = -T(1.0);
2635template <
typename T>
2639 ocean_assert(nearDistance >=
NumericT<T>::eps() && farDistance > nearDistance);
2646 const VectorT3<T> leftTop(width * -T(0.5), height * T(0.5), 0);
2647 const VectorT3<T> rightBottom(width * T(0.5), height * -T(0.5), 0);
2649 const VectorT3<T> leftTopInCamera(inversedViewingMatrix * leftTop);
2650 const VectorT3<T> rightBottomInCamera(inversedViewingMatrix * rightBottom);
2652 const T factor = nearDistance / planeDistance;
2654 return frustumMatrix(factor * leftTopInCamera.
x(), factor * rightBottomInCamera.
x(), factor * leftTopInCamera.
y(), factor * rightBottomInCamera.
y(), nearDistance, farDistance);
2657template <
typename T>
2660 ocean_assert((vectors && results) || number == 0);
2662 for (
size_t n = 0; n < number; ++n)
2664 results[n] = matrix * vectors[n];
2668#if defined(OCEAN_HARDWARE_AVX_VERSION) && OCEAN_HARDWARE_AVX_VERSION >= 10
2684 __m256d c0 = _mm256_loadu_pd(matrix.
values + 0);
2685 __m256d c1 = _mm256_loadu_pd(matrix.
values + 4);
2686 __m256d c2 = _mm256_loadu_pd(matrix.
values + 8);
2687 __m256d c3 = _mm256_loadu_pd(matrix.
values + 12);
2689 for (
size_t n = 0; n < number; ++n)
2691 __m256d v0 = _mm256_broadcast_sd(vectors[n].data() + 0);
2692 __m256d r0 = _mm256_mul_pd(c0, v0);
2694 __m256d v1 = _mm256_broadcast_sd(vectors[n].data() + 1);
2695 __m256d r1 = _mm256_mul_pd(c1, v1);
2697 r0 = _mm256_add_pd(r0, r1);
2699 __m256d v2 = _mm256_broadcast_sd(vectors[n].data() + 2);
2700 __m256d r2 = _mm256_mul_pd(c2, v2);
2702 r0 = _mm256_add_pd(r0, r2);
2704 __m256d v3 = _mm256_broadcast_sd(vectors[n].data() + 3);
2705 __m256d r3 = _mm256_mul_pd(c3, v3);
2707 r0 = _mm256_add_pd(r0, r3);
2709 _mm256_storeu_pd(results[n].data(), r0);
2715#ifdef OCEAN_USE_SLOWER_IMPLEMENTATION
2719#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
2736 __m128 row0 = _mm_loadu_ps(matrix.
values + 0);
2737 __m128 row1 = _mm_loadu_ps(matrix.
values + 4);
2738 __m128 row2 = _mm_loadu_ps(matrix.
values + 8);
2739 __m128 row3 = _mm_loadu_ps(matrix.
values + 12);
2749 __m128 temp0 = _mm_shuffle_ps(row0, row1, 0x44);
2751 __m128 temp2 = _mm_shuffle_ps(row0, row1, 0xEE);
2753 __m128 temp1 = _mm_shuffle_ps(row2, row3, 0x44);
2755 __m128 temp3 = _mm_shuffle_ps(row2, row3, 0xEE);
2758 row0 = _mm_shuffle_ps(temp0, temp1, 0x88);
2760 row1 = _mm_shuffle_ps(temp0, temp1, 0xDD);
2762 row2 = _mm_shuffle_ps(temp2, temp3, 0x88);
2764 row3 = _mm_shuffle_ps(temp2, temp3, 0xDD);
2766#ifdef OCEAN_COMPILER_MSC
2767 ocean_assert(row0.m128_f32[0] == matrix.
values[0] && row0.m128_f32[1] == matrix.
values[4] && row0.m128_f32[2] == matrix.
values[ 8] && row0.m128_f32[3] == matrix.
values[12]);
2768 ocean_assert(row1.m128_f32[0] == matrix.
values[1] && row1.m128_f32[1] == matrix.
values[5] && row1.m128_f32[2] == matrix.
values[ 9] && row1.m128_f32[3] == matrix.
values[13]);
2769 ocean_assert(row2.m128_f32[0] == matrix.
values[2] && row2.m128_f32[1] == matrix.
values[6] && row2.m128_f32[2] == matrix.
values[10] && row2.m128_f32[3] == matrix.
values[14]);
2770 ocean_assert(row3.m128_f32[0] == matrix.
values[3] && row3.m128_f32[1] == matrix.
values[7] && row3.m128_f32[2] == matrix.
values[11] && row3.m128_f32[3] == matrix.
values[15]);
2773 for (
size_t n = 0u; n < number; ++n)
2776 __m128 v = _mm_loadu_ps(vectors[n].data());
2779 __m128 dot0 = _mm_dp_ps(row0, v, 0xF1);
2782 __m128 dot1 = _mm_dp_ps(row1, v, 0xF2);
2783 __m128 dot2 = _mm_dp_ps(row2, v, 0xF4);
2784 __m128 dot3 = _mm_dp_ps(row3, v, 0xF8);
2787 __m128 result01 = _mm_or_ps(dot0, dot1);
2788 __m128 result23 = _mm_or_ps(dot2, dot3);
2789 __m128 result03 = _mm_or_ps(result01, result23);
2791 _mm_storeu_ps(results[n].data(), result03);
2799#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 20
2814 __m128d c0a = _mm_loadu_pd(matrix.
values + 0);
2815 __m128d c0b = _mm_loadu_pd(matrix.
values + 2);
2816 __m128d c1a = _mm_loadu_pd(matrix.
values + 4);
2817 __m128d c1b = _mm_loadu_pd(matrix.
values + 6);
2818 __m128d c2a = _mm_loadu_pd(matrix.
values + 8);
2819 __m128d c2b = _mm_loadu_pd(matrix.
values + 10);
2820 __m128d c3a = _mm_loadu_pd(matrix.
values + 12);
2821 __m128d c3b = _mm_loadu_pd(matrix.
values + 14);
2823 for (
size_t n = 0u; n < number; ++n)
2825 __m128d v0 = _mm_load1_pd(vectors[n].data() + 0);
2826 __m128d v1 = _mm_load1_pd(vectors[n].data() + 1);
2827 __m128d v2 = _mm_load1_pd(vectors[n].data() + 2);
2828 __m128d v3 = _mm_load1_pd(vectors[n].data() + 3);
2831 __m128d r0a = _mm_mul_pd(c0a, v0);
2832 __m128d r0b = _mm_mul_pd(c0b, v0);
2835 __m128d r1a = _mm_mul_pd(c1a, v1);
2836 __m128d r1b = _mm_mul_pd(c1b, v1);
2838 r0a = _mm_add_pd(r0a, r1a);
2839 r0b = _mm_add_pd(r0b, r1b);
2842 __m128d r2a = _mm_mul_pd(c2a, v2);
2843 __m128d r2b = _mm_mul_pd(c2b, v2);
2844 r0a = _mm_add_pd(r0a, r2a);
2845 r0b = _mm_add_pd(r0b, r2b);
2848 __m128d r3a = _mm_mul_pd(c3a, v3);
2849 __m128d r3b = _mm_mul_pd(c3b, v3);
2850 r0a = _mm_add_pd(r0a, r3a);
2851 r0b = _mm_add_pd(r0b, r3b);
2853 _mm_storeu_pd(results[n].data() + 0, r0a);
2854 _mm_storeu_pd(results[n].data() + 2, r0b);
2860#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 10
2875 __m128 c0 = _mm_loadu_ps(matrix.
values + 0);
2876 __m128 c1 = _mm_loadu_ps(matrix.
values + 4);
2877 __m128 c2 = _mm_loadu_ps(matrix.
values + 8);
2878 __m128 c3 = _mm_loadu_ps(matrix.
values + 12);
2880 for (
size_t n = 0u; n < number; ++n)
2882 __m128 v0 = _mm_load1_ps(vectors[n].data() + 0);
2883 __m128 v1 = _mm_load1_ps(vectors[n].data() + 1);
2884 __m128 v2 = _mm_load1_ps(vectors[n].data() + 2);
2885 __m128 v3 = _mm_load1_ps(vectors[n].data() + 3);
2888 __m128 r0 = _mm_mul_ps(c0, v0);
2891 __m128 r1 = _mm_mul_ps(c1, v1);
2893 r0 = _mm_add_ps(r0, r1);
2896 __m128 r2 = _mm_mul_ps(c2, v2);
2897 r0 = _mm_add_ps(r0, r2);
2900 __m128 r3 = _mm_mul_ps(c3, v3);
2901 r0 = _mm_add_ps(r0, r3);
2903 _mm_storeu_ps(results[n].data(), r0);
2913#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
2923 float64x2_t c0a = vld1q_f64(matrix.
values + 0);
2924 float64x2_t c0b = vld1q_f64(matrix.
values + 2);
2925 float64x2_t c1a = vld1q_f64(matrix.
values + 4);
2926 float64x2_t c1b = vld1q_f64(matrix.
values + 6);
2927 float64x2_t c2a = vld1q_f64(matrix.
values + 8);
2928 float64x2_t c2b = vld1q_f64(matrix.
values + 10);
2929 float64x2_t c3a = vld1q_f64(matrix.
values + 12);
2930 float64x2_t c3b = vld1q_f64(matrix.
values + 14);
2932 for (
size_t n = 0u; n < number; ++n)
2934 float64x2_t v0 = vld1q_dup_f64(vectors[n].data() + 0);
2935 float64x2_t v1 = vld1q_dup_f64(vectors[n].data() + 1);
2936 float64x2_t v2 = vld1q_dup_f64(vectors[n].data() + 2);
2937 float64x2_t v3 = vld1q_dup_f64(vectors[n].data() + 3);
2939 float64x2_t r0a = vmulq_f64(c0a, v0);
2940 float64x2_t r0b = vmulq_f64(c0b, v0);
2942 float64x2_t r1a = vmulq_f64(c1a, v1);
2943 float64x2_t r1b = vmulq_f64(c1b, v1);
2945 r0a = vaddq_f64(r0a, r1a);
2946 r0b = vaddq_f64(r0b, r1b);
2948 float64x2_t r2a = vmulq_f64(c2a, v2);
2949 float64x2_t r2b = vmulq_f64(c2b, v2);
2951 r0a = vaddq_f64(r0a, r2a);
2952 r0b = vaddq_f64(r0b, r2b);
2954 float64x2_t r3a = vmulq_f64(c3a, v3);
2955 float64x2_t r3b = vmulq_f64(c3b, v3);
2957 r0a = vaddq_f64(r0a, r3a);
2958 r0b = vaddq_f64(r0b, r3b);
2960 vst1q_f64(results[n].data() + 0, r0a);
2961 vst1q_f64(results[n].data() + 2, r0b);
2973 float32x4_t c0 = vld1q_f32(matrix.
values + 0);
2974 float32x4_t c1 = vld1q_f32(matrix.
values + 4);
2975 float32x4_t c2 = vld1q_f32(matrix.
values + 8);
2976 float32x4_t c3 = vld1q_f32(matrix.
values + 12);
2978 for (
size_t n = 0u; n < number; ++n)
2980 float32x4_t v0 = vld1q_dup_f32(vectors[n].data() + 0);
2981 float32x4_t v1 = vld1q_dup_f32(vectors[n].data() + 1);
2982 float32x4_t v2 = vld1q_dup_f32(vectors[n].data() + 2);
2983 float32x4_t v3 = vld1q_dup_f32(vectors[n].data() + 3);
2986 float32x4_t r0 = vmulq_f32(c0, v0);
2989 float32x4_t r1 = vmulq_f32(c1, v1);
2991 r0 = vaddq_f32(r0, r1);
2994 float32x4_t r2 = vmulq_f32(c2, v2);
2996 r0 = vaddq_f32(r0, r2);
2999 float32x4_t r3 = vmulq_f32(c3, v3);
3001 r0 = vaddq_f32(r0, r3);
3003 vst1q_f32(results[n].data(), r0);
3009template <
typename T>
3010template <
typename U>
3013 std::vector< SquareMatrixT4<T> > result;
3014 result.reserve(matrices.size());
3016 for (
typename std::vector<
SquareMatrixT4<U> >::const_iterator i = matrices.begin(); i != matrices.end(); ++i)
3038template <
typename T>
3039template <
typename U>
3042 std::vector< SquareMatrixT4<T> > result;
3043 result.reserve(size);
3045 for (
size_t n = 0; n < size; ++n)
3053template <
typename T>
3056 ocean_assert(row0 < 4u && row1 < 4u);
3063 T* first = values + row0;
3064 T* second = values + row1;
3089template <
typename T>
3092 ocean_assert(row < 4u);
3094 T* element = values + row;
3105template <
typename T>
3108 ocean_assert(targetRow < 4u && sourceRow < 4u);
3109 ocean_assert(targetRow != sourceRow);
3111 T* target = values + targetRow;
3112 T* source = values + sourceRow;
3114 *target += *source * scalar;
3118 *target += *source * scalar;
3122 *target += *source * scalar;
3126 *target += *source * scalar;
3129template <
typename T>
3132 stream <<
"|" << matrix(0, 0) <<
", " << matrix(0, 1) <<
", " << matrix(0, 2) <<
", " << matrix(0, 3) <<
"|" << std::endl;
3133 stream <<
"|" << matrix(1, 0) <<
", " << matrix(1, 1) <<
", " << matrix(1, 2) <<
", " << matrix(1, 3) <<
"|" << std::endl;
3134 stream <<
"|" << matrix(2, 0) <<
", " << matrix(2, 1) <<
", " << matrix(2, 2) <<
", " << matrix(2, 3) <<
"|" << std::endl;
3135 stream <<
"|" << matrix(3, 0) <<
", " << matrix(3, 1) <<
", " << matrix(3, 2) <<
", " << matrix(3, 3) <<
"|";
3140template <
bool tActive,
typename T>
3141MessageObject<tActive>&
operator<<(MessageObject<tActive>& messageObject,
const SquareMatrixT4<T>& matrix)
3143 return messageObject <<
"|" << matrix(0, 0) <<
", " << matrix(0, 1) <<
", " << matrix(0, 2) <<
", " << matrix(0, 3) <<
"|\n|"
3144 << matrix(1, 0) <<
", " << matrix(1, 1) <<
", " << matrix(1, 2) <<
", " << matrix(1, 3) <<
"|\n|"
3145 << matrix(2, 0) <<
", " << matrix(2, 1) <<
", " << matrix(2, 2) <<
", " << matrix(2, 3) <<
"|\n|"
3146 << matrix(3, 0) <<
", " << matrix(3, 1) <<
", " << matrix(3, 2) <<
", " << matrix(3, 3) <<
"|";
3149template <
bool tActive,
typename T>
3150MessageObject<tActive>&
operator<<(MessageObject<tActive>&& messageObject,
const SquareMatrixT4<T>& matrix)
3152 return messageObject <<
"|" << matrix(0, 0) <<
", " << matrix(0, 1) <<
", " << matrix(0, 2) <<
", " << matrix(0, 3) <<
"|\n|"
3153 << matrix(1, 0) <<
", " << matrix(1, 1) <<
", " << matrix(1, 2) <<
", " << matrix(1, 3) <<
"|\n|"
3154 << matrix(2, 0) <<
", " << matrix(2, 1) <<
", " << matrix(2, 2) <<
", " << matrix(2, 3) <<
"|\n|"
3155 << matrix(3, 0) <<
", " << matrix(3, 1) <<
", " << matrix(3, 2) <<
", " << matrix(3, 3) <<
"|";
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
virtual unsigned int width() const =0
Returns the width of the camera image.
virtual T focalLengthX() const =0
Returns the horizontal focal length parameter.
virtual T focalLengthY() const =0
Returns the vertical focal length parameter.
virtual unsigned int height() const =0
Returns the height of the camera image.
virtual T principalPointY() const =0
Returns the y-value of the principal point of the camera image in the pixel domain.
virtual bool isValid() const =0
Returns whether this camera is valid.
virtual T principalPointX() const =0
Returns the x-value of the principal point of the camera image in the pixel domain.
static unsigned int solveQuartic(const T a, const T b, const T c, const T d, const T e, T *x, const bool refine=true)
Solves a quartic equation with the form:
Definition Equation.h:343
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition HomogenousMatrix4.h:110
HomogenousMatrixT4< T > inverted() const noexcept
Returns the inverted of this matrix.
Definition HomogenousMatrix4.h:1575
VectorT3< T > translation() const
Returns the translation of the transformation.
Definition HomogenousMatrix4.h:1381
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1806
This class provides basic numeric functionalities.
Definition Numeric.h:57
static constexpr T weakEps()
Returns a weak epsilon.
static T atan(const T value)
Returns the arctangent of a given value.
Definition Numeric.h:1620
static T abs(const T value)
Returns the absolute value of a given value.
Definition Numeric.h:1220
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:2395
static T tan(const T value)
Returns the tangent of a given value.
Definition Numeric.h:1604
static constexpr bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition Numeric.h:2096
static constexpr T maxValue()
Returns the max scalar value.
Definition Numeric.h:3253
This class implements a 3x3 square matrix.
Definition SquareMatrix3.h:89
OCEAN_FORCE_INLINE SquareMatrixT4< T > & operator*=(const SquareMatrixT4< T > &matrix)
Multiplies and assigns two matrices.
Definition SquareMatrix4.h:1336
void copyElements(U *arrayValues) const
Copies the elements of this matrix to an array with floating point values of type U.
Definition SquareMatrix4.h:1311
SquareMatrixT4< T > & operator-=(const SquareMatrixT4< T > &matrix)
Subtracts and assigns two matrices.
Definition SquareMatrix4.h:1460
const T * data() const
Returns a pointer to the internal values.
Definition SquareMatrix4.h:750
T operator()(const unsigned int index) const
Element operator.
Definition SquareMatrix4.h:1378
SquareMatrixT4(const U *arrayValues, const bool valuesRowAligned)
Creates a new SquareMatrixT4 object by an array of at least sixteen elements of float type U.
Definition SquareMatrix4.h:644
static SquareMatrixT4< T > projectionMatrix(const T fovX, const T aspectRatio, const T nearDistance, const T farDistance)
Creates a projection matrix defined by the horizontal field of view, the aspect ratio and the near an...
Definition SquareMatrix4.h:2488
OCEAN_FORCE_INLINE VectorT3< T > operator*(const VectorT3< T > &vector) const
Multiply operator for a 3D vector.
Definition SquareMatrix4.h:1874
bool isIdentity() const
Returns whether this matrix is the identity matrix.
Definition SquareMatrix4.h:970
SquareMatrixT4(const U *arrayValues)
Creates a new SquareMatrixT4 object by an array of at least sixteen elements of float type U.
Definition SquareMatrix4.h:625
SquareMatrixT4(const SquareMatrixT4< U > &matrix)
Copy constructor for a matrix with difference element data type than T.
Definition SquareMatrix4.h:602
void transpose()
Transposes the matrix.
Definition SquareMatrix4.h:788
static SquareMatrixT4< T > projectionMatrix(const AnyCameraT< T > &anyCamera, const T nearDistance, const T farDistance)
Creates a projection matrix defined by a camera profile of a pinhole camera and the near and far clip...
Definition SquareMatrix4.h:2533
SquareMatrixT4< T > transposed() const
Returns the transposed of this matrix.
Definition SquareMatrix4.h:762
void swapRows(const unsigned int row0, const unsigned int row1)
Swaps two rows of this matrix.
Definition SquareMatrix4.h:3054
void copyElements(T *arrayValues) const
Copies the elements of this matrix to an array with floating point values.
Definition SquareMatrix4.h:1322
SquareMatrixT4< T > inverted() const
Returns the inverted matrix of this matrix.
Definition SquareMatrix4.h:812
bool invert(SquareMatrixT4< T > &invertedMatrix) const
Inverts the matrix and returns the result.
Definition SquareMatrix4.h:841
SquareMatrixT4< T > operator+(const SquareMatrixT4< T > &matrix) const
Adds two matrices.
Definition SquareMatrix4.h:1429
T operator[](const unsigned int index) const
Element operator.
Definition SquareMatrix4.h:1350
bool isSingular() const
Returns whether this matrix is singular (and thus cannot be inverted).
Definition SquareMatrix4.h:988
SquareMatrixT4()
Creates a new SquareMatrixT4 object with undefined elements.
Definition SquareMatrix4.h:595
SquareMatrixT4(const VectorT4< T > &diagonal)
Creates a new SquareMatrixT4 object by a given diagonal vector.
Definition SquareMatrix4.h:729
OCEAN_FORCE_INLINE SquareMatrixT4< T > operator*(const HomogenousMatrixT4< T > &matrix) const
Multiplies two matrices.
Definition SquareMatrix4.h:1846
friend class SquareMatrixT4
Definition SquareMatrix4.h:86
bool isSymmetric(const T epsilon=NumericT< T >::eps()) const
Returns whether this matrix is symmetric.
Definition SquareMatrix4.h:994
T values[16]
The sixteen values of the matrix.
Definition SquareMatrix4.h:591
T determinant() const
Returns the determinant of the matrix.
Definition SquareMatrix4.h:906
T * data()
Returns a pointer to the internal values.
Definition SquareMatrix4.h:756
T operator()(const unsigned int row, const unsigned int column) const
Element operator.
Definition SquareMatrix4.h:1364
bool isEqual(const SquareMatrixT4< T > &matrix, const T eps=NumericT< T >::eps()) const
Returns whether two matrices are almost identical up to a specified epsilon.
Definition SquareMatrix4.h:1003
void toNull()
Sets the matrix to a zero matrix.
Definition SquareMatrix4.h:961
bool operator==(const SquareMatrixT4< T > &matrix) const
Returns whether two matrices are identical up to a small epsilon.
Definition SquareMatrix4.h:1423
static size_t elements()
Returns the number of elements this matrix has.
Definition SquareMatrix4.h:1417
SquareMatrixT4< T > & operator+=(const SquareMatrixT4< T > &matrix)
Adds and assigns two matrices.
Definition SquareMatrix4.h:1439
const T * operator()() const
Access operator.
Definition SquareMatrix4.h:1392
SquareMatrixT4< T > & operator=(const SquareMatrixT4< T > &)=default
Default assign operator.
SquareMatrixT4(const T *arrayValues, const bool valuesRowAligned)
Creates a new SquareMatrixT4 object by an array of at least sixteen elements.
Definition SquareMatrix4.h:677
static void multiply(const SquareMatrixT4< T > &matrix, const VectorT4< T > *vectors, VectorT4< T > *results, const size_t number)
Multiplies several 4D vectors with a given matrix.
Definition SquareMatrix4.h:2658
SquareMatrixT4< T > operator-() const
Returns the negative matrix of this matrix (all matrix elements are multiplied by -1).
Definition SquareMatrix4.h:1471
bool isNull() const
Returns whether this matrix is a null matrix.
Definition SquareMatrix4.h:979
OCEAN_FORCE_INLINE SquareMatrixT4< T > & operator*=(const HomogenousMatrixT4< T > &matrix)
Multiplies and assigns two matrices.
Definition SquareMatrix4.h:1343
T Type
Definition of the used data type.
Definition SquareMatrix4.h:93
SquareMatrixT4(const SquareMatrixT3< T > &subMatrix)
Creates a new SquareMatrixT4 object by given 3x3 sub matrix.
Definition SquareMatrix4.h:713
SquareMatrixT4< T > operator-(const SquareMatrixT4< T > &matrix) const
Subtracts two matrices.
Definition SquareMatrix4.h:1450
void addRows(const unsigned int targetRow, const unsigned int sourceRow, const T scalar)
Multiplies elements from a specific row with a scalar and adds them to another row.
Definition SquareMatrix4.h:3106
static std::vector< SquareMatrixT4< T > > matrices2matrices(const std::vector< SquareMatrixT4< U > > &matrices)
Converts matrices with specific data type to matrices with different data type.
Definition SquareMatrix4.h:3011
static SquareMatrixT4< T > frustumMatrix(const T left, const T right, const T top, const T bottom, const T nearDistance, const T farDistance)
Creates a projection matrix defined by an asymmetric viewing frustum.
Definition SquareMatrix4.h:2590
T & operator()(const unsigned int index)
Element operator.
Definition SquareMatrix4.h:1385
SquareMatrixT4< T > operator*(const T value) const
Multiplies this matrix with a scalar value.
Definition SquareMatrix4.h:2440
bool invert()
Inverts this matrix in place.
Definition SquareMatrix4.h:826
bool operator!=(const SquareMatrixT4< T > &matrix) const
Returns whether two matrices are not identical up to a small epsilon.
Definition SquareMatrix4.h:1330
size_t operator()(const SquareMatrixT4< T > &matrix) const
Hash function.
Definition SquareMatrix4.h:1404
static std::vector< SquareMatrixT4< T > > matrices2matrices(const SquareMatrixT4< U > *matrices, const size_t size)
Converts matrices with specific data type to matrices with different data type.
Definition SquareMatrix4.h:3040
OCEAN_FORCE_INLINE SquareMatrixT4< T > operator*(const SquareMatrixT4< T > &matrix) const
Multiplies two matrices.
Definition SquareMatrix4.h:1484
T & operator()(const unsigned int row, const unsigned int column)
Element operator.
Definition SquareMatrix4.h:1371
T & operator[](const unsigned int index)
Element operator.
Definition SquareMatrix4.h:1357
bool eigenSystem(T *eigenValues, VectorT4< T > *eigenVectors) const
Performs an eigen value analysis.
Definition SquareMatrix4.h:1016
void multiplyRow(const unsigned int row, const T scalar)
Multiplies a row with a scalar value.
Definition SquareMatrix4.h:3090
T trace() const
Returns the trace of the matrix which is the sum of the diagonal elements.
Definition SquareMatrix4.h:934
SquareMatrixT4(const bool setToIdentity)
Creates a new SquareMatrixT4 object.
Definition SquareMatrix4.h:611
SquareMatrixT4(const HomogenousMatrixT4< T > &transformation)
Creates a new SquareMatrixT4 object by given transformation matrix.
Definition SquareMatrix4.h:707
OCEAN_FORCE_INLINE VectorT4< T > operator*(const VectorT4< T > &vector) const
Multiply operator for a 4D vector.
Definition SquareMatrix4.h:1887
T * operator()()
Access operator.
Definition SquareMatrix4.h:1398
static SquareMatrixT4< T > frustumMatrix(const T width, const T height, const HomogenousMatrixT4< T > &viewingMatrix, const T nearDistance, const T farDistance)
Creates a project matrix defined by an asymmetric viewing frustum.
Definition SquareMatrix4.h:2636
SquareMatrixT4< T > & operator*=(const T value)
Multiplies and assigns this matrix with a scalar value.
Definition SquareMatrix4.h:2465
void toIdentity()
Sets the matrix to the identity matrix.
Definition SquareMatrix4.h:940
SquareMatrixT4(const SquareMatrixT4< T > &matrix)=default
Copy constructor.
SquareMatrixT4(const T *arrayValues)
Creates a new SquareMatrixT4 object by an array of at least sixteen elements.
Definition SquareMatrix4.h:636
static void sortHighestToFront4(T &value0, T &value1, T &value2, T &value3)
Sorts four values so that the highest value will finally be the first value.
Definition base/Utilities.h:758
This class implements a vector with three elements.
Definition Vector3.h:97
const T & y() const noexcept
Returns the y value.
Definition Vector3.h:824
const T & x() const noexcept
Returns the x value.
Definition Vector3.h:812
This class implements a vector with four elements.
Definition Vector4.h:97
const T * data() const noexcept
Returns an pointer to the vector elements.
Definition Vector4.h:732
bool normalize()
Normalizes this vector.
Definition Vector4.h:605
std::vector< SquareMatrix4 > SquareMatrices4
Definition of a vector holding SquareMatrix4 objects.
Definition SquareMatrix4.h:68
std::vector< SquareMatrixT4< T > > SquareMatricesT4
Definition of a typename alias for vectors with SquareMatrixT4 objects.
Definition SquareMatrix4.h:61
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
std::ostream & operator<<(std::ostream &stream, const HighPerformanceStatistic &highPerformanceStatistic)
Definition HighPerformanceTimer.h:963