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 intoBindependent subproblems.batch_offsets[i]is the first scalar degree of freedom of subproblemi. For vector-valued arrays, offsets must be aligned to the vector length. Scalar degrees of freedom at or beyondbatch_offsets[-1]are inactive and ignored by batched iterative solvers. WhenNone(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
matvecroutine of a customLinearOperatorcannot be graph-captured, theuse_cuda_graph=Falseparameter should be passed to the solver function.Attributes
Number of independent subproblems.
Array partitioning the active scalar degrees of freedom, or
None.- property batch_offsets: array | None[source]#
Array partitioning the active scalar degrees of freedom, or
None.Scalar degrees of freedom at or beyond the final offset are inactive and ignored by batched iterative solvers.
- property batch_count: int[source]#
Number of independent subproblems.
1whenbatch_offsetsisNone.