Skip to content

Commit 6cff2ab

Browse files
committed
func
1 parent 4d0b69d commit 6cff2ab

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/func.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,28 @@ mutable struct FunctionOperator{iip,oop,T<:Number,F,Fa,Fi,Fai,Tr,P,Tt,C} <: Abst
6666
end
6767
end
6868

69+
function FunctionOperator(op,
70+
input::AbstractArray{<:Any,D},
71+
output::AbstractArray{<:Any,D};
72+
kwargs...) where{D}
73+
D 2 && @error "FunctionOperator not defined for $(typeof(input)), $(typeof(output))."
74+
75+
NK = length(input)
76+
MK = length(output)
77+
78+
M = size(output, 1)
79+
N = size(input, 1)
80+
81+
K = NK ÷ N
82+
83+
@assert MK == M * K
84+
85+
input = reshape(input, (N, K))
86+
output = reshape(output, (M, K))
87+
88+
FunctionOperator(op, input, output; kwargs...)
89+
end
90+
6991
function FunctionOperator(op,
7092
input::AbstractVecOrMat,
7193
output::AbstractVecOrMat;

src/interface.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ function cache_operator(L::AbstractSciMLOperator, u::AbstractVecOrMat)
5151
end
5252

5353
function cache_operator(L::AbstractSciMLOperator, u::AbstractArray)
54+
u isa AbstractVecOrMat && @error "cache_operator not defined for $(typeof(L)), $(typeof(u))."
55+
5456
n = size(L, 2)
5557
s = size(u)
5658
k = prod(s[2:end])

0 commit comments

Comments
 (0)