Skip to content

Commit 2d35f07

Browse files
Update the docstring of ldiv! (#1344)
![image](https://github.com/user-attachments/assets/724d0ca3-fc05-46a7-b22a-cc0ab929bfe0) A comment about the existing docstring is: The lower example reads counter-intuitive, _given_ the experience from reading the upper example. And `X` and `Y` are not like `A` and `B`. Hope the revised version reads clearer and intelligible.
1 parent ae208d6 commit 2d35f07

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/LinearAlgebra.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,13 @@ control over the factorization of `A`.
394394
```jldoctest
395395
julia> A = [1 2.2 4; 3.1 0.2 3; 4 1 2];
396396
397-
julia> X = [1; 2.5; 3];
397+
julia> B = [1, 2.5, 3];
398398
399-
julia> Y = zero(X);
399+
julia> Y = similar(B); # use similar since there is no need to read from it
400400
401-
julia> ldiv!(Y, qr(A), X);
401+
julia> ldiv!(Y, qr(A), B); # you may also try qr!(A) to further reduce allocation
402402
403-
julia> Y ≈ A\\X
403+
julia> Y ≈ A \\ B
404404
true
405405
```
406406
"""
@@ -426,13 +426,13 @@ control over the factorization of `A`.
426426
```jldoctest
427427
julia> A = [1 2.2 4; 3.1 0.2 3; 4 1 2];
428428
429-
julia> X = [1; 2.5; 3];
429+
julia> B = [1, 2.5, 3];
430430
431-
julia> Y = copy(X);
431+
julia> B0 = copy(B); # a backup copy to facilitate testing
432432
433-
julia> ldiv!(qr(A), X);
433+
julia> ldiv!(lu(A), B); # you may also try lu!(A) to further reduce allocation
434434
435-
julia> X ≈ A\\Y
435+
julia> B ≈ A \\ B0
436436
true
437437
```
438438
"""

0 commit comments

Comments
 (0)