Skip to content

Commit 029292b

Browse files
committed
tests
1 parent 6d0a8d7 commit 029292b

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

test/basic.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ K = 12
3131
@test one(A) isa IdentityOperator{N}
3232
@test convert(AbstractMatrix, Id) == Matrix(I, N, N)
3333

34+
@test iscached(Id)
3435
@test size(Id) == (N, N)
3536
@test Id' isa IdentityOperator{N}
3637

@@ -65,6 +66,7 @@ end
6566
@test zero(A) isa NullOperator{N}
6667
@test convert(AbstractMatrix, Z) == zeros(size(Z))
6768

69+
@test iscached(Z)
6870
@test size(Z) == (N, N)
6971
@test Z' isa NullOperator{N}
7072

@@ -99,13 +101,15 @@ end
99101
op = ScaledOperator(α, MatrixOperator(A))
100102

101103
@test op isa ScaledOperator
104+
@test iscached(op)
102105

103106
@test α * A * u op * u
104107
@test* op) * u β * α * A * u
105108

106109
opF = factorize(op)
107110

108111
@test opF isa ScaledOperator
112+
@test iscached(opF)
109113

110114
@test α * A convert(AbstractMatrix, op) convert(AbstractMatrix, opF)
111115

@@ -145,6 +149,8 @@ end
145149
end
146150

147151
op = AddedOperator(A, B)
152+
@test iscached(op)
153+
148154
v=rand(N,K); @test mul!(v, op, u) (A+B) * u
149155
v=rand(N,K); w=copy(v); @test mul!(v, op, u, α, β) α*(A+B)*u + β*w
150156
end
@@ -172,7 +178,10 @@ end
172178
@test ABCmulu op * u
173179
@test ABCdivu op \ u opF \ u
174180

181+
@test !iscached(op)
175182
op = cache_operator(op, u)
183+
@test iscached(op)
184+
176185
v=rand(N,K); @test mul!(v, op, u) ABCmulu
177186
v=rand(N,K); w=copy(v); @test mul!(v, op, u, α, β) α*ABCmulu + β*w
178187

@@ -181,7 +190,9 @@ end
181190
C = rand(N) |> Diagonal
182191

183192
op = (MatrixOperator.((A, B, C))...)
193+
@test !iscached(op)
184194
op = cache_operator(op, u)
195+
@test iscached(op)
185196
v=rand(N,K); @test ldiv!(v, op, u) (A * B * C) \ u
186197
v=copy(u); @test ldiv!(op, u) (A * B * C) \ v
187198

@@ -195,7 +206,9 @@ end
195206
@test_throws MethodError inner_op * u
196207
# We can now test that caching does not rely on matmul
197208
op = inner_op * factorize(MatrixOperator(rand(N, N)))
209+
@test !iscached(op)
198210
@test_nowarn op = cache_operator(op, rand(N))
211+
@test iscached(op)
199212
u = rand(N)
200213
@test ldiv!(rand(N), op, u) op \ u
201214
end
@@ -245,7 +258,9 @@ end
245258
α = rand()
246259
β = rand()
247260

261+
@test !iscached(Di)
248262
Di = cache_operator(Di, u)
263+
@test iscached(Di)
249264

250265
@test Di * u u ./ s
251266
v=rand(N); @test mul!(v, Di, u) u ./ s

test/func.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ K = 12
6262
@test has_ldiv(op2)
6363
@test has_ldiv!(op2)
6464

65-
op2 = cache_operator(op2, u)
65+
@test iscached(op1)
66+
@test iscached(op2)
6667

6768
v = rand(N,K); @test A * u op1 * u mul!(v, op2, u)
6869
v = rand(N,K); @test A * u op1(u,p,t) op2(v,u,p,t)

test/matrix.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,24 @@ for square in [false, true] #for K in [1, K]
207207
@test AB \ v2 opAB \ v2 opAB_F \ v2
208208
@test ABC \ v3 opABC \ v3 opABC_F \ v3
209209

210+
@test !iscached(opAB)
211+
@test !iscached(opABC)
212+
213+
@test !iscached(opAB_F)
214+
@test !iscached(opABC_F)
215+
210216
opAB = cache_operator(opAB, u2)
211217
opABC = cache_operator(opABC, u3)
212218

213219
opAB_F = cache_operator(opAB_F, u2)
214220
opABC_F = cache_operator(opABC_F, u3)
215221

222+
@test iscached(opAB)
223+
@test iscached(opABC)
224+
225+
@test iscached(opAB_F)
226+
@test iscached(opABC_F)
227+
216228
N2 = n1*n2
217229
N3 = n1*n2*n3
218230
M2 = m1*m2

test/scalar.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ K = 12
1414
u = rand(N,K)
1515

1616
@test α isa ScalarOperator
17+
@test iscached(α)
1718
@test convert(Number, α) isa Number
1819
@test convert(ScalarOperator, a) isa ScalarOperator
1920

0 commit comments

Comments
 (0)