SuperDex Physics C++ API
Loading...
Searching...
No Matches
matrix_utils.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
25
26namespace superdex {
27
28/**************************************************************************************************
29 Frobenius Norm
30*/
31
32// Square of the Frobenius norm of a matrix
33template <typename T, size_t N, size_t M>
34[[nodiscard]] MOCHI_FORCE_INLINE constexpr T NormSqr(NdArray<T, N, M> const& a);
35
36// Frobenius norm of a matrix
37template <typename T, size_t N, size_t M>
38[[nodiscard]] MOCHI_FORCE_INLINE T Norm(NdArray<T, N, M> const& a);
39
40// Square of the Frobenius norm of the upper-left 3x3 portion of a SIMD matrix
41template <typename T, size_t D0, int D1, MOCHI_CONCEPT(D0 >= 3 && D1 >= 3)>
42[[nodiscard]] MOCHI_FORCE_INLINE T NormSqr3x3(NdArray<Simd<T, D1>, D0> const& a);
43
44// Frobenius norm of the upper-left 3x3 portion of a SIMD matrix.
45template <typename T, size_t D0, int D1, MOCHI_CONCEPT(D0 >= 3 && D1 >= 3)>
46[[nodiscard]] MOCHI_FORCE_INLINE T Norm3x3(NdArray<Simd<T, D1>, D0> const& a);
47
48/**************************************************************************************************
49 Matrix-Vector Dot Product
50*/
51
52// Dot product of (matrix, array). The result is a 1D array where the ith element is defined as the
53// dot product of 'b' and a row (2nd dimension) of 'a'.
54template <typename T, size_t N, size_t M>
55[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N> DotMatVec(
56 NdArray<T, N, M> const& a,
57 NdArray<T, M> const& b);
58
59template <typename T, size_t N, size_t M>
60[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N> DotMatVec(
61 NdArray<T, N, M> const& a,
63
64template <typename T, size_t N, size_t M>
66
67// Dot product of a 3xN matrix and an Nx1 vector, where N <= 4. The result is interpreted as a 3x1
68// vector, with an additional invalid component for SIMD padding. The matrix is allowed to have
69// more (D0) rows, but rows beyond the third one will be ignored.
70template <size_t N, typename T, size_t D0>
72 NdArray<Simd<T, 4>, D0> const& m,
73 Simd<T, 4> v);
74
75// Dot product of (matrix, array). Supports 3x3 and 4x4 matrices, but only uses the upper-left 3x3
76// portion of the matrix. Ignores v[3]. Can be used to rotate 3D vectors, but DotVecMat3x3 is faster
77// if you already have the matrix transpose.
78template <typename T, size_t D0>
80 NdArray<Simd<T, 4>, D0> const& m,
81 Simd<T, 4> v);
82
83// Dot product of (matrix, array). Can be used to transform vectors, but DotVecMat4x4 is faster if
84// you already have the matrix transpose.
85template <typename T>
87 NdArray<Simd<T, 4>, 4> const& m,
88 Simd<T, 4> v);
89
90/**************************************************************************************************
91 Vector-Matrix Dot Product
92*/
93
94// Dot product of (array, matrix). The result is a 1D array where the ith element is defined as the
95// dot product of 'a' and a column (1st dimension) of 'b'.
96template <typename T, size_t N, size_t M>
97[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, M> DotVecMat(
98 NdArray<T, N> const& a,
99 NdArray<T, N, M> const& b);
100
101// Dot product of (array, matrix). SIMD specialization using the first 2 components of each Vec4r.
102template <typename T>
104 Simd<T, 4> v,
105 NdArray<Simd<T, 4>, 2> const& m);
106
107// Dot product of (array, matrix). Input matrices can be VMatrix3x3r or VMatrix4x4r, but only the
108// upper-left 3x3 portion will be used. Output is a Vec4r where the last SIMD component is
109// undefined.
110template <typename T, size_t D0>
112 Simd<T, 4> v,
113 NdArray<Simd<T, 4>, D0> const& m);
114
115// Dot product of (array, matrix). Full SIMD specialization.
116template <typename T>
118 Simd<T, 4> a,
119 NdArray<Simd<T, 4>, 4> const& b);
120
121/**************************************************************************************************
122 Matrix-Matrix Dot Product
123*/
124
125// Dot product of 2 matrices
126template <typename T, size_t N, size_t M, size_t L>
127[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, L> Dot(
128 NdArray<T, N, M> const& a,
129 NdArray<T, M, L> const& B);
130
131// Dot product of 2 matrices. VMatrix4x4r specialization.
132template <typename T>
134 NdArray<Simd<T, 4>, 4> const& a,
135 NdArray<Simd<T, 4>, 4> const& b);
136
137// Dot product of (matrix, matrix). Input matrices can be VMatrix3x3r or VMatrix4x4r, but only the
138// upper-left 3x3 portion will be used. Output is a VMatrix3x3r where the last SIMD component of
139// each row is undefined.
140template <typename T, size_t D0A, size_t D0B>
142 NdArray<Simd<T, 4>, D0A> const& a,
143 NdArray<Simd<T, 4>, D0B> const& b);
144
145// Matrix-matrix product of 2x2 matrices.
146template <typename T>
147[[nodiscard]] MOCHI_FORCE_INLINE Simd<T, 4> Dot2x2(Simd<T, 4> const& a, Simd<T, 4> const& b);
148
149/**************************************************************************************************
150 Outer Product
151*/
152
153// Outer product of two 2x1 vectors returning a 2x2 matrix
154template <typename T>
155[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> Outer(
156 NdArray<T, 2> const& a,
157 NdArray<T, 2> const& b);
158
159// Outer product of two vectors, 3x1 and 1x2, returning a 3x2 matrix
160template <typename T>
161[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3, 2> Outer(
162 NdArray<T, 3> const& a,
163 NdArray<T, 2> const& b);
164
165// Outer product of two 3x1 vectors returning a 3x3 matrix
166template <typename T>
167[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3, 3> Outer(
168 NdArray<T, 3> const& a,
169 NdArray<T, 3> const& b);
170
171// Outer product of two 3x1 vectors returning a 3x3 matrix
172template <typename T>
174
175// Outer product of a 3x1 vector and a 3x3 matrix returning a 3x3x3 3rd-order tensor
176template <typename T>
177[[nodiscard]] NdArray<Simd<T, 4>, 3, 3> Outer3(
178 Simd<T, 4> const& vec,
179 NdArray<Simd<T, 4>, 3> const& mat);
180
181// Outer product of a 3x3 matrix and a 3x1 vector returning a 3x3x3 3rd-order tensor
182template <typename T>
183[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, 3, 3> Outer3(
184 NdArray<Simd<T, 4>, 3> const& mat,
185 Simd<T, 4> const& vec);
186
187// Outer product of a 3x3x3 tensor and a 3x1 vector returning a 3x3x3x3 4th-order tensor
188template <typename T>
189[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, 3, 3, 3> Outer3(
190 NdArray<Simd<T, 4>, 3, 3> const& ten,
191 Simd<T, 4> const& vec);
192
193// Outer product of a 3x1 vector and 3x3x3 tensor and returning a 3x3x3x3 4th-order tensor
194template <typename T>
195[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, 3, 3, 3> Outer3(
196 Simd<T, 4> const& vec,
197 NdArray<Simd<T, 4>, 3, 3> const& ten);
198
199// Outer product of two 3x3 matrices returning a 3x3x3x3 4th-order tensor
200template <typename T>
201[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, 3, 3, 3> Outer3(
202 NdArray<Simd<T, 4>, 3> const& mat0,
203 NdArray<Simd<T, 4>, 3> const& mat1);
204
205// Outer product of 3 component vectors, returning a symmetric 3x3 SIMD matrix (assumed 4th
206// component unused).
207template <typename T>
209
210// Outer product of two 2x2 matrices, each stored in row-major order as SIMD vectors, returning a
211// 2x2x2x2 4th-order tensor whose last two indices are packed into a single SIMD vector, with
212// row-major order. For `c = Outer2(a, b)`, we have `c[i][j][2*k + l] = a[2*i + j] * b[2*k + l]`,
213// corresponding to $c_{ijkl} = a_{ij} b_{kl}$ in mathematical index notation.
214template <typename T>
215[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, 2, 2> Outer2(
216 Simd<T, 4> const& a,
217 Simd<T, 4> const& b);
218
219/**************************************************************************************************
220 Inner Product
221*/
222
223// Colon product (Frobenius inner product) of two 3x3 SIMD matrices A and B, i.e. the sum of the
224// element-wise products A:B = \sum_{i,j} A_{ij} B_{ij}.
225template <typename T>
226[[nodiscard]] MOCHI_FORCE_INLINE T
227Colon3x3(NdArray<Simd<T, 4>, 3> const& A, NdArray<Simd<T, 4>, 3> const& B);
228
229// Colon product (Frobenius inner product) of two matrices A and B, i.e. the sum of the element-wise
230// products A:B = \sum_{i,j} A_{ij} B_{ij}.
231template <typename T, size_t N, size_t M>
232[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Colon(
233 NdArray<T, N, M> const& A,
234 NdArray<T, N, M> const& B);
235
236// Colon product (Frobenius inner product) of two symmetric 2x2 matrices stored as raw
237// [a00, a01, a11] components.
238template <typename T>
239[[nodiscard]] MOCHI_FORCE_INLINE constexpr T ColonSym2x2(
240 NdArray<T, 3> const& A,
241 NdArray<T, 3> const& B);
242
243/**************************************************************************************************
244 Invert
245*/
246
247// Invert 2x2 matrix
248template <typename T>
249[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> Invert(NdArray<T, 2, 2> const& a);
250
251// Invert 2x2 matrix when the determinant is known
252template <typename T>
253[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> Invert(
254 NdArray<T, 2, 2> const& a,
255 T det);
256
257// Invert 3x3 matrix
258template <typename T>
259[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3, 3> Invert(NdArray<T, 3, 3> const& a);
260
261// Invert 3x3 matrix when the determinant is known
262template <typename T>
263[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3, 3> Invert(
264 NdArray<T, 3, 3> const& a,
265 T det);
266
267// The left pseudoinverse of a 3x2 matrix
268template <typename T>
269void PseudoInvert(NdArray<T, 3, 2> const& a, NdArray<T, 2, 3>* outInv, T* outDet);
270
271// Invert a 4x4 matrix
272template <typename T>
273[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 4, 4> Invert(NdArray<T, 4, 4> const& A);
274
275// Invert a 4x4 SIMD matrix
276template <typename T>
277[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<Simd<T, 4>, 4> Invert4x4(
278 NdArray<Simd<T, 4>, 4> const& A);
279
280// Invert 3x3 SIMD matrix
281template <typename T>
283 NdArray<Simd<T, 4>, 3> const& mat);
284
285// Invert 3x3 SIMD matrix when the determinant is known
286template <typename T>
288 NdArray<Simd<T, 4>, 3> const& mat,
289 Simd<T, 4> det);
290
291// Invert 2x2 SIMD matrix when the determinant is known
292template <typename T>
293[[nodiscard]] MOCHI_FORCE_INLINE Simd<T, 4> Invert2x2(Simd<T, 4> const& mat, T det);
294
295// Invert a 3D transformation matrix consisting of scale, rotation, and translation only.
296// The matrix should be of the form:
297//
298// | Ax Bx Cx Tx | Where the first 3 columns are the orthogonal scaled basis vectors, and
299// | Ay By Cy Ty | the last column is the translation
300// | Az Bz Cz Tz |
301// | 0 0 0 1 |
302//
303template <typename T>
305 NdArray<Simd<T, 4>, 4> const& mat);
306
307// Invert a pre-transposed 3D transformation matrix consisting of scale, rotation, and translation
308// only. The input matrix should be of the form below. The result matrix will have the same form.
309//
310// | Ax Ay Az 0 | Where the first 3 rows are the orthogonal scaled basis vectors
311// | Bx By Bz 0 | The last row is the translation
312// | Cx Cy Cz 0 |
313// | Tx Ty Tz 1 |
314//
315template <typename T>
317 NdArray<Simd<T, 4>, 4> const& mat);
318
319/**************************************************************************************************
320 Matrix Builders
321*/
322
323// Return an NxN array with a given value down the diagonal. Equivalent to: (Eye<N, T>() *
324// valueOnDiagonal)
325template <size_t N, typename T>
326[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, N> DiagonalMatrix(T valueOnDiagonal);
327
328// Return an NxN array with a given array down the diagonal.
329template <size_t N, typename T>
331 NdArray<T, N> const& diagonalVector);
332
333// Return raw [a00, a01, a11] components of a symmetric 2x2 matrix.
334template <typename T>
335[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3> Sym2x2Components(T a00, T a01, T a11);
336
337// Return raw [a00, a01, a11] components of the symmetric part of a 2x2 matrix.
338template <typename T>
340 NdArray<T, 2, 2> const& m);
341
342// Construct a 2x2 symmetric matrix from upper-triangle components.
343// [a00 a01]
344// [a01 a11]
345template <typename T>
346[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> SymMatrix2x2(T a00, T a01, T a11);
347
348// Return an NxN array with 1s down the diagonal (an identity matrix).
349template <size_t N, typename T = real>
350[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, N> Eye();
351
352// Return an NxN array with a given value down the diagonal. Equivalent to: (Eye<N, T>() *
353// valueOnDiagonal)
354template <size_t N, typename T>
355[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, N> VDiagonalMatrix(T valueOnDiagonal);
356
357// Return an NxN array with a given array down the diagonal.
358template <size_t N, typename T>
360 Simd<T, 4> const& diagonalVector);
361
362// Return an NxN array with 1s down the diagonal (an identity matrix).
363template <size_t N, typename T = real>
364[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, N> VEye();
365
366/**************************************************************************************************
367 Matrix Determinant
368*/
369
370// Determinant of 2x2 matrix.
371template <typename T>
372[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Det(NdArray<T, 2, 2> const& A);
373
374// Determinant of 3x3 matrix.
375template <typename T>
376[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Det(NdArray<T, 3, 3> const& A);
377
378// Determinant of the upper-left 3x3 of a SIMD matrix.
379template <typename T, size_t N>
380[[nodiscard]] MOCHI_FORCE_INLINE T
381Det3x3(NdArray<Simd<T, 4>, N> const& A); // Ignores the last SIMD column
382
383// Same as Det3x3 except that it returns Simd<T, 4>{det, det, det, det}
384template <typename T, size_t N>
385[[nodiscard]] MOCHI_FORCE_INLINE Simd<T, 4> VDet3x3(NdArray<Simd<T, 4>, N> const& A);
386
387template <typename T>
388[[nodiscard]] MOCHI_FORCE_INLINE T Det2x2(Simd<T, 4> const& A);
389
390/**************************************************************************************************
391 Matrix Transpose
392*/
393
394// Transpose matrix NxM
395template <typename T, size_t N, size_t M>
396[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, M, N> Transpose(NdArray<T, N, M> const& mat);
397
398// Transpose matrix 4x4 (SIMD)
399template <typename T>
401 NdArray<Simd<T, 4>, 4> const& m);
402
403// Transpose a 2x2 SIMD matrix stored in row-major order as a single Simd<T, 4>.
404template <typename T>
406
407// Transpose the upper-left 3x3 portion of a SIMD matrix. The 4th column will be filled by m[2][3].
408// Thus, if the 4th column was all zeros, then the 4th column of the transpose will also be all
409// zeros. Input matrix can have have 3 or 4 rows.
410template <typename T, size_t D0>
412 NdArray<Simd<T, 4>, D0> const& m);
413
414/**************************************************************************************************
415 Matrix Cofactor
416*/
417
418template <typename T>
419[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> Cofactor(NdArray<T, 2, 2> const& mat);
420
421template <typename T>
422[[nodiscard]] inline constexpr NdArray<T, 3, 3> Cofactor(NdArray<T, 3, 3> const& mat);
423
424template <typename T>
425[[nodiscard]] NdArray<Simd<T, 4>, 3> Cofactor3x3(
426 NdArray<Simd<T, 4>, 3> const& mat); // Ignores the last SIMD column
427
428template <typename T>
430
431template <typename T>
433 NdArray<Simd<T, 4>, 2> const& mat);
434
435/**************************************************************************************************
436 Matrix Trace (sum of diagonal elements)
437*/
438template <typename T, size_t DimTotal = 3, size_t DimTrace = DimTotal>
439[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Trace(NdArray<T, DimTotal, DimTotal> const& mat);
440
441template <typename T>
442[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Trace2x2(Simd<T, 4> const& mat);
443
444template <typename T>
445[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Trace3x3(NdArray<Simd<T, 4>, 3> const& mat);
446
447/**************************************************************************************************
448 Skew-symmetric matrix
449*/
450
451// Return the 3x3 skew-symmetric matrix [v] of a vector v, s.t. [v] * u = v x u, [v] = -[v]^T.
452template <typename T>
453[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3, 3> Skew(NdArray<T, 3> const& v);
454
455// Return the 3x3 skew-symmetric matrix [v] of a vector v, s.t. [v] * u = v x u, [v] = -[v]^T.
456template <typename T>
457[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<Simd<T, 4>, 3> Skew3(Simd<T, 4> const& vector);
458
459// Return the vector v s.t. skew(v) is the anti-symmetric part of the input matrix
460template <typename T>
461[[nodiscard]] MOCHI_FORCE_INLINE constexpr Simd<T, 4> InvSkew3(
462 NdArray<Simd<T, 4>, 3> const& matrix);
463
464// Computes the first derivative of Skew(v)
465template <typename T = real>
466[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, 3, 3> VDSkew3();
467
468/**************************************************************************************************
469 Vector Derivatives
470*/
471
472// Derivative of normalized 3-vector w.r.t. vector. Returns a 3x3 matrix representing dv_hat/dv,
473// where v_hat = v / ||v||.
474template <typename T>
476
477// Derivative of normalized N-vector w.r.t. vector. Returns an NxN matrix representing dv_hat/dv,
478// where v_hat = v / ||v||.
479template <typename T, size_t N>
480[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, N> DNormalize(NdArray<T, N> const& v);
481
482// Derivative of normalized N-vector w.r.t. vector with precomputed squared norm. Returns an NxN
483// matrix representing dv_hat/dv, where v_hat = v / ||v||.
484template <typename T, size_t N>
485[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, N> DNormalize(
486 NdArray<T, N> const& v,
487 T sqrNorm);
488
489/**************************************************************************************************
490 Matrix Row/Column Selection
491*/
492
493// Retrieves the largest row (in the L-2 sense) of the given matrix. Optionally outputs
494// its squared norm.
495template <typename T, size_t D0, size_t D1>
496[[nodiscard]] constexpr auto LargestRow(NdArray<T, D0, D1> const& A, T* sqrNorm = nullptr);
497
498// Retrieves the largest row/col (in the L-2 sense) of the given symmetric matrix.
499// Optionally outputs its squared norm.
500[[nodiscard]] auto LargestRowColSym2x2(VSymMatrix2x2r A, Vec4r& outNormSqr);
501
502// Retrieves the largest row/col (in the L-2 sense) of the given symmetric matrix.
503// Optionally outputs its squared norm.
504[[nodiscard]] auto LargestRowColSym3x3(VSymMatrix3x3r A, Vec4r& outNormSqr);
505
506} // namespace superdex
507
508#include "matrix_utils_inl.h"
#define MOCHI_FORCE_INLINE
constexpr NdArray< T, M > DotVecMat(NdArray< T, N > const &a, NdArray< T, N, M > const &b)
T Dot(Simd< T, N > a, Simd< T, N > b)
Definition simd.h:673
constexpr T Trace(NdArray< T, DimTotal, DimTotal > const &mat)
constexpr NdArray< T, N, N > DNormalize(NdArray< T, N > const &v)
constexpr NdArray< T, 2, 2 > SymMatrix2x2(T a00, T a01, T a11)
NdArray< Simd< T, 4 >, 3 > DNormalize3(Simd< T, 4 > const &v)
Simd< T, 4 > Transpose2x2(Simd< T, 4 > const &m)
constexpr NdArray< T, 3 > Sym2x2Components(T a00, T a01, T a11)
T NormSqr(Simd< T, N > a)
Definition simd_inl.h:874
NdArray< Simd< T, 4 >, 3 > Cofactor3x3(NdArray< Simd< T, 4 >, 3 > const &mat)
Simd< T, 4 > DotVecMat4x4(Simd< T, 4 > a, NdArray< Simd< T, 4 >, 4 > const &b)
Simd< T, 4 > Invert2x2(Simd< T, 4 > const &mat, T det)
NdArray< Simd< T, 4 >, 4 > InvertTransformation(NdArray< Simd< T, 4 >, 4 > const &mat)
constexpr Simd< T, 4 > InvSkew3(NdArray< Simd< T, 4 >, 3 > const &matrix)
T Norm(Simd< T, N > a)
Definition simd_inl.h:879
T Det2x2(Simd< T, 4 > const &A)
Simd< T, 4 > DotMatVec3xN(NdArray< Simd< T, 4 >, D0 > const &m, Simd< T, 4 > v)
constexpr auto LargestRow(NdArray< T, D0, D1 > const &A, T *sqrNorm=nullptr)
NdArray< Simd< T, 4 >, 3, 3 > VDSkew3()
constexpr NdArray< T, N > DotMatVec(NdArray< T, N, M > const &a, NdArray< T, M > const &b)
Simd< T, 4 > DotMatVec4x4(NdArray< Simd< T, 4 >, 4 > const &m, Simd< T, 4 > v)
NdArray< Simd< T, 4 >, 3 > Transpose3x3(NdArray< Simd< T, 4 >, D0 > const &m)
Simd< real, 4 > Vec4r
Definition simd.h:206
NdArray< Simd< T, 4 >, 2 > CofactorSym3x3(NdArray< Simd< T, 4 >, 2 > const &mat)
NdArray< Simd< T, 4 >, 4 > InvertTransformationTransposed(NdArray< Simd< T, 4 >, 4 > const &mat)
Simd< real, 4 > VSymMatrix2x2r
Special case for the SIMD representation of a 2x2 symmetric matrix.
Definition vmatrix.h:84
constexpr NdArray< T, M, N > Transpose(NdArray< T, N, M > const &mat)
auto LargestRowColSym2x2(VSymMatrix2x2r A, Vec4r &outNormSqr)
constexpr NdArray< T, N, N > Eye()
TransformRT Invert(TransformRT const &a)
Simd< T, 4 > DotVecMat3x3(Simd< T, 4 > v, NdArray< Simd< T, 4 >, D0 > const &m)
constexpr T Colon(NdArray< T, N, M > const &A, NdArray< T, N, M > const &B)
Simd< T, 4 > DotVecMat2x3(Simd< T, 4 > v, NdArray< Simd< T, 4 >, 2 > const &m)
NdArray< Simd< T, 4 >, 4 > Transpose4x4(NdArray< Simd< T, 4 >, 4 > const &m)
NdArray< Simd< T, 4 >, 2, 2 > Outer2(Simd< T, 4 > const &a, Simd< T, 4 > const &b)
void PseudoInvert(NdArray< T, 3, 2 > const &a, NdArray< T, 2, 3 > *outInv, T *outDet)
NdArray< Simd< T, 4 >, 4 > Dot4x4(NdArray< Simd< T, 4 >, 4 > const &a, NdArray< Simd< T, 4 >, 4 > const &b)
T Colon3x3(NdArray< Simd< T, 4 >, 3 > const &A, NdArray< Simd< T, 4 >, 3 > const &B)
NdArray< Simd< T, 4 >, 2 > OuterSym3(Simd< T, 4 > a, Simd< T, 4 > b)
auto LargestRowColSym3x3(VSymMatrix3x3r A, Vec4r &outNormSqr)
Simd< T, 4 > DotMatVec3x3(NdArray< Simd< T, 4 >, D0 > const &m, Simd< T, 4 > v)
Simd< T, 4 > Dot2x2(Simd< T, 4 > const &a, Simd< T, 4 > const &b)
constexpr NdArray< T, 3, 3 > Skew(NdArray< T, 3 > const &v)
constexpr NdArray< Simd< T, 4 >, 3 > Skew3(Simd< T, 4 > const &vector)
NdArray< Simd< T, 4 >, 3 > Invert3x3(NdArray< Simd< T, 4 >, 3 > const &mat)
constexpr NdArray< T, 2, 2 > Cofactor(NdArray< T, 2, 2 > const &mat)
T Norm3x3(NdArray< Simd< T, D1 >, D0 > const &a)
T NormSqr3x3(NdArray< Simd< T, D1 >, D0 > const &a)
Simd< T, 4 > CofactorSym2x2(Simd< T, 4 > const &mat)
constexpr NdArray< T, 2, 2 > Outer(NdArray< T, 2 > const &a, NdArray< T, 2 > const &b)
constexpr T Trace3x3(NdArray< Simd< T, 4 >, 3 > const &mat)
NdArray< Simd< T, 4 >, 3 > Outer3(Simd< T, 4 > a, Simd< T, 4 > b)
constexpr T ColonSym2x2(NdArray< T, 3 > const &A, NdArray< T, 3 > const &B)
NdArray< Simd< real, 4 >, 2 > VSymMatrix3x3r
Special case for the SIMD representation of a 3x3 symmetric matrix.
Definition vmatrix.h:96
NdArray< Simd< T, 4 >, N > VEye()
constexpr T Det(NdArray< T, 2, 2 > const &A)
constexpr NdArray< T, N, N > DiagonalMatrix(T valueOnDiagonal)
NdArray< Simd< T, 4 >, N > VDiagonalMatrix(T valueOnDiagonal)
constexpr T Trace2x2(Simd< T, 4 > const &mat)
T Det3x3(NdArray< Simd< T, 4 >, N > const &A)
constexpr NdArray< Simd< T, 4 >, 4 > Invert4x4(NdArray< Simd< T, 4 >, 4 > const &A)
Simd< T, 4 > VDet3x3(NdArray< Simd< T, 4 >, N > const &A)
NdArray< Simd< T, 4 >, 3 > Dot3x3(NdArray< Simd< T, 4 >, D0A > const &a, NdArray< Simd< T, 4 >, D0B > const &b)