Skip to content

Commit 6f6052d

Browse files
committed
add tests
1 parent fb46a43 commit 6f6052d

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

test/linalg.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,42 @@ end
147147
end
148148
end
149149

150+
@testset "destination array density in solves" begin
151+
O = diagm(-1 => fill(-1, 9), 0 => fill(2, 10), 1 => fill(-1, 9))
152+
wrappers = (a -> Bidiagonal(a, :U),
153+
a -> Bidiagonal(a, :L),
154+
a -> SymTridiagonal(2diag(a), -diag(a, 1)),
155+
a -> Tridiagonal(-diag(a, -1), 2diag(a), -diag(a, 1)),
156+
LowerTriangular,
157+
UnitLowerTriangular,
158+
UpperTriangular,
159+
UnitUpperTriangular,
160+
UpperHessenberg)
161+
for T in wrappers
162+
A = T(O)
163+
bs = sprandn(10, 0.3)
164+
bd = Array(bs)
165+
x = A \ bs
166+
@test x A \ bd
167+
@test !issparse(x)
168+
Bs = sprandn(10, 3, 0.2)
169+
Bd = Matrix(Bs)
170+
X = A \ Bs
171+
@test X A \ Bd
172+
@test !issparse(X)
173+
Cs = copy(Bs')
174+
Cd = Matrix(Cs)
175+
Y = Cs / A
176+
@test Y Cd / A
177+
@test !issparse(Y)
178+
end
179+
b, B = ones(Int, 10), ones(Int, 10, 10)
180+
for T in (UnitLowerTriangular, UnitUpperTriangular)
181+
A = T(O)
182+
@test eltype(A \ b) == eltype(A \ B) == eltype(B / A) == Int
183+
end
184+
end
185+
150186
@testset "multiplication of special sparse with dense matrix" begin
151187
# this results in a call of the most generic multiplication code in LinearAlgebra.jl
152188
A = randn(2, 2)
@@ -228,6 +264,7 @@ begin
228264
AW = tr(wr(A))
229265
MAW = tr(wr(MA))
230266
@test AW \ B MAW \ B
267+
@test !issparse(AW \ B)
231268
# and for SparseMatrixCSCView - a view of all rows and unit range of cols
232269
vAW = tr(wr(view([zero(A)+I A], :, (n+1):2n)))
233270
@test vAW \ B AW \ B

0 commit comments

Comments
 (0)