No matching definitions.

tur/mat

src/linalg/mat.tur

dynamic :float matrix type and core operations

defstruct

mat

(defstruct mat [])

a heap-allocated row-major m x n float matrix.

defn

mat--alloc-data

(mat--alloc-data [n] :int)

Private helper: allocate float array

defn

mat--free-data

(mat--free-data [data] :void)

Private helper: free float array

defn

mat-new

(mat-new [rows cols] :int)

create an uninitialized m x n matrix

defn

mat-new-zeroed

(mat-new-zeroed [rows cols] :int)

create an m x n matrix filled with zeros

defn

mat-identity

(mat-identity [n] :int)

create an n x n identity matrix

defn

mat-diag

(mat-diag [v] :int)

create a diagonal matrix from a vector

defn

mat-from-list

(mat-from-list [rows cols data] :int)

create a matrix from a cons list of floats (row-major)

defn

mat-copy

(mat-copy [m] :int)

create a deep copy of a matrix

defn

mat-free

(mat-free [m] :void)

free a matrix

defn

mat-rows

(mat-rows [m] :int)

get number of rows

defn

mat-cols

(mat-cols [m] :int)

get number of columns

defn

mat-shape

(mat-shape [m] :int)

get matrix shape as (cons rows cols)

defn

mat-get

(mat-get [m r c] :float)

get element at (r, c) with bounds checking

defn

mat-set!

(mat-set! [m r c v] :void)

set element at (r, c) with bounds checking

defn

mat-row

(mat-row [m r] :int)

get a copy of row r as a vector

defn

mat-col

(mat-col [m c] :int)

get a copy of column c as a vector

defn

mat-submat

(mat-submat [m r0 c0 r1 c1] :int)

get a copy of submatrix from (r0, c0) to (r1, c1) (exclusive)

defn

mat-add

(mat-add [a b] :int)

Arithmetic operations

defn

mat-sub

(mat-sub [a b] :int)

element-wise matrix subtraction

defn

mat-scale

(mat-scale [m s] :int)

scalar multiplication

defn

mat-mul

(mat-mul [a b] :int)

matrix multiplication

defn

mat-mul-vec

(mat-mul-vec [m v] :int)

matrix-vector multiplication

defn

mat-transpose

(mat-transpose [m] :int)

transpose a matrix

defn

mat-trace

(mat-trace [m] :float)

sum of diagonal elements (for square matrices)

defn

mat-norm-fro

(mat-norm-fro [m] :float)

Frobenius norm (sqrt of sum of squares of all elements)

defn

mat-norm-max

(mat-norm-max [m] :float)

maximum absolute element

defn

mat-square?

(mat-square? [m] :int)

check if matrix is square

defn

mat-approx-eq?

(mat-approx-eq? [a b tol] :int)

check if two matrices are approximately equal