Skip to content

Commit 60e3201

Browse files
authored
Add tests for 5-arg mul (#350)
* Add tests for 5-arg mul * isapprox for real
1 parent 45a5873 commit 60e3201

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

test/test_linalg.jl

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ import BandedMatrices: BandedColumns, _BandedMatrix
4141
@test bandwidths(UpperTriangular(A)*A) == (1,4)
4242
end
4343

44+
@testset "BandedMatrix * dense" begin
45+
for T in [Float64, Int]
46+
cmp = T <: Integer ? (==) : ()
47+
B = brand(T, 10,10,2,2)
48+
M = Matrix(B)
49+
v = rand(T, 10)
50+
Bv = M * v
51+
@test cmp(B * v, Bv)
52+
w = similar(v)
53+
@test cmp(mul!(w, B, v), Bv)
54+
@test cmp(mul!(w, B, v, true, false), Bv)
55+
56+
X = rand(T, 10, 10)
57+
BX = M * X
58+
@test cmp(B * X, BX)
59+
Y = similar(X)
60+
@test cmp(mul!(Y, B, X), BX)
61+
@test cmp(mul!(Y, B, X, true, false), BX)
62+
end
63+
end
64+
4465
@testset "gbmm!" begin
4566
@testset "gbmm! subpieces step by step and column by column" begin
4667
for n in (1,5,50), ν in (1,5,50), m in (1,5,50),
@@ -133,7 +154,10 @@ import BandedMatrices: BandedColumns, _BandedMatrix
133154
B = brand(10,10,-2,2)
134155
C = BandedMatrix(Fill(NaN,10,10),(0,4))
135156
mul!(C,A,B)
136-
@test C Matrix(A)*Matrix(B)
157+
AB = Matrix(A)*Matrix(B)
158+
@test C AB
159+
mul!(C,A,B,true,false)
160+
@test C AB
137161

138162
A = brand(10,10,-2,2)
139163
B = brand(10,10,-2,2)
@@ -180,7 +204,11 @@ import BandedMatrices: BandedColumns, _BandedMatrix
180204

181205
mul!(C,A,B)
182206

183-
@test all(C .=== A*B)
207+
AB = A*B
208+
@test C == AB
209+
210+
mul!(C,A,B,true,false)
211+
@test C == AB
184212

185213
A[band(1)] .= randn(9)
186214
@test_throws BandError mul!(C,A,B)

0 commit comments

Comments
 (0)