Y YASPS
Docs menu
Getting started Scene Mesh Primitive Primitive union Connectivity Attribute Minimizer Solver Differentiator Matrix Jacobian Hessian Gradient Examples Dropping in a container Cubify Inverse simulation

API reference · 10

Matrix

Stores value needed to assemble a block-sparse matrix on the GPU.

matrix

matrix(rows=0, cols=0, symmetric_storage=False)

Create an empty block-sparse matrix. Derivative matrices normally populate this representation automatically.

Parameter Type Default Description
rows int 0 Number of matrix rows.
cols int 0 Number of matrix columns.
symmetric_storage bool False Treat each stored off-diagonal block as also representing its transpose.

Example

empty_matrix = matrix(rows=12, cols=12)

Returns: new matrix.

Raises: ValueError when either dimension is negative.

spmv

spmv(x, transpose=False)

Multiply the numeric static and dynamic sparse blocks by a device-resident YASPS vector.

Parameter Type Default Description
x compatible YASPS vector required Input vector matching cols, or rows when transposed.
transpose bool False Multiply by the matrix transpose when True.

Example

previous_position_contribution = previous_position_jacobian.spmv(auxiliary, transpose=True)

Returns: new compatible YASPS vector with the multiplication result.

Raises: TypeError for an incompatible vector or transpose flag; ValueError when dimensions or sparse block metadata do not match.

The matrix * x and matrix @ x operators are equivalent to matrix.spmv(x).

Properties

Property Type Description
rows int Matrix row count.
cols int Matrix column count.
symmetric_storage bool Whether stored off-diagonal blocks also represent their transposes.
block_dimensions list[int] Static block dimensions stored as row/column pairs.
blocks_flattened pycuda.gpuarray.GPUArray Flattened static block values.
blocks_start_indices list[int] Value-buffer start for each static block category.
block_positions pycuda.gpuarray.GPUArray Flattened row/column coordinates for static blocks.
block_counts list[int] Static block count per dimension category.
block_dimensions_dynamic list[int] Dynamic block dimensions stored as row/column pairs.
blocks_flattened_dynamic pycuda.gpuarray.GPUArray Flattened dynamic block values.
blocks_start_indices_dynamic list[int] Value-buffer start for each dynamic block category.
block_positions_dynamic pycuda.gpuarray.GPUArray Flattened row/column coordinates for dynamic blocks.
block_counts_dynamic list[int] Dynamic block count per dimension category.