No matching definitions.

tur/sized-matrix

stdlib/sized-matrix.tur

SizedMatrix: row-major 2D matrix with static size annotations.

Since: Phase SZ3

defn

sized-matrix-new

(sized-matrix-new [rows cols])

allocate a rows x cols matrix (uninitialized).

rowsnumber of rows
colsnumber of columns

Opaque pointer to the new SizedMatrix.

(let [m (unsafe (sized-matrix-new 3 4))] ...)

Since: Phase SZ3

defn

sized-matrix-new-zeroed

(sized-matrix-new-zeroed [rows cols])

allocate a rows x cols matrix, all zero.

rowsnumber of rows
colsnumber of columns

Opaque pointer to the new SizedMatrix with all elements set to 0.

(let [m (unsafe (sized-matrix-new-zeroed 3 4))] ...)

Since: Phase SZ3

defn

sized-matrix-free

(sized-matrix-free [m])

free a heap-allocated SizedMatrix and its data.

mSizedMatrix pointer from sized-matrix-new or sized-matrix-new-zeroed

nil

(unsafe (sized-matrix-free m))

Since: Phase SZ3

defn

sized-matrix-rows

(sized-matrix-rows [m])

number of rows in the matrix.

mSizedMatrix pointer

Row count as :int.

(sized-matrix-rows m)  ; => 3

Since: Phase SZ3

defn

sized-matrix-cols

(sized-matrix-cols [m])

number of columns in the matrix.

mSizedMatrix pointer

Column count as :int.

(sized-matrix-cols m)  ; => 4

Since: Phase SZ3

defn

sized-matrix-size

(sized-matrix-size [m])

return the total element count as a Size expression.

mSizedMatrix pointer

A (Static n) where n = rows * cols.

(size-eval (unsafe (sized-matrix-size m)))  ; => rows*cols

Since: Phase SZ3

defn

sized-matrix-row-size

(sized-matrix-row-size [m])

return the number of columns as a Size expression.

mSizedMatrix pointer

A (Static cols).

(size-eval (unsafe (sized-matrix-row-size m)))  ; => cols

Since: Phase SZ3

defn

sized-matrix-col-size

(sized-matrix-col-size [m])

return the number of rows as a Size expression.

mSizedMatrix pointer

A (Static rows).

(size-eval (unsafe (sized-matrix-col-size m)))  ; => rows

Since: Phase SZ3

defn

sized-matrix-get

(sized-matrix-get [m r c])

bounds-checked element read at (r, c).

mSizedMatrix pointer
rzero-based row index
czero-based column index

The int64 value at row r, column c.

(sized-matrix-get m 1 2)  ; => element at row 1 col 2

Since: Phase SZ3

defn

sized-matrix-set!

(sized-matrix-set! [m r c v])

bounds-checked element write at (r, c).

mSizedMatrix pointer
rzero-based row index
czero-based column index
vvalue to store

The same matrix pointer m (for chaining).

(sized-matrix-set! m 0 0 42)

Since: Phase SZ3

defn

sized-matrix-fill!

(sized-matrix-fill! [m v])

set every element to v; returns the same matrix.

mSizedMatrix pointer
vvalue to store in every element

The same matrix pointer m.

(sized-matrix-fill! m 0)  ; zero-fill

Since: Phase SZ3

defn

sized-matrix-row-sum

(sized-matrix-row-sum [m r])

sum all elements in row r.

mSizedMatrix pointer
rzero-based row index

Integer sum of all elements in row r.

(sized-matrix-row-sum m 0)  ; => sum of first row

Since: Phase SZ3

defn

sized-matrix-col-sum

(sized-matrix-col-sum [m c])

sum all elements in column c.

mSizedMatrix pointer
czero-based column index

Integer sum of all elements in column c.

(sized-matrix-col-sum m 0)  ; => sum of first column

Since: Phase SZ3

defn

sized-matrix-total-sum

(sized-matrix-total-sum [m])

sum all elements in the matrix.

mSizedMatrix pointer

Integer sum of all elements.

(sized-matrix-total-sum m)

Since: Phase SZ3

defn

sized-matrix-assert-shape!

(sized-matrix-assert-shape! [m expected-rows expected-cols])

panic if the matrix does not have the expected shape.

mSizedMatrix pointer
expected-rowsexpected row count as a (Size)
expected-colsexpected column count as a (Size)

nil on success; panics with a descriptive message on shape mismatch.

(unsafe (sized-matrix-assert-shape! m (Static 3) (Static 4)))

Since: Phase SZ3