Struct Mat
Matrix type for linear algebra
struct Mat(T, ulong R, ulong C)
;
Constructors
Name | Description |
---|---|
this
(args)
|
Build a matrix from its elements. To be provided row major. |
this
(args)
|
Build a matrix from the provided rows. Each row must be an array (static or dynamic) and have the correct number of elements. |
Fields
Name | Type | Description |
---|---|---|
_rep
|
T[R*C] |
Properties
Name | Type | Description |
---|---|---|
compTup [get]
|
Tuple!CompSeq | All components in a tuple |
ct [get]
|
Mat | Index a component at compile time |
ct [get]
|
Mat | Index a row at compile time |
ctCol [get]
|
Mat | Index a column at compile time |
ctIndex [get]
|
auto | |
data [get]
|
inout(Mat | Direct access to underlying data. |
identityCode [get]
|
string | |
rowTup [get]
|
Tuple!RowSeq | All rows in a tuple |
slice [get]
|
Mat!(T,RE-RS,CE-CS) | Return a slice of the matrix |
slice [set]
|
Mat!(U,UR,UC) | Assign a slice of this matrix |
Methods
Name | Description |
---|---|
column
(c)
|
Index a matrix column. |
comp
(r, c)
|
Index a matrix component |
ct
(comp)
|
Assign a compile time indexed component |
ct
(row)
|
Assign a row indexed at compile time |
ctCol
(col)
|
Assign a column indexed at compile time |
index
(r, c)
|
|
opBinary
(mat)
|
Build an augmented matrix (add oth to the right of this matrix) |
opBinary
(oth)
|
Add/Subtract by a matrix to its right. |
opBinary
(oth)
|
Multiply by a matrix to its right. |
opBinary
(vec)
|
Multiply a matrix by a vector to its right. |
opBinary
(val)
|
Operation of a matrix with a scalar on its right. |
opBinaryRight
(vec)
|
Multiply a matrix by a vector to its left. |
opBinaryRight
(val)
|
Operation of a matrix with a scalar on its left. |
opCast
()
|
Cast a matrix to another type |
opDollar
()
|
Number of components per direction. |
opIndex
(r, c)
|
Index a matrix component. |
opIndex
(r)
|
Index a matrix row |
opIndexAssign
(val, r, c)
|
Assign a matrix component. |
opIndexAssign
(row, r)
|
Assign a row |
opIndexOpAssign
(val, r, c)
|
Apply op on a matrix component. |
opOpAssign
(val)
|
Assign operation of a matrix with a scalar on its right. |
opOpAssign
(mat)
|
Assign operation of a matrix with a matrix on its right. |
row
(r)
|
Index a matrix row. |
simdScalarOp
(res, val)
|
|
toString
()
|
Aliases
Name | Description |
---|---|
Column
|
The matrix columns type. |
Component
|
The type of the componetypeof(rt.expand)nts. |
CompSeq
|
Alias to a type sequence holding all components |
Row
|
The matrix rows type. |
RowSeq
|
Alias to a type sequence holding all rows |
Example
import gfx .math .approx : approxUlp;
assert(approxUlp(FMat2x2 .identity, FMat2x2(
1, 0,
0, 1
)));
Example
import gfx .math .approx : approxUlp;
immutable ml = Mat!(float, 2, 3)(
1, 2, 3,
4, 5, 6,
);
immutable mr = Mat!(float, 3, 2)(
1, 2,
3, 4,
5, 6,
);
immutable exp = Mat!(float, 2, 2)(
1+6+15, 2+8+18,
4+15+30, 8+20+36
);
assert(approxUlp(ml * mr, exp));