Houdini 20.0 Nodes Geometry nodes

Linear Solver geometry node

Solves system of linear equations.

On this page

This SOP node performs common numerical linear algebra operations, including linear system solve, least squares solve, and matrix decompositions, using real matrix and vector stored as geometry attributes, and outputs the result as a geometry attribute. This node supports both dense and sparse matrix inputs encoded in several ways. A dense matrix is a matrix where entries are fully populated with non-zero entries, whereas a sparse matrix is a matrix with a small proportion of non-zero entries. Both dense and sparse linear systems can be solved using direct or iterative solvers. Direct solvers first decompose the input matrix and solve the system using the decomposition, while iterative solvers multiply the input matrix to vectors multiple times until convergence to find the solution. Refer to Numerical Linear Algebra and Apple Accelerate Framework: Sparse Solvers for the summary of numerical linear algebra.

This node is implemented as a wrapper of linear solver and matrix decomposition classes available in Eigen and Spectra.

TIPS

For dense matrices, numpy, a popular library written in Python, offers similar capabilities using direct solvers. If you are familiar with numpy, you may utilize the table below about the rough correspondence between what numpy offers and the mode and the choice of direct solver in this node to help you with the transition. However, note that the computation results are not expected to be identical between the two, and it is advised that you carefully evaluate the choice of solver and the usage to obtain the best performance with your application. Some of the considerations include, but are not limited to, the size, sparsity, and symmetry of the input matrix, whether you can gain advantages by precomputing the decomposition, and whether you should use an iterative solver.

Function in numpy.linalg

Mode

Direct Solver

solve(a, b)

Linear System Solve

PartialPivLU

lstsq(a, b)

Linear System Solve

BDCSVD

cholesky(a)

Decompose

LLT

qr(a)

Decompose

HouseholderQR

svd(a)

Decompose

BDCSVD

eig(a)

Decompose

EigenSolver

eigh(a)

Decompose

SelfAdjointEigenSolver

Warning

It is your responsibility to choose the appropriate solver for your own problem. This node does not check if the given input matrix satisfies the required conditions for a specific solver to work, such as symmetry, positive definiteness, or invertibility of the input matrix.

Note

This node uses Intel’s Math Kernel Library when run on x86 processors. You can use an environment variable to tune the library for speed or for producing identical results from run to run.

Inputs

Matrix/Decomposition (&Vectors)

Specifies the matrix and the decomposition used to perform operations in all modes. See Matrix for the details. Optionally, known and unknown vectors can be specified in this input when the second or third geometry is not given.

Known Vector

Specifies the vector that is multiplied to a matrix in Multiply mode or the right-hand side vector in Linear System Solve and Solve with Decomposition modes. See Known Vector for the details. When there is no second input geometry available, the node tries to retrieve information from the first input. When the size of the vector is an integer multiple of the required length, the vector will be reinterpreted as a stack of vectors and outputs the stack of vectors if possible.

Unknown Vector

Specifies the configuration related to the unknown vector in the Linear System Solve, Decompose, and Solve with Decomposition modes. This includes the original vector when we accumulate the results and information about the pinned/known entries in the vector. See Unknown Vector for the details. When there is no third input geometry available, the node tries to retrieve information from the first input. When the size of the vector is an integer multiple of the required length, the vector will be reinterpreted as a stack of vectors.

Parameters

Mode

Linear System Solve

Solves the system of linear equations using the choice of solver and outputs the resulting vector, given a matrix and a vector. Some solvers support least squares solve as well. See Linear Solver Setting for the available solvers.

Decompose

Outputs the decomposition of the input matrix with the choice of a direct solver from Eigen or an eigensolver from Spectra.

Solve with Decomposition

Performs the solve of the system of linear equations and outputs the resulting vector, given a decomposition produced with Decompose mode and a vector. The type of decomposition is inferred from the input.

Multiply

Multiplies the given matrix and vector and outputs the resulting vector.

Cook In-Place

Turn on this toggle to create the output in place. Otherwise, a new geometry is created. Note the in-place output cannot change the number of incoming points, if they exist, and the number of incoming primitives. If this requirement is not satisfied, the node reports an error.

Precision

Linear Solver SOP can evaluate at 32-bit or 64-bit floating point precision. 64-bit provides higher accuracy. The auto mode will switch between 32-bit and 64-bit depending on the preferred precision of the incoming matrix/decomposition. When run in 64-bit precision, any created floating point attributes will be 64-bit. When run in 32-bit any created floating point attributes will be 32-bit. Use Attribute Cast to change the preferred precision.

Solver Settings

Direct Solver

Specifies the direct solver used for Linear System Solve and Decompose modes. The available choices are as follows.

Dense

  • PartialPivLU

  • FullPivLU

  • HouseholderQR

  • ColPivHouseholderQR

  • FullPivHouseholderQR

  • CompleteOrthogonalDecomposition

  • LLT

  • LDLT

  • BDCSVD

  • JacobiSVD

    BDCSVD and JacobiSVD perform singular value decomposition. In Decompose mode, the resulting triplets that consist of a singular value and the corresponding left and right singular vectors are stored in the output geometry one triplet per point.

  • EigenSolver

  • SelfAdjointEigenSolver

    EigenSolver and SelfAdjointEigenSolver perform eigenvalue decomposition. In Decompose mode, the resulting pairs that consist of an eigenvalue and the corresponding eigenvector are stored in the output geometry one pair per point.

See Eigen: Catalogue of Dense Decompositions for the description of these solvers.

Note

Decompose mode does not support CompleteOrthogonalDecomposition.

Solve with Decomposition mode does not support the decompositions made with Decompose mode using EigenSolver or SelfAdjointEigenSolver.

Sparse

  • LLT

  • LDLT

  • LU

  • QR

See Backend for the choice of backend.

Backend

This option lets you choose the backend used for the sparse direct solver used in the Linear System Solve mode. Note that Decompose mode always uses a decomposition computed with Eigen backend, and this option is hidden.

Pardiso / Accelerate

This mode uses the implementation provided by Intel PARDISO or Apple Accelerate Framework, if available. Intel PARDISO is used on all x86 platforms, and Apple Accelerate Framework is used on Mac OS with Apple Silicon. The solver options in Direct Solver correspond to the solvers below.

Pardiso

  • PardisoLLT

  • PardisoLDLT

  • PardisoLU

  • SparseQR (Eigen’s implementation)

Accelerate

  • AccelerateLLT

  • AccelerateLDLT

  • SparseLU (Eigen’s implementation)

  • AccelerateQR

Eigen

This mode uses the implementation provided by Eigen. Use this option when you want to get consistent results between the solution you get with Linear System Solve mode and Solve with Decomposition mode. The solver options in Direct Solver correspond to the solvers below.

  • SimplicialLLT

  • SimplicialLDLT

  • SparseLU

  • SparseQR

See Eigen: Solving Sparse Linear Systems for the description of these solvers.

Use Iterative Solver

Turn on this toggle to use an iterative solver instead of a direct solver. Direct solvers are more accurate but consume more memory. Iterative solvers are less accurate but consume less memory. Therefore, it is recommended in general that you use direct solvers for small problems and iterative solvers for large problems. Note iterative solvers are supported in Linear System Solve mode only.

Iterative Solver

Specifies the direct solver for dense and sparse input matrices. The available choices are as follows.

  • GMRES

  • DGMRES

  • MINRES

  • ConjugateGradient

  • LeastSquaresConjugateGradient

  • BiCGSTAB

  • IDRS

See Eigen: Iterative Linear Solvers module and Eigen-unsupported: Iterative Linear Solvers module for the description of solvers.

Preconditioner

Specifies the preconditioner used for iterative solvers. The available choices are as follows.

For LeastSquaresConjugateGradient solver, choosing Diagonal preconditioner lets the solver use LeastSquareDiagonalPreconditioner instead.

Solve with Guess

Turn on this toggle to use the iterative solver with the unknown vector as an initial guess.

Use Eigensolver

Turn on this toggle to use an eigensolver from Spectra library instead of a direct solver. These eigensolvers are designed to efficiently find a fraction of eigenpairs instead of finding all eigenpairs. These eigensolvers are available for both dense and sparse matrices. Note these eigensolvers are supported in Decompose mode only.

Eigensolver

Specifies the eigensolver used. The prefix “Gen” means that the solver is for general matrices, while the prefix “Sym” means that the solver is for symmetric matrices.

See the documentation of Spectra for the details of each solver.

Num Eigenpairs

Specifies the number of pairs of eigenvalue and eigenvector to request to the eigensolver. The node will report a warning when the solver cannot find the requested number of eigenpairs. The solvers from Spectra cannot find all the eigenpairs for a given matrix, and it is advised that you use the solvers from Eigen in Direct Solver for such cases.

Shift

Specifies the real shift value for GenEigsRealShiftSolver and SymEigsShiftSolver.

Tolerance

Specifies the relative error tolerance for the iterative solvers and the eigensolvers. Solvers may take longer to converge if you specify a smaller tolerance.

Matrix

Storage

Specifies the source of the input matrix from a volume primitive, point attributes, primitive attributes, or detail attributes.

Encoding

Volume

Dense Col-Major / Row-Major

The input dense matrix is stored as a volume primitive specified in the Value Attribute parameter field in the column-major (or row-major) order. The size of the matrix is inferred from the x and y dimensions of the volume primitive.

Points / Primitives

Dense Col-Major / Row-Major

The input dense matrix is stored as an array per point / primitive in the column-major (or row-major) order, where arrays are of the same length. The number of columns and rows are inferred from the number of points / primitives and the length of arrays.

LIL Col-Major / Row-Major

The input sparse matrix is stored in the list of lists format (LIL) as point / primitive attributes. Each point / primitive stores the matrix entries for one column for the column-major option (respectively one row for the row-major option). For each column (resp. row), an array of row (resp. column) indices and the corresponding array of values must be given. The number of columns (resp. rows) are inferred from the number of points / primitives whereas the number of rows (resp. cols) must be specified.

Note

This format is the same as the more commonly used compressed sparse column (resp. row) format (CSC/CSR) if we additionally provide an outer index array instead of using the column-wise (resp. row-wise) point / primitive storage.

COO

The input sparse matrix is stored in the coordinate list format (COO) as point / primitive attributes. Triplets of column index, row index, and value, stored as scalars, tuples, or arrays with the same length per point / primitive, specify the matrix entries.

Note

COO encoding is less efficient than LIL. For large systems, using LIL is recommended.

Detail

Dense Col-Major / Row-Major

The input dense matrix is stored as a flattened array as a detail attribute in the column-major (or row-major) order. The number of columns and rows must be specified.

COO

The input sparse matrix is stored in the coordinate list format (COO) as detail attributes. Triplets of column index, row index, and value, stored as tuples, or arrays with the same length, specify the matrix entries.

Square Matrix

Turn on this toggle to infer the shape of the matrix from the given data whenever possible, assuming that the matrix is square.

Rows

Specifies the number of rows of the matrix when not inferred from the encoding.

Cols

Specifies the number of columns of the matrix when not inferred from the encoding.

Row Attribute

Specifies the name of the integer attribute that stores the row indices for LIL Col-Major and COO sparse matrix formats. When an array or a tuple is used, the length must be the same as the ones for Col Attribute and Value Attribute when they need to be specified as well.

Col Attribute

Specifies the name of the integer attribute that stores the column indices for LIL Row-Major and COO sparse matrix formats. When an array or a tuple is used, the length must be the same as the ones for Row Attribute and Value Attribute when they need to be specified as well.

Value Attribute

Specifies the name of the floating point attribute that stores the values of matrix entries. When an array or a tuple is used, the length must be the same as the ones for Col Attribute and Row Attribute when they need to be specified as well.

Known Vector

Storage

Specifies what storage is used to store the vector.

Points / Primitives

The input vector is stored as a point / primitive attribute. Each point / primitive can store one or more entries. The entries are concatenated in the order of the point / primitive number as a flat vector.

Detail

The input vector is stored as an array detail attribute.

Value Attribute

Specifies the name of the floating point attribute that stores the values of vector entries.

Unknown Vector

Storage

Specifies what storage is used to store the vector.

Points / Primitives

The output vector will be stored as a point / primitive attribute. Each point / primitive stores one entry.

Detail

The output vector will be stored as an array detail attribute.

Value Attribute

Specifies the name of the floating point attribute that stores the values of vector entries.

Pinned Group

Specifies a “pinned” point / primitive group when the unknown vector is encoded as points/primitives. In the Linear System Solve, Decompose, and Solve with Decomposition modes, the pinned vector entries will be ignored and the corresponding matrix columns will be removed during the computation. Note that this pin information will not modify the known vector (right-hand vector) in the solve, and you need to perform such operations separately. Note that the pinned group can be specified for the Decompose mode, too, without specifying the unknown vector Value Attribute to perform the decomposition of a matrix with column reduction (and row reduction; see below).

Reduce Rows

Turn on this toggle to reduce the corresponding matrix rows in addition to the columns when a pinned group is specified. This option is valid only for square matrices.

Scale

Specifies a constant scale applied to the result vector.

Accumulate Result

Turn on this toggle to output the sum of the computed vector and the vector specified in the incoming geometry. The scaling is applied before the summation.

Examples

ARAPSurfaceDeformation Example for Linear Solver geometry node

This example demonstrates the use of the Linear Solver SOP to apply the As-Rigid-As-Possible surface deformation method.

CurveInflation Example for Linear Solver geometry node

This example demonstrates the use of the Linear Solver SOP to inflate an input 2D domain defined with curves to create a 3D surface geometry.

RBFCageDeformer Example for Linear Solver geometry node

This example demonstrates the use of the Linear Solver SOP to deform an object based on the embedding cage’s deformation using a radial basis function.

SagfreeInitialization Example for Linear Solver geometry node

This example demonstrates the use of the Linear Solver SOP to initialize the Vellum distance constraints so the object will not sag from the gravity.

See also

Geometry nodes