# 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!`.