16template<
int N,
typename SampleType =
float>
18 std::array<SampleType, N * N>
data{};
20 SampleType&
at(
int row,
int col) {
return data[row * N + col]; }
21 SampleType
at(
int row,
int col)
const {
return data[row * N + col]; }
24 SampleType
operator()(
int row,
int col)
const {
return at(row, col); }
29 for (
int i = 0;
i < N; ++
i)
30 m.at(
i,
i) = SampleType{1.0f};
40 for (
int i = 0;
i < N; ++
i)
41 for (
int j = 0; j < N; ++j)
42 for (
int k = 0; k < N; ++k)
43 result.
at(
i, j) +=
at(
i, k) * other.at(k, j);
50 for (
int i = 0;
i < N * N; ++
i)
58 for (
int i = 0;
i < N * N; ++
i)
66 for (
int i = 0;
i < N; ++
i)
67 for (
int j = 0; j < N; ++j)
68 result.
at(j,
i) =
at(
i, j);
83template <
typename SampleType>
85 return m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0);
89template <
typename SampleType>
91 return m(0, 0) * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1))
92 - m(0, 1) * (m(1, 0) * m(2, 2) - m(1, 2) * m(2, 0))
93 + m(0, 2) * (m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0));
117 float c = std::cos(radians), s = std::sin(radians);
118 m(1, 1) =
c; m(1, 2) = -s;
119 m(2, 1) = s; m(2, 2) =
c;
126 float c = std::cos(radians), s = std::sin(radians);
127 m(0, 0) =
c; m(0, 2) = s;
128 m(2, 0) = -s; m(2, 2) =
c;
135 float c = std::cos(radians), s = std::sin(radians);
136 m(0, 0) =
c; m(0, 1) = -s;
137 m(1, 0) = s; m(1, 1) =
c;
143 float x = 0,
y = 0,
z = 0;
148 m(0, 0) * v.x + m(0, 1) * v.y + m(0, 2) * v.z + m(0, 3),
149 m(1, 0) * v.x + m(1, 1) * v.y + m(1, 2) * v.z + m(1, 3),
150 m(2, 0) * v.x + m(2, 1) * v.y + m(2, 2) * v.z + m(2, 3)
Definition additive_bank.hpp:218
Matrix< 3, double > Matrix3d
Definition matrix.hpp:79
Matrix< 2, double > Matrix2d
Definition matrix.hpp:78
Matrix< 4 > Matrix4
Definition matrix.hpp:77
Matrix< 2 > Matrix2
Definition matrix.hpp:75
@ c
Definition spectrum_trace.hpp:35
Matrix4 rotation_z(float radians)
4x4 rotation around Z axis
Definition matrix.hpp:133
Matrix4 rotation_y(float radians)
4x4 rotation around Y axis
Definition matrix.hpp:124
Matrix4 scale_matrix(float sx, float sy, float sz)
4x4 scale matrix
Definition matrix.hpp:106
Matrix4 translation_matrix(float x, float y, float z)
4x4 translation matrix
Definition matrix.hpp:97
Matrix< 3 > Matrix3
Definition matrix.hpp:76
Matrix< 4, double > Matrix4d
Definition matrix.hpp:80
SampleType determinant(const Matrix< 2, SampleType > &m)
Determinant of a 2x2 matrix.
Definition matrix.hpp:84
@ i
Definition formant_filter_bank.hpp:20
Vec3 transform(const Matrix4 &m, const Vec3 &v)
Definition matrix.hpp:146
Matrix4 rotation_x(float radians)
4x4 rotation around X axis
Definition matrix.hpp:115
NxN matrix stored in row-major order.
Definition matrix.hpp:17
Matrix operator*(const Matrix &other) const
Matrix multiply.
Definition matrix.hpp:38
static Matrix zero()
Zero matrix.
Definition matrix.hpp:35
std::array< float, N *N > data
Definition matrix.hpp:18
Matrix operator*(SampleType scalar) const
Scalar multiply.
Definition matrix.hpp:48
SampleType at(int row, int col) const
Definition matrix.hpp:21
Matrix operator+(const Matrix &other) const
Matrix add.
Definition matrix.hpp:56
SampleType operator()(int row, int col) const
Definition matrix.hpp:24
static Matrix identity()
Identity matrix.
Definition matrix.hpp:27
Matrix transposed() const
Transpose.
Definition matrix.hpp:64
SampleType & operator()(int row, int col)
Definition matrix.hpp:23
bool operator==(const Matrix &other) const
Definition matrix.hpp:72
SampleType & at(int row, int col)
Definition matrix.hpp:20
Transform a 3D vector by a 4x4 matrix (assumes w=1).
Definition matrix.hpp:142
float x
Definition matrix.hpp:143
float y
Definition matrix.hpp:143
float z
Definition matrix.hpp:143