package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `SuperLU
]
type t = [ `Object | `SuperLU ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : unit -> t

LU factorization of a sparse matrix.

Factorization is represented as::

Pr * A * Pc = L * U

To construct these `SuperLU` objects, call the `splu` and `spilu` functions.

Attributes ---------- shape nnz perm_c perm_r L U

Methods ------- solve

Notes -----

.. versionadded:: 0.14.0

Examples -------- The LU decomposition can be used to solve matrix equations. Consider:

>>> import numpy as np >>> from scipy.sparse import csc_matrix, linalg as sla >>> A = csc_matrix([1,2,0,4],[1,0,0,1],[1,0,2,1],[2,2,1,0.])

This can be solved for a given right-hand side:

>>> lu = sla.splu(A) >>> b = np.array(1, 2, 3, 4) >>> x = lu.solve(b) >>> A.dot(x) array( 1., 2., 3., 4.)

The ``lu`` object also contains an explicit representation of the decomposition. The permutations are represented as mappings of indices:

>>> lu.perm_r array(0, 2, 1, 3, dtype=int32) >>> lu.perm_c array(2, 0, 1, 3, dtype=int32)

The L and U factors are sparse matrices in CSC format:

>>> lu.L.A array([ 1. , 0. , 0. , 0. ], [ 0. , 1. , 0. , 0. ], [ 0. , 0. , 1. , 0. ], [ 1. , 0.5, 0.5, 1. ]) >>> lu.U.A array([ 2., 0., 1., 4.], [ 0., 2., 1., 1.], [ 0., 0., 1., 1.], [ 0., 0., 0., -5.])

The permutation matrices can be constructed:

>>> Pr = csc_matrix((np.ones(4), (lu.perm_r, np.arange(4)))) >>> Pc = csc_matrix((np.ones(4), (np.arange(4), lu.perm_c)))

We can reassemble the original matrix:

>>> (Pr.T * (lu.L * lu.U) * Pc.T).A array([ 1., 2., 0., 4.], [ 1., 0., 0., 1.], [ 1., 0., 2., 1.], [ 2., 2., 1., 0.])

val shape : t -> Py.Object.t

Attribute shape: get value or raise Not_found if None.

val shape_opt : t -> Py.Object.t option

Attribute shape: get value as an option.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.