Skip to content

Commit 9a92f02

Browse files
Merge pull request #147 from vpuri3/ff
FunctionOperator fixes
2 parents 1f408a0 + 730eef6 commit 9a92f02

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/func.jl

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,29 @@ function FunctionOperator(op,
171171
)
172172
end
173173

174+
function update_coefficients(L, u, p, t)
175+
op = update_coefficients(L.op, u, p, t)
176+
op_adjoint = update_coefficients(L.op_adjoint, u, p, t)
177+
op_inverse = update_coefficients(L.op_inverse, u, p, t)
178+
op_adjoint_inverse = update_coefficients(L.op_adjoint_inverse, u, p, t)
179+
180+
FunctionOperator(op,
181+
op_adjoint,
182+
op_inverse,
183+
op_adjoint_inverse,
184+
L.traits,
185+
p,
186+
t,
187+
L.cache
188+
)
189+
end
190+
174191
function update_coefficients!(L::FunctionOperator, u, p, t)
192+
ops = getops(L)
193+
for op in ops
194+
update_coefficients!(op, u, p, t)
195+
end
196+
175197
L.p = p
176198
L.t = t
177199

@@ -273,7 +295,18 @@ LinearAlgebra.issymmetric(L::FunctionOperator) = L.traits.issymmetric
273295
LinearAlgebra.ishermitian(L::FunctionOperator) = L.traits.ishermitian
274296
LinearAlgebra.isposdef(L::FunctionOperator) = L.traits.isposdef
275297

276-
getops(::FunctionOperator) = ()
298+
function getops(L::FunctionOperator)
299+
ops = (L.op,)
300+
301+
ops = isa(L.op_adjoint, Nothing) ? ops : (ops..., L.op_adjoint)
302+
ops = isa(L.op_inverse, Nothing) ? ops : (ops..., L.op_inverse)
303+
ops = isa(L.op_adjoint_inverse, Nothing) ? ops : (ops..., L.op_adjoint_inverse)
304+
305+
ops
306+
end
307+
308+
#TODO - isconstant(L::FunctionOperator)
309+
iscached(::FunctionOperator) = true
277310
islinear(L::FunctionOperator) = L.traits.islinear
278311
has_adjoint(L::FunctionOperator) = !(L.op_adjoint isa Nothing)
279312
has_mul(L::FunctionOperator{iip}) where{iip} = true

0 commit comments

Comments
 (0)