-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathtest_dot.jl
42 lines (33 loc) · 1.06 KB
/
test_dot.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module TestDot
using BandedMatrices, LinearAlgebra, FillArrays, Test
import BandedMatrices: _BandedMatrix
using Random
@testset "dot(x, A::BandedMatrix, y)" begin
Random.seed!(0)
@testset "Single, constant diagonal" begin
for (m,n,l) in [(100,15,5),(15,100,-5)]
S = _BandedMatrix(0.1Ones{Int}(1,n), Base.OneTo(m), l, -l)
MS = Matrix(S)
a = rand(ComplexF64, m)
b = rand(ComplexF64, n)
v = dot(a, MS, b)
ref = dot(a, S, b)
@test v ≈ ref rtol=1e-14
end
end
@testset "Multiple, random diagonals" begin
for cols in [2000,500]
for (l,u) in [(3,-1), (1,1), (-1,3)]
S = _BandedMatrix(rand(3,cols), Base.OneTo(1000), l, u)
MS = Matrix(S)
m,n = size(S)
a = rand(ComplexF64, m)
b = rand(ComplexF64, n)
v = dot(a, S, b)
ref = dot(a, MS, b)
@test v ≈ ref rtol=1e-14
end
end
end
end
end # module