Matrix Basics
This page covers the basics of the matrix struct in slap and
several of the fundamental operations.
The Matrix struct
In slap, a matrix is a lightweight struct (and matching typedef) that
holds the pointer to the start of the matrix, along with some additional meta
for things like the size, stride, and type.
-
struct Matrix
Represents a matrix of sfloat-precision data.
Simple wrapper around an arbitrary pointer to the underlying data. The data is assumed to be stored in a contiguous block of memory. The data is interpreted column-wise, such that
data[1]is element[1,0]of the matrix.
The underlying data pointer should be accessed via the getter:
-
static inline sfloat *slap_GetData(Matrix mat)
Return the raw pointer stored by the matrix.
- Parameters:
mat – Any matrix
Warning
The fields of a Matrix should be considered private and
are not meant to be directly altered. Please use the function API, as the
internal representation of the API is subject to change in future versions.
Size Information
The following functions are useful for obtaining information about the
size of a matrix. Please use these functions over directly accessing the
fields of the Matrix type. All size information in slap
is represented by the int type.
Name |
Description |
|---|---|
Get the number of rows (\(m\)) |
|
Get the number of columns (\(n\)) |
|
Get the number of elements (\(m * n\)) |
|
Get the column stride of the matrix |
|
Get the number of elements (\(\text{min}(m, n)\)) |
|
True if either dimension is zero |
|
True if dimensions are equal |
Note
In the future, the default type used for size information might be set by the user as a CMake variable.
Boolean Checks
Use the following functions to perform various checks on a matrix.
Name |
Description |
|---|---|
Checks if the matrix is transposed. |
|
Checks if memory is contiguous (default stride) |
|
Checks if the matrix is a default-initialized Null matrix |
|
Checks if the data pointer for a matrix is valid |