svdvals!

svdvals!(A)

Returns the singular values of A, while saving space by overwriting the input.

Examples

  1. Compute singular values of a matrix:

    julia> A = [1 2; 3 4; 5 6];
    julia> svdvals!(A)
    2-element Array{Float64,1}:
    7.3484692283495345
    0.3722813232690143

    This example computes the singular values of matrix A and overwrites A with the result.

  2. Update singular values of a matrix in-place:

    julia> B = [0.5 1.5; 2.5 3.5];
    julia> svdvals!(B)
    2-element Array{Float64,1}:
    4.541381265149109
    0.258618734850891

    It computes the singular values of matrix B and modifies B in-place.

  3. Handle rectangular matrices:
    julia> C = [1 2 3; 4 5 6];
    julia> svdvals!(C)
    2-element Array{Float64,1}:
    8.866068747318506
    0.36621420674709056

    It can handle rectangular matrices and compute their singular values.

Common mistake example:

julia> D = [1 2; 3 4; 5 6];
julia> svdvals!(D')
ERROR: MethodError: no method matching svdvals!(::Adjoint{Int64,Array{Int64,2}})

In this example, the transpose of matrix D is passed to svdvals!, resulting in a MethodError. Make sure to apply svdvals! directly to the matrix and not its transpose.

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: