Skip to content

Commit 734205b

Browse files
committed
add tests
1 parent 664d609 commit 734205b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/func.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,9 @@ function _unvec(L::FunctionOperator, u, v)
619619

620620
if !isnothing(u) & !isnothing(v)
621621
if (vec_u & !vec_v) | (!vec_u & vec_v)
622-
msg = """Input/output to $L can either be of sizes
623-
$(sizes[1])/ $(sizes[2]), or
624-
$(tuple(prod(sizes[1])))/ $(tuple(prod(sizes[2]))). Got
622+
msg = """Input / output to $L can either be of sizes
623+
$(sizes[1]) / $(sizes[2]), or
624+
$(tuple(prod(sizes[1]))) / $(tuple(prod(sizes[2]))). Got
625625
$(size(u)), $(size(v))."""
626626
throw(DimensionMismatch(msg))
627627
end

test/func.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,25 @@ NK = N * K
4747
L = FunctionOperator(f, u, v; kw...)
4848
L = cache_operator(L, u)
4949

50+
# test with ND-arrays
5051
@test _mul(A, u) L(u, p, t) L * u mul!(zero(v), L, u)
5152
@test α * _mul(A, u)+ β * v mul!(copy(v), L, u, α, β)
5253

5354
if sz_in == sz_out
5455
@test _div(A, v) L \ v ldiv!(zero(u), L, v) ldiv!(L, copy(v))
5556
end
56-
end
57+
58+
# test with vec(Array)
59+
@test vec(_mul(A, u)) L(vec(u), p, t) L * vec(u) mul!(vec(zero(v)), L, vec(u))
60+
@test vec* _mul(A, u)+ β * v) mul!(vec(copy(v)), L, vec(u), α, β)
61+
62+
if sz_in == sz_out
63+
@test vec(_div(A, v)) L \ vec(v) ldiv!(vec(zero(u)), L, vec(v)) ldiv!(L, vec(copy(v)))
64+
end
65+
66+
@test_throws DimensionMismatch mul!(vec(v), L, u)
67+
@test_throws DimensionMismatch mul!(v, L, vec(u))
68+
end # for
5769

5870
end
5971

0 commit comments

Comments
 (0)