include/vecmat/types.h file

Public value types: vectors, matrices, quaternion, clip/layout enums, extras structs.

Classes

struct vector2
2-D floating-point vector (x, y).
struct vector3
3-D floating-point vector (x, y, z).
struct vector4
4-D floating-point vector (x, y, z, w).
struct vector2i
2-D integer vector (x, y).
struct vector3i
3-D integer vector (x, y, z).
struct vector4i
4-D integer vector (x, y, z, w).
struct matrix2
2x2 column-major floating-point matrix.
struct matrix3
3x3 column-major floating-point matrix.
struct matrix4
4x4 column-major floating-point matrix.
struct matrix2i
2x2 column-major integer matrix.
struct matrix3i
3x3 column-major integer matrix.
struct matrix4i
4x4 column-major integer matrix.
struct quaternion
Rotation quaternion (vector part x,y,z, scalar part w).
struct vm_mat
Heap dense matrix used by LU / QR / SVD / Cholesky / det / inverse.
struct vm_spmat
Heap sparse matrix in compressed sparse row (CSR) form.
struct vm_ksp_info
Iteration stats from vm_cg / vm_bicgstab.
struct vm_grid3
Uniform Cartesian grid.

Enums

enum vm_clip_t { VM_CLIP_RH_NO = 0, VM_CLIP_RH_ZO, VM_CLIP_LH_ZO, VM_CLIP_LH_NO }
Clip-space handedness and depth range for projection / look-at matrices.
enum vm_layout_t { VM_LAYOUT_COL_MAJOR = 0, VM_LAYOUT_ROW_MAJOR = 1 }
Memory layout for dense panels passed to vm_gemm and vm_mat.
enum (anonymous) { VM_GEMM_OP_NONE = 0, VM_GEMM_OP_BIAS = 1, VM_GEMM_OP_RELU = 2, VM_GEMM_OP_BIAS_RELU = 3 }
Optional GEMM epilogue.
enum vm_ksp_prec_t { VM_KSP_PREC_NONE = 0, VM_KSP_PREC_JACOBI = 1, VM_KSP_PREC_SSOR = 2, VM_KSP_PREC_IC0 = 3 }
Left preconditioner for the Krylov solvers.
enum vm_bc_t { VM_BC_DIRICHLET = 0, VM_BC_NEUMANN = 1 }
Boundary condition for assembled grid operators.

Typedefs

using vm_ode_fn = void(*)(const vm_float_t*y, vm_float_t*ydot, void*ctx)
First-order ODE right-hand side ydot = f(y).
using vm_acc_fn = void(*)(const vm_float_t*x, vm_float_t*a, void*ctx)
Acceleration callback a = acc(x) for velocity Verlet.

Defines

#define VM_CLIP_OPENGL
#define VM_CLIP_VULKAN
#define VM_CLIP_DIRECTX
#define FLOAT_EQ(a, b, eps)
Checks if two floats are approximately equal within tolerance.
#define DOUBLE_EQ(a, b, eps)
Checks if two doubles are approximately equal within tolerance.
#define VECMAT_EPSILON
#define VECMAT_EQ(a, b, eps)
#define VECMAT_FABS(x)
#define VECMAT_SQRT(x)
#define VECMAT_SIN(x)
#define VECMAT_COS(x)
#define VECMAT_TAN(x)
#define VECMAT_ASIN(x)
#define VECMAT_ACOS(x)
#define VECMAT_ATAN(x)
#define VECMAT_ATAN2(y, x)
#define VECMAT_FMIN(a, b)
#define VECMAT_FMAX(a, b)
#define VECMAT_FLOOR(x)
#define VECMAT_CEIL(x)
#define VECMAT_ROUND(x)
#define VECMAT_POW(x, y)
#define VECMAT_COPYSIGN(x, y)

Enum documentation

enum vm_clip_t

Clip-space handedness and depth range for projection / look-at matrices.

Historic mat4_perspective / mat4_look_at / mat4_ortho stay OpenGL right-handed with z in [-1, 1] (VM_CLIP_RH_NO). Perspective FOV and rotation angles are in radians; use the _deg suffix for degrees.

Enumerators
VM_CLIP_RH_NO

OpenGL: right-handed, clip z in [-1, 1].

VM_CLIP_RH_ZO

Vulkan: right-handed, clip z in [0, 1].

VM_CLIP_LH_ZO

Direct3D: left-handed, clip z in [0, 1].

VM_CLIP_LH_NO

Left-handed, clip z in [-1, 1].

enum vm_layout_t

Memory layout for dense panels passed to vm_gemm and vm_mat.

Enumerators
VM_LAYOUT_COL_MAJOR

Element (r, c) at data[r + c * ld].

VM_LAYOUT_ROW_MAJOR

Element (r, c) at data[c + r * ld].

enum (anonymous)

Optional GEMM epilogue.

Flags may be OR-ed.

Bias is length N and broadcasts over rows: C(i, j) += bias[j]. ReLU is max(C, 0) after alpha/beta/bias.

Enumerators
VM_GEMM_OP_NONE

No epilogue.

VM_GEMM_OP_BIAS

Add per-column bias.

VM_GEMM_OP_RELU

Apply ReLU.

VM_GEMM_OP_BIAS_RELU

Bias then ReLU (BIAS | RELU).

enum vm_ksp_prec_t

Left preconditioner for the Krylov solvers.

IC0 is incomplete Cholesky with no fill. On breakdown the solver falls back to Jacobi for that call.

Enumerators
VM_KSP_PREC_NONE

No preconditioning.

VM_KSP_PREC_JACOBI

Diagonal (Jacobi) scaling.

VM_KSP_PREC_SSOR

Symmetric successive over-relaxation.

VM_KSP_PREC_IC0

Incomplete Cholesky, zero fill.

enum vm_bc_t

Boundary condition for assembled grid operators.

Dirichlet rows become the identity (rhs holds the boundary value). Homogeneous Neumann drops the missing neighbour; the 7-point Neumann Laplacian is singular (constant nullspace).

Enumerators
VM_BC_DIRICHLET

Fixed-value boundary (identity rows).

VM_BC_NEUMANN

Homogeneous Neumann (drop missing neighbour).

Define documentation

#define FLOAT_EQ(a, b, eps)

Checks if two floats are approximately equal within tolerance.

Parameters
a First value
b Second value
eps Tolerance threshold
Returns True if values are equal within the given tolerance.

#define DOUBLE_EQ(a, b, eps)

Checks if two doubles are approximately equal within tolerance.

Parameters
a First value
b Second value
eps Tolerance threshold
Returns True if values are equal within the given tolerance.