Skip to content

Commit 0c68b47

Browse files
fix test setup
1 parent 5d5de01 commit 0c68b47

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

src/array_partition.jl

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Base.zero(A::ArrayPartition, dims::NTuple{N,Int}) where {N} = zero(A)
9090

9191
## Array
9292

93-
Base.Array(A::ArrayPartition) = ArrayPartition(Array.(A.x))
93+
Base.Array(A::ArrayPartition) = reduce(vcat,Array.(A.x))
9494
Base.Array(VA::AbstractVectorOfArray{T,N,A}) where {T,N,A <: AbstractVector{<:ArrayPartition}} = reduce(hcat,Array.(VA.u))
9595

9696
## ones
@@ -390,13 +390,13 @@ end
390390
# [U11 U12 U13] [ b1 ]
391391
# [ 0 U22 U23] \ [ b2 ]
392392
# [ 0 0 U33] [ b3 ]
393-
function LinearAlgebra.ldiv!(A::T, bb::ArrayPartition) where T<:Union{UnitUpperTriangular,UpperTriangular}
393+
function LinearAlgebra.ldiv!(A::UnitUpperTriangular, bb::ArrayPartition)
394394
A = A.data
395395
n = npartitions(bb)
396396
b = bb.x
397397
lens = map(length, b)
398398
@inbounds for j in n:-1:1
399-
Ajj = T(getblock(A, lens, j, j))
399+
Ajj = UnitUpperTriangular(getblock(A, lens, j, j))
400400
xj = ldiv!(Ajj, vec(b[j]))
401401
for i in j-1:-1:1
402402
Aij = getblock(A, lens, i, j)
@@ -407,13 +407,30 @@ function LinearAlgebra.ldiv!(A::T, bb::ArrayPartition) where T<:Union{UnitUpperT
407407
return bb
408408
end
409409

410-
function LinearAlgebra.ldiv!(A::T, bb::ArrayPartition) where T<:Union{UnitLowerTriangular,LowerTriangular}
410+
function LinearAlgebra.ldiv!(A::UpperTriangular, bb::ArrayPartition)
411+
A = A.data
412+
n = npartitions(bb)
413+
b = bb.x
414+
lens = map(length, b)
415+
@inbounds for j in n:-1:1
416+
Ajj = UpperTriangular(getblock(A, lens, j, j))
417+
xj = ldiv!(Ajj, vec(b[j]))
418+
for i in j-1:-1:1
419+
Aij = getblock(A, lens, i, j)
420+
# bi = -Aij * xj + bi
421+
mul!(vec(b[i]), Aij, xj, -1, true)
422+
end
423+
end
424+
return bb
425+
end
426+
427+
function LinearAlgebra.ldiv!(A::UnitLowerTriangular, bb::ArrayPartition)
411428
A = A.data
412429
n = npartitions(bb)
413430
b = bb.x
414431
lens = map(length, b)
415432
@inbounds for j in 1:n
416-
Ajj = T(getblock(A, lens, j, j))
433+
Ajj = UnitLowerTriangular(getblock(A, lens, j, j))
417434
xj = ldiv!(Ajj, vec(b[j]))
418435
for i in j+1:n
419436
Aij = getblock(A, lens, i, j)
@@ -423,6 +440,24 @@ function LinearAlgebra.ldiv!(A::T, bb::ArrayPartition) where T<:Union{UnitLowerT
423440
end
424441
return bb
425442
end
443+
444+
function LinearAlgebra.ldiv!(A::LowerTriangular, bb::ArrayPartition)
445+
A = A.data
446+
n = npartitions(bb)
447+
b = bb.x
448+
lens = map(length, b)
449+
@inbounds for j in 1:n
450+
Ajj = LowerTriangular(getblock(A, lens, j, j))
451+
xj = ldiv!(Ajj, vec(b[j]))
452+
for i in j+1:n
453+
Aij = getblock(A, lens, i, j)
454+
# bi = -Aij * xj + b[i]
455+
mul!(vec(b[i]), Aij, xj, -1, true)
456+
end
457+
end
458+
return bb
459+
end
460+
426461
# TODO: optimize
427462
function LinearAlgebra._ipiv_rows!(A::LU, order::OrdinalRange, B::ArrayPartition)
428463
for i = order

test/linalg.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ using LinearAlgebra
44
n, m = 5, 6
55
bb = rand(n), rand(m)
66
b = ArrayPartition(bb)
7+
@test Array(b) isa Array
78
@test Array(b) == collect(b) == vcat(bb...)
89
A = randn(MersenneTwister(123), n+m, n+m)
910

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919

2020
@time begin
2121

22-
if !is_APPVEYOR && GROUP == "Core"
22+
if GROUP == "Core" || GROUP == "All"
2323
@time @testset "Utils Tests" begin include("utils_test.jl") end
2424
@time @testset "Partitions Tests" begin include("partitions_test.jl") end
2525
@time @testset "VecOfArr Indexing Tests" begin include("basic_indexing.jl") end

0 commit comments

Comments
 (0)