Skip to content

Commit 5567504

Browse files
authored
Backports to v1.12 (#1472)
2 parents 24f5e21 + a2a4981 commit 5567504

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

src/adjtrans.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,3 +560,8 @@ diagview(A::Adjoint, k::Integer = 0) = _vecadjoint(diagview(parent(A), -k))
560560
# triu and tril
561561
triu!(A::AdjOrTransAbsMat, k::Integer = 0) = wrapperop(A)(tril!(parent(A), -k))
562562
tril!(A::AdjOrTransAbsMat, k::Integer = 0) = wrapperop(A)(triu!(parent(A), -k))
563+
564+
function fillstored!(A::AdjOrTransAbsMat, v)
565+
fillstored!(parent(A), wrapperop(A)(v))
566+
return A
567+
end

src/bunchkaufman.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ BunchKaufman{T}(B::BunchKaufman) where {T} =
215215
BunchKaufman(convert(Matrix{T}, B.LD), B.ipiv, B.uplo, B.symmetric, B.rook, B.info)
216216
Factorization{T}(B::BunchKaufman) where {T} = BunchKaufman{T}(B)
217217

218+
AbstractMatrix(B::BunchKaufman) = B.uplo == 'U' ? B.P'B.U*B.D*B.U'B.P : B.P'B.L*B.D*B.L'B.P
219+
AbstractArray(B::BunchKaufman) = AbstractMatrix(B)
220+
Matrix(B::BunchKaufman) = convert(Array, AbstractArray(B))
221+
Array(B::BunchKaufman) = Matrix(B)
222+
223+
218224
size(B::BunchKaufman) = size(getfield(B, :LD))
219225
size(B::BunchKaufman, d::Integer) = size(getfield(B, :LD), d)
220226
issymmetric(B::BunchKaufman) = B.symmetric

src/cholesky.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ Factorization{T}(C::CholeskyPivoted) where {T} = CholeskyPivoted{T}(C)
646646

647647
AbstractMatrix(C::Cholesky) = C.uplo == 'U' ? C.U'C.U : C.L*C.L'
648648
AbstractArray(C::Cholesky) = AbstractMatrix(C)
649-
Matrix(C::Cholesky) = Array(AbstractArray(C))
649+
Matrix(C::Cholesky) = convert(Array, AbstractArray(C))
650650
Array(C::Cholesky) = Matrix(C)
651651

652652
function AbstractMatrix(F::CholeskyPivoted)
@@ -655,7 +655,7 @@ function AbstractMatrix(F::CholeskyPivoted)
655655
U'U
656656
end
657657
AbstractArray(F::CholeskyPivoted) = AbstractMatrix(F)
658-
Matrix(F::CholeskyPivoted) = Array(AbstractArray(F))
658+
Matrix(F::CholeskyPivoted) = convert(Array, AbstractArray(F))
659659
Array(F::CholeskyPivoted) = Matrix(F)
660660

661661
copy(C::Cholesky) = Cholesky(copy(C.factors), C.uplo, C.info)

src/dense.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ function fillband!(A::AbstractMatrix{T}, x, l, u) where T
218218
return A
219219
end
220220

221+
fillstored!(A::AbstractMatrix, v) = fill!(A, v)
222+
221223
diagind(m::Integer, n::Integer, k::Integer=0) = diagind(IndexLinear(), m, n, k)
222224
diagind(::IndexLinear, m::Integer, n::Integer, k::Integer=0) =
223225
k <= 0 ? range(1-k, step=m+1, length=min(m+k, n)) : range(k*m+1, step=m+1, length=min(m, n-k))

test/adjtrans.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,4 +771,15 @@ end
771771
end
772772
end
773773

774+
@testset "fillstored!" begin
775+
A = rand(ComplexF64, 4, 4)
776+
U = UpperTriangular(A)
777+
@testset for (op, f) in ((Adjoint, adjoint), (Transpose, transpose))
778+
@test LinearAlgebra.fillstored!(op(A), 1) == op(fill(1, size(A)))
779+
@test LinearAlgebra.fillstored!(op(A), 2im) == op(fill(f(2im), size(A)))
780+
@test LinearAlgebra.fillstored!(op(U), 1) == op(triu(fill(1, size(U))))
781+
@test LinearAlgebra.fillstored!(op(U), 2im) == op(triu(fill(f(2im), size(U))))
782+
end
783+
end
784+
774785
end # module TestAdjointTranspose

test/bunchkaufman.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,13 @@ end
259259
@test B.U * B.D * B.U' S
260260
end
261261

262+
@testset "BunchKaufman array constructors #1461" begin
263+
a = randn(5,5)
264+
A = a'a
265+
for ul in (:U, :L)
266+
B = bunchkaufman(Symmetric(A, ul))
267+
@test A Array(B) Matrix(B) AbstractArray(B) AbstractMatrix(B)
268+
end
269+
end
270+
262271
end # module TestBunchKaufman

0 commit comments

Comments
 (0)