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/**************************************************************************************************
237 Invert
238*/
239
240// Invert 2x2 matrix
241template <typename T>
242[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> Invert(NdArray<T, 2, 2> const& a);
243
244// Invert 2x2 matrix when the determinant is known
245template <typename T>
246[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> Invert(
247 NdArray<T, 2, 2> const& a,
248 T det);
249
250// Invert 3x3 matrix
251template <typename T>
252[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3, 3> Invert(NdArray<T, 3, 3> const& a);
253
254// Invert 3x3 matrix when the determinant is known
255template <typename T>
256[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3, 3> Invert(
257 NdArray<T, 3, 3> const& a,
258 T det);
259
260// The left pseudoinverse of a 3x2 matrix
261template <typename T>
262void PseudoInvert(NdArray<T, 3, 2> const& a, NdArray<T, 2, 3>* outInv, T* outDet);
263
264// Invert a 4x4 matrix
265template <typename T>
266[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 4, 4> Invert(NdArray<T, 4, 4> const& A);
267
268// Invert a 4x4 SIMD matrix
269template <typename T>
270[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<Simd<T, 4>, 4> Invert4x4(
271 NdArray<Simd<T, 4>, 4> const& A);
272
273// Invert 3x3 SIMD matrix
274template <typename T>
276 NdArray<Simd<T, 4>, 3> const& mat);
277
278// Invert 3x3 SIMD matrix when the determinant is known
279template <typename T>
281 NdArray<Simd<T, 4>, 3> const& mat,
282 Simd<T, 4> det);
283
284// Invert 2x2 SIMD matrix when the determinant is known
285template <typename T>
286[[nodiscard]] MOCHI_FORCE_INLINE Simd<T, 4> Invert2x2(Simd<T, 4> const& mat, T det);
287
288// Invert a 3D transformation matrix consisting of scale, rotation, and translation only.
289// The matrix should be of the form:
290//
291// | Ax Bx Cx Tx | Where the first 3 columns are the orthogonal scaled basis vectors, and
292// | Ay By Cy Ty | the last column is the translation
293// | Az Bz Cz Tz |
294// | 0 0 0 1 |
295//
296template <typename T>
298 NdArray<Simd<T, 4>, 4> const& mat);
299
300// Invert a pre-transposed 3D transformation matrix consisting of scale, rotation, and translation
301// only. The input matrix should be of the form below. The result matrix will have the same form.
302//
303// | Ax Ay Az 0 | Where the first 3 rows are the orthogonal scaled basis vectors
304// | Bx By Bz 0 | The last row is the translation
305// | Cx Cy Cz 0 |
306// | Tx Ty Tz 1 |
307//
308template <typename T>
310 NdArray<Simd<T, 4>, 4> const& mat);
311
312/**************************************************************************************************
313 Matrix Builders
314*/
315
316// Return an NxN array with a given value down the diagonal. Equivalent to: (Eye<N, T>() *
317// valueOnDiagonal)
318template <size_t N, typename T>
319[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, N> DiagonalMatrix(T valueOnDiagonal);
320
321// Return an NxN array with a given array down the diagonal.
322template <size_t N, typename T>
324 NdArray<T, N> const& diagonalVector);
325
326// Construct a 2x2 symmetric matrix from upper-triangle components.
327// [a00 a01]
328// [a01 a11]
329template <typename T>
330[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> SymMatrix2x2(T a00, T a01, T a11);
331
332// Return an NxN array with 1s down the diagonal (an identity matrix).
333template <size_t N, typename T = real>
334[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, N> Eye();
335
336// Return an NxN array with a given value down the diagonal. Equivalent to: (Eye<N, T>() *
337// valueOnDiagonal)
338template <size_t N, typename T>
339[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, N> VDiagonalMatrix(T valueOnDiagonal);
340
341// Return an NxN array with a given array down the diagonal.
342template <size_t N, typename T>
344 Simd<T, 4> const& diagonalVector);
345
346// Return an NxN array with 1s down the diagonal (an identity matrix).
347template <size_t N, typename T = real>
348[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, N> VEye();
349
350/**************************************************************************************************
351 Matrix Determinant
352*/
353
354// Determinant of 2x2 matrix.
355template <typename T>
356[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Det(NdArray<T, 2, 2> const& A);
357
358// Determinant of 3x3 matrix.
359template <typename T>
360[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Det(NdArray<T, 3, 3> const& A);
361
362// Determinant of the upper-left 3x3 of a SIMD matrix.
363template <typename T, size_t N>
364[[nodiscard]] MOCHI_FORCE_INLINE T
365Det3x3(NdArray<Simd<T, 4>, N> const& A); // Ignores the last SIMD column
366
367// Same as Det3x3 except that it returns Simd<T, 4>{det, det, det, det}
368template <typename T, size_t N>
369[[nodiscard]] MOCHI_FORCE_INLINE Simd<T, 4> VDet3x3(NdArray<Simd<T, 4>, N> const& A);
370
371template <typename T>
372[[nodiscard]] MOCHI_FORCE_INLINE T Det2x2(Simd<T, 4> const& A);
373
374/**************************************************************************************************
375 Matrix Transpose
376*/
377
378// Transpose matrix NxM
379template <typename T, size_t N, size_t M>
380[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, M, N> Transpose(NdArray<T, N, M> const& mat);
381
382// Transpose matrix 4x4 (SIMD)
383template <typename T>
385 NdArray<Simd<T, 4>, 4> const& m);
386
387// Transpose a 2x2 SIMD matrix stored in row-major order as a single Simd<T, 4>.
388template <typename T>
390
391// Transpose the upper-left 3x3 portion of a SIMD matrix. The 4th column will be filled by m[2][3].
392// Thus, if the 4th column was all zeros, then the 4th column of the transpose will also be all
393// zeros. Input matrix can have have 3 or 4 rows.
394template <typename T, size_t D0>
396 NdArray<Simd<T, 4>, D0> const& m);
397
398/**************************************************************************************************
399 Matrix Cofactor
400*/
401
402template <typename T>
403[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 2, 2> Cofactor(NdArray<T, 2, 2> const& mat);
404
405template <typename T>
406[[nodiscard]] inline constexpr NdArray<T, 3, 3> Cofactor(NdArray<T, 3, 3> const& mat);
407
408template <typename T>
409[[nodiscard]] NdArray<Simd<T, 4>, 3> Cofactor3x3(
410 NdArray<Simd<T, 4>, 3> const& mat); // Ignores the last SIMD column
411
412template <typename T>
414
415template <typename T>
417 NdArray<Simd<T, 4>, 2> const& mat);
418
419/**************************************************************************************************
420 Matrix Trace (sum of diagonal elements)
421*/
422template <typename T, size_t DimTotal = 3, size_t DimTrace = DimTotal>
423[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Trace(NdArray<T, DimTotal, DimTotal> const& mat);
424
425template <typename T>
426[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Trace2x2(Simd<T, 4> const& mat);
427
428template <typename T>
429[[nodiscard]] MOCHI_FORCE_INLINE constexpr T Trace3x3(NdArray<Simd<T, 4>, 3> const& mat);
430
431/**************************************************************************************************
432 Skew-symmetric matrix
433*/
434
435// Return the 3x3 skew-symmetric matrix [v] of a vector v, s.t. [v] * u = v x u, [v] = -[v]^T.
436template <typename T>
437[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, 3, 3> Skew(NdArray<T, 3> const& v);
438
439// Return the 3x3 skew-symmetric matrix [v] of a vector v, s.t. [v] * u = v x u, [v] = -[v]^T.
440template <typename T>
441[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<Simd<T, 4>, 3> Skew3(Simd<T, 4> const& vector);
442
443// Return the vector v s.t. skew(v) is the anti-symmetric part of the input matrix
444template <typename T>
445[[nodiscard]] MOCHI_FORCE_INLINE constexpr Simd<T, 4> InvSkew3(
446 NdArray<Simd<T, 4>, 3> const& matrix);
447
448// Computes the first derivative of Skew(v)
449template <typename T = real>
450[[nodiscard]] MOCHI_FORCE_INLINE NdArray<Simd<T, 4>, 3, 3> VDSkew3();
451
452/**************************************************************************************************
453 Vector Derivatives
454*/
455
456// Derivative of normalized 3-vector w.r.t. vector. Returns a 3x3 matrix representing dv_hat/dv,
457// where v_hat = v / ||v||.
458template <typename T>
460
461// Derivative of normalized N-vector w.r.t. vector. Returns an NxN matrix representing dv_hat/dv,
462// where v_hat = v / ||v||.
463template <typename T, size_t N>
464[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, N> DNormalize(NdArray<T, N> const& v);
465
466// Derivative of normalized N-vector w.r.t. vector with precomputed squared norm. Returns an NxN
467// matrix representing dv_hat/dv, where v_hat = v / ||v||.
468template <typename T, size_t N>
469[[nodiscard]] MOCHI_FORCE_INLINE constexpr NdArray<T, N, N> DNormalize(
470 NdArray<T, N> const& v,
471 T sqrNorm);
472
473/**************************************************************************************************
474 Matrix Row/Column Selection
475*/
476
477// Retrieves the largest row (in the L-2 sense) of the given matrix. Optionally outputs
478// its squared norm.
479template <typename T, size_t D0, size_t D1>
480[[nodiscard]] constexpr auto LargestRow(NdArray<T, D0, D1> const& A, T* sqrNorm = nullptr);
481
482// Retrieves the largest row/col (in the L-2 sense) of the given symmetric matrix.
483// Optionally outputs its squared norm.
484[[nodiscard]] auto LargestRowColSym2x2(VSymMatrix2x2r A, Vec4r& outNormSqr);
485
486// Retrieves the largest row/col (in the L-2 sense) of the given symmetric matrix.
487// Optionally outputs its squared norm.
488[[nodiscard]] auto LargestRowColSym3x3(VSymMatrix3x3r A, Vec4r& outNormSqr);
489
490} // namespace superdex
491
492#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:666
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)
T NormSqr(Simd< T, N > a)
Definition simd_inl.h:849
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:854
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)
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)