You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
```
(cherry picked from commit cc74d24)
Copy file name to clipboardExpand all lines: stdlib/LinearAlgebra/test/triangular.jl
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ debug && println("Test basic type functionality")
18
18
@testLowerTriangular(randn(3, 3)) |> t -> [size(t, i) for i =1:3] == [size(Matrix(t), i) for i =1:3]
19
19
20
20
# The following test block tries to call all methods in base/linalg/triangular.jl in order for a combination of input element types. Keep the ordering when adding code.
21
-
for elty1 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}, Int)
21
+
@testsetfor elty1 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}, Int)
0 commit comments