svdfact!

..  svdfact!(A, [thin=true]) -> SVD

``svdfact!`` is the same as :func:`svdfact`, but saves space by overwriting the input ``A``, instead of creating a copy. If ``thin`` is ``true``, an economy mode decomposition is returned. The default is to produce a thin decomposition.

Examples

The svdfact!(A, [thin=true]) function in Julia performs Singular Value Decomposition (SVD) on matrix A. It overwrites the input matrix A, saving space by not creating a copy. If thin is set to true, it returns an economy mode decomposition. The default behavior is to produce a thin decomposition.

Here are some examples of how to use the svdfact! function:

  1. Perform SVD on a matrix:

    julia> A = [1 2 3; 4 5 6; 7 8 9];
    julia> svdfact!(A)
    SVD{Float64, Float64, Matrix{Float64}}
    U factor:
    3×3 Matrix{Float64}:
    -0.214837  -0.887231   0.408248
    -0.520587  -0.249644  -0.816497
    -0.826338   0.387943   0.408248
    singular values:
    3-element Vector{Float64}:
    16.848103352614207
     1.0683695145549087e-15
     1.0683695145549087e-15
    Vt factor:
    3×3 Matrix{Float64}:
    -0.479671  -0.572368  -0.665064
    -0.776691  -0.075686   0.625319
    -0.408248   0.816497  -0.408248

    This example performs SVD on matrix A and overwrites it with the result. It returns the SVD object containing the U factor, singular values, and Vt factor.

  2. Perform economy mode SVD:

    julia> B = [1 2 3; 4 5 6; 7 8 9];
    julia> svdfact!(B, true)
    SVD{Float64, Float64, Matrix{Float64}}
    U factor:
    3×2 Matrix{Float64}:
    -0.214837  -0.887231
    -0.520587  -0.249644
    -0.826338   0.387943
    singular values:
    2-element Vector{Float64}:
    16.848103352614207
     1.0683695145549087e-15
    Vt factor:
    2×3 Matrix{Float64}:
    -0.479671  -0.572368  -0.665064
    -0.776691  -0.075686   0.625319

    In this example, the thin parameter is set to true, resulting in an economy mode decomposition where the U factor and Vt factor are reduced to their optimal sizes.

Remember that svdfact! modifies the input matrix A directly, so make sure to create a copy if you need to preserve the original matrix.

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: