lufact!

..  lufact!(A) -> LU

``lufact!`` is the same as :func:`lufact`, but saves space by overwriting the input ``A``, instead of creating a copy.  For sparse ``A`` the ``nzval`` field is not overwritten but the index fields, ``colptr`` and ``rowval`` are decremented in place, converting from 1-based indices to 0-based indices.

Examples

In the Julia programming language, the function lufact!(A)

lufact! is similar to lufact, but it saves space by overwriting the input A instead of creating a copy. For sparse A, the nzval field is not overwritten, but the index fields, colptr and rowval, are decremented in place, converting from 1-based indices to 0-based indices.

Common examples of its use:

  1. Factorize and overwrite a dense matrix:

    julia> A = [1 2; 3 4];
    julia> lufact!(A)
    Base.LinAlg.LU{Float64,Array{Float64,2}}([3.0 4.0; 0.3333333333333333 -0.6666666666666666], [2, 2], [2, 1])

    This example factorizes the dense matrix A using lufact! and overwrites A with the LU factorization.

  2. Factorize and overwrite a sparse matrix:

    julia> using SparseArrays
    julia> A = sparse([1 0; 0 1]);
    julia> lufact!(A)
    SuiteSparse.UMFPACK.UmfpackLU{Float64,Int64}(2, 2, [1, 2], [1, 2], [1.0, 1.0], [1, 2], [1])

    This example factorizes the sparse matrix A using lufact! and overwrites A with the LU factorization.

  3. Handle errors when input is not a square matrix:
    julia> A = [1 2 3; 4 5 6];
    julia> lufact!(A)
    ERROR: ArgumentError: input is not a square matrix

    It throws an error when the input matrix is not a square matrix.

Please note that the actual returned objects may vary depending on the Julia version and package versions used.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: