warp.optim.linear.LinearOperator#

class warp.optim.linear.LinearOperator(shape, dtype, device, matvec, batch_offsets=None)[source]#

Linear operator to be used as left-hand-side of linear iterative solvers.

Parameters:
  • shape (tuple[int, int]) – Tuple containing the number of rows and columns of the operator

  • dtype (type) – Type of the operator elements

  • device (Device) – Device on which computations involving the operator should be performed

  • matvec (Callable) – Matrix-vector multiplication routine

  • batch_offsets (array | None) – Optional array of shape (B+1,) partitioning scalar degrees of freedom into B independent subproblems. batch_offsets[i] is the first scalar degree of freedom of subproblem i. For vector-valued arrays, offsets must be aligned to the vector length. When None (default) the operator represents a single subproblem.

The matrix-vector multiplication routine should have the following signature:

def matvec(x: warp.array, y: warp.array, z: warp.array, alpha: Scalar, beta: Scalar):
    '''Perform a generalized matrix-vector product.

    This function computes the operation z = alpha * (A @ x) + beta * y, where 'A'
    is the linear operator represented by this class.
    '''
    ...

For performance reasons, by default the iterative linear solvers in this module will try to capture the calls for one or more iterations in CUDA graphs. If the matvec routine of a custom LinearOperator cannot be graph-captured, the use_cuda_graph=False parameter should be passed to the solver function.

__init__(
shape,
dtype,
device,
matvec,
batch_offsets=None,
)[source]#
Parameters:

Methods

__init__(shape, dtype, device, matvec[, ...])

Attributes

batch_count

Number of independent subproblems.

batch_offsets

Array of length batch_count + 1 partitioning scalar degrees of freedom, or None.

device

dtype

matvec

scalar_type

shape

property shape: tuple[int, int][source]#
property dtype: type[source]#
property device: Device[source]#
property matvec: Callable[source]#
property scalar_type[source]#
property batch_offsets: array | None[source]#

Array of length batch_count + 1 partitioning scalar degrees of freedom, or None.

property batch_count: int[source]#

Number of independent subproblems. 1 when batch_offsets is None.