tril!(M)

tril!(M)

Lower triangle of a matrix, overwriting M in the process.

Examples

  1. Extract lower triangle of a matrix:

    julia> A = [1 2 3; 4 5 6; 7 8 9];
    julia> tril!(A)
    3×3 Array{Int64,2}:
    1  0  0
    4  5  0
    7  8  9

    This example extracts the lower triangle of matrix A and overwrites A with the lower triangular portion.

  2. Specify a positive value of k to extract lower triangle from a specific superdiagonal:

    julia> B = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
    julia> tril!(B, 2)
    4×4 Array{Int64,2}:
    1   0   0   0
    5   6   0   0
    9  10  11   0
    13  14  15  16

    It extracts the lower triangle of matrix B starting from the 2nd superdiagonal and modifies B accordingly.

  3. Handle edge cases when k is larger than the number of superdiagonals:
    julia> C = [1 2 3; 4 5 6; 7 8 9];
    julia> tril!(C, 5)
    3×3 Array{Int64,2}:
    1  0  0
    4  5  0
    7  8  9

    In this case, k is larger than the number of superdiagonals, so the function behaves as if k is equal to the number of superdiagonals.

Common mistake example:

julia> D = [1 2 3; 4 5 6; 7 8 9];
julia> tril!(D, -1)
ERROR: ArgumentError: k must be non-negative

In this example, a negative value of k is provided, which results in an ArgumentError. Ensure that k is a non-negative value when using tril!.

See Also

Ac_ldiv_B, Ac_ldiv_Bc, Ac_mul_B, Ac_mul_Bc, Ac_rdiv_B, Ac_rdiv_Bc, At_ldiv_B, At_ldiv_Bt, At_mul_B, At_mul_Bt, At_rdiv_B, At_rdiv_Bt, A_ldiv_Bc, A_ldiv_Bt, A_mul_B!, A_mul_Bc, A_mul_Bt, A_rdiv_Bc, A_rdiv_Bt, Bidiagonal, cond, conv2, det, diag, diagind, diagm, diff, eig, eigvals, eigvecs, expm, eye, full, inv, isdiag, ishermitian, isposdef, isposdef!, issym, istril, istriu, logabsdet, logdet, lyap, norm, qrfact, rank, repmat, rot180, rotl90, rotr90, sortrows, sqrtm, SymTridiagonal, trace, Tridiagonal, tril, tril!, triu, triu!, writedlm,

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: