Commit cc74d24
authored
Inplace transpose for unit Triangular may skip diagonal (#53101)
Since the diagonal elements of a `UnitUpperTriangular` are given by
`onelement`, these should be unchanged under `transpose/adjoint`, and we
don't need to access these elements in the parent array when performing
in-place operations.
Fixes
```julia
julia> using LinearAlgebra
julia> M = Matrix{BigFloat}(undef, 2, 2);
julia> M[1,2] = 3;
julia> U = UnitUpperTriangular(M)
2×2 UnitUpperTriangular{BigFloat, Matrix{BigFloat}}:
1.0 3.0
⋅ 1.0
julia> transpose!(U)
ERROR: UndefRefError: access to undefined reference
Stacktrace:
[1] getindex
@ ./essentials.jl:882 [inlined]
[2] getindex
@ ./array.jl:915 [inlined]
[3] copytri!
@ ~/packages/julias/julia-latest/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:414 [inlined]
[4] transpose!(A::UnitUpperTriangular{BigFloat, Matrix{BigFloat}})
@ LinearAlgebra ~/packages/julias/julia-latest/share/julia/stdlib/v1.11/LinearAlgebra/src/triangular.jl:470
[5] top-level scope
@ REPL[5]:1
```
After this PR:
```julia
julia> transpose!(U)
2×2 UnitLowerTriangular{BigFloat, Matrix{BigFloat}}:
1.0 ⋅
3.0 1.0
```1 parent cb9b00d commit cc74d24
2 files changed
+27
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
| 468 | + | |
469 | 469 | | |
470 | | - | |
| 470 | + | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
998 | 998 | | |
999 | 999 | | |
1000 | 1000 | | |
1001 | | - | |
| 1001 | + | |
1002 | 1002 | | |
1003 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
1004 | 1007 | | |
1005 | 1008 | | |
1006 | 1009 | | |
| |||
1009 | 1012 | | |
1010 | 1013 | | |
1011 | 1014 | | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
1012 | 1022 | | |
1013 | 1023 | | |
1014 | 1024 | | |
1015 | 1025 | | |
1016 | | - | |
| 1026 | + | |
1017 | 1027 | | |
1018 | 1028 | | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
1019 | 1032 | | |
1020 | 1033 | | |
1021 | 1034 | | |
| |||
1024 | 1037 | | |
1025 | 1038 | | |
1026 | 1039 | | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
1027 | 1047 | | |
1028 | 1048 | | |
1029 | 1049 | | |
| |||
0 commit comments