src/matrix2i.c file

Functions

auto mat2i_identity(void) -> matrix2i
Constructs the 2x2 integer identity matrix.
auto mat2i_mul(matrix2i a, matrix2i b) -> matrix2i
Multiplies two 2x2 integer matrices (a * b).
auto mat2i_transpose(matrix2i m) -> matrix2i
Computes the transpose of a 2x2 integer matrix.
auto mat2i_inverse(matrix2i m) -> matrix2i
Computes the inverse of a 2x2 integer matrix.
auto mat2i_determinant(matrix2i m) -> vm_int_t
Calculates the determinant of the given 2x2 integer matrix.
auto mat2i_mul_vec2i(matrix2i m, vector2i v) -> vector2i
Multiplies a 2x2 integer matrix by a vector2i.

Function documentation

matrix2i mat2i_identity(void)

Constructs the 2x2 integer identity matrix.

Returns The identity matrix2i.

matrix2i mat2i_mul(matrix2i a, matrix2i b)

Multiplies two 2x2 integer matrices (a * b).

Parameters
a The first matrix.
b The second matrix.
Returns The resulting product matrix2i.

Column-major product AB so (AB)v == A(Bv) (column vector on the right).

matrix2i mat2i_transpose(matrix2i m)

Computes the transpose of a 2x2 integer matrix.

Parameters
m The input matrix.
Returns The transposed matrix2i.

matrix2i mat2i_inverse(matrix2i m)

Computes the inverse of a 2x2 integer matrix.

Parameters
m The input matrix.
Returns The inverse matrix2i.

Truncated integer inverse (not a modular inverse).

vm_int_t mat2i_determinant(matrix2i m)

Calculates the determinant of the given 2x2 integer matrix.

Parameters
m The matrix.
Returns The determinant value (m.v[0]*m.v[3] - m.v[1]*m.v[2]).

vector2i mat2i_mul_vec2i(matrix2i m, vector2i v)

Multiplies a 2x2 integer matrix by a vector2i.

Parameters
m Input matrix.
v Input vector.
Returns The resulting vector2i.