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
```
Copy file name to clipboardExpand all lines: stdlib/LinearAlgebra/test/triangular.jl
+23-3Lines changed: 23 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ debug && println("Test basic type functionality")
26
26
@testLowerTriangular(randn(3, 3)) |> t -> [size(t, i) for i =1:3] == [size(Matrix(t), i) for i =1:3]
27
27
28
28
# 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.
29
-
for elty1 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}, Int)
29
+
@testsetfor elty1 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}, Int)
30
30
# Begin loop for first Triangular matrix
31
31
for (t1, uplo1) in ((UpperTriangular, :U),
32
32
(UnitUpperTriangular, :U),
@@ -998,9 +998,12 @@ end
998
998
999
999
@testset"arithmetic with partly uninitialized matrices"begin
1000
1000
@testset"$(typeof(A))"for A in (Matrix{BigFloat}(undef,2,2), Matrix{Complex{BigFloat}}(undef,2,2)')
0 commit comments