Premade SciMLOperators
Direct Operator Definitions
Missing docstring for ScalarOperator.IdentityOperator
. Check Documenter's build log for details.
SciMLOperators.NullOperator
— Typestruct NullOperator <: SciMLOperators.AbstractSciMLOperator{Bool}
Operator representing the null function n(u) = 0 * u
SciMLOperators.ScalarOperator
— TypeScalarOperator(val; update_func, accepted_kwargs)
Represents a linear scaling operator that may be applied to a Number
, or an AbstractArray
subtype. Its state is updated by the user-provided update_func
during operator evaluation (L([v,] u, p, t)
), or by calls to update_coefficients[!]
. Both recursively call the update function, update_func
which is assumed to have the signature:
update_func(oldval::Number, u, p, t; <accepted kwargs>) -> newval
The set of keyword-arguments accepted by update_func
must be provided to ScalarOperator
via the kwarg accepted_kwargs
as a tuple of Symbol
s. kwargs
cannot be passed down to update_func
if accepted_kwargs
are not provided.
The user-provided update_func[!]
must not use u
in its computation. Positional argument (u, p, t)
to update_func[!]
are passed down by update_coefficients[!](L, u, p, t)
, where u
is the input-vector to the composite AbstractSciMLOperator
. For that reason, the values of u
, or even shape, may not correspond to the input expected by update_func[!]
. If an operator's state depends on its input vector, then it is, by definition, a nonlinear operator. We recommend sticking such nonlinearities in FunctionOperator.
This topic is further discussed in (this issue)[https://github.com/SciML/SciMLOperators.jl/issues/159].
Interface
Lazy scalar algebra is defined for AbstractSciMLScalarOperator
s. The interface supports lazy addition, subtraction, multiplication and division.
Example
v = zero(4)
u = rand(4)
p = nothing
t = 0.0
val_update = (a, u, p, t; scale = 0.0) -> copy(scale)
α = ScalarOperator(0.0; update_func = val_update; accepted_kwargs = (:scale,))
β = 2 * α + 3 / α
# update L out-of-place, and evaluate
β(u, p, t; scale = 1.0)
# update L in-place and evaluate
β(v, u, p, t; scale = 1.0)
SciMLOperators.MatrixOperator
— TypeRepresents a linear operator given by an AbstractMatrix
that may be applied to an AbstractVecOrMat
. Its state is updated by the user-provided update_func
during operator evaluation (L([v,], u, p, t)
), or by calls to update_coefficients[!](L, u, p, t)
. Both recursively call the update_function
, update_func
which is assumed to have the signature
update_func(A::AbstractMatrix, u, p, t; <accepted kwargs>) -> newA
or
update_func!(A::AbstractMatrix, u, p, t; <accepted kwargs>) -> [modifies A]
The set of keyword-arguments accepted by update_func[!]
must be provided to MatrixOperator
via the kwarg accepted_kwargs
as a tuple of Symbol
s. kwargs
cannot be passed down to update_func[!]
if accepted_kwargs
are not provided.
The user-provided update_func[!]
must not use u
in its computation. Positional argument (u, p, t)
to update_func[!]
are passed down by update_coefficients[!](L, u, p, t)
, where u
is the input-vector to the composite AbstractSciMLOperator
. For that reason, the values of u
, or even shape, may not correspond to the input expected by update_func[!]
. If an operator's state depends on its input vector, then it is, by definition, a nonlinear operator. We recommend sticking such nonlinearities in FunctionOperator.
This topic is further discussed in (this issue)[https://github.com/SciML/SciMLOperators.jl/issues/159].
Interface
Lazy matrix algebra is defined for AbstractSciMLOperator
s. The Interface supports lazy addition, subtraction, multiplication, inversion, adjoints, transposes.
Example
Out-of-place update and usage
u = rand(4)
p = rand(4, 4)
t = rand()
mat_update = (A, u, p, t; scale = 0.0) -> t * p
M = MatrixOperator(0.0; update_func = mat_update; accepted_kwargs = (:scale,))
L = M * M + 3I
L = cache_operator(M, u)
# update L and evaluate
v = L(u, p, t; scale = 1.0)
In-place update and usage
v = zero(4)
u = rand(4)
p = nothing
t = rand()
mat_update! = (A, u, p, t; scale = 0.0) -> (copy!(A, p); lmul!(t, A))
M = MatrixOperator(zeros(4, 4); update_func! = val_update!; accepted_kwargs = (:scale,))
L = M * M + 3I
# update L in-place and evaluate
L(v, u, p, t; scale = 1.0)
SciMLOperators.DiagonalOperator
— FunctionDiagonalOperator(
diag;
update_func,
update_func!,
accepted_kwargs
)
Represents an elementwise scaling (diagonal-scaling) operation that may be applied to an AbstractVecOrMat
. When diag
is an AbstractVector
of length N, L = DiagonalOperator(diag, ...)
can be applied to AbstractArray
s with size(u, 1) == N
. Each column of the u
will be scaled by diag
, as in LinearAlgebra.Diagonal(diag) * u
.
When diag
is a multidimensional array, L = DiagonalOperator(diag, ...)
forms an operator of size (N, N)
where N = size(diag, 1)
is the leading length of diag
. L
then is the elementwise-scaling operation on arrays of length(u) = length(diag)
with leading length size(u, 1) = N
.
Its state is updated by the user-provided update_func
during operator evaluation (L([v,], u, p, t)
), or by calls to update_coefficients[!](L, u, p, t)
. Both recursively call the update_function
, update_func
which is assumed to have the signature
update_func(diag::AbstractVecOrMat, u, p, t; <accepted kwargs>) -> new_diag
or
update_func!(diag::AbstractVecOrMat, u, p, t; <accepted kwargs>) -> [modifies diag]
The set of keyword-arguments accepted by update_func[!]
must be provided to MatrixOperator
via the kwarg accepted_kwargs
as a tuple of Symbol
s. kwargs
cannot be passed down to update_func[!]
if accepted_kwargs
are not provided.
The user-provided update_func[!]
must not use u
in its computation. Positional argument (u, p, t)
to update_func[!]
are passed down by update_coefficients[!](L, u, p, t)
, where u
is the input-vector to the composite AbstractSciMLOperator
. For that reason, the values of u
, or even shape, may not correspond to the input expected by update_func[!]
. If an operator's state depends on its input vector, then it is, by definition, a nonlinear operator. We recommend sticking such nonlinearities in FunctionOperator.
This topic is further discussed in (this issue)[https://github.com/SciML/SciMLOperators.jl/issues/159].
Example
SciMLOperators.AffineOperator
— TypeRepresents a generalized affine operation (v = A * u + B * b
) that may be applied to an AbstractVecOrMat
. The user-provided update functions, update_func[!]
update the AbstractVecOrMat
b
, and are called during operator evaluation (L([v,], u, p, t)
), or by calls to update_coefficients[!](L, u, p, t)
. The update functions are assumed to have the syntax
update_func(b::AbstractVecOrMat, u, p, t; <accepted kwargs>) -> new_b
or
update_func!(b::AbstractVecOrMat, u ,p , t; <accepted kwargs>) -> [modifies b]
and B
, b
are expected to have an appropriate size so that A * u + B * b
makes sense. Specifically, size(A, 1) == size(B, 1)
, and size(u, 2) == size(b, 2)
.
The set of keyword-arguments accepted by update_func[!]
must be provided to AffineOperator
via the kwarg accepted_kwargs
as a tuple of Symbol
s. kwargs
cannot be passed down to update_func[!]
if accepted_kwargs
are not provided.
Example
u = rand(4)
p = rand(4)
t = rand()
A = MatrixOperator(rand(4, 4))
B = MatrixOperator(rand(4, 4))
vec_update_func = (b, u, p, t) -> p * t
L = AffineOperator(A, B, zero(4); update_func = vec_update_func)
L = cache_operator(M, u)
# update L and evaluate
v = L(u, p, t) # == A * u + B * (p * t)
SciMLOperators.AddVector
— FunctionAddVector(b; update_func, update_func!, accepted_kwargs)
Represents the affine operation v = I * u + I * b
. The update functions, update_func[!]
update the state of AbstractVecOrMat
b
. See documentation of AffineOperator
for more details.
AddVector(B, b; update_func, update_func!, accepted_kwargs)
Represents the affine operation v = I * u + B * b
. The update functions, update_func[!]
update the state of AbstractVecOrMat
b
. See documentation of AffineOperator
for more details.
SciMLOperators.FunctionOperator
— TypeMatrix free operator given by a function
op
: Function with signature op(u, p, t) and (if isinplace) op(v, u, p, t)op_adjoint
: Adjoint operatorop_inverse
: Inverse operatorop_adjoint_inverse
: Adjoint inverse operatortraits
: Traitsp
: Parameterst
: Timecache
: Cache
SciMLOperators.TensorProductOperator
— TypeComputes the lazy pairwise Kronecker product, or tensor product, operator of AbstractMatrix
, and AbstractSciMLOperator
subtypes. Calling ⊗(ops...)
is equivalent to Base.kron(ops...)
. Fast operator evaluation is performed without forming the full tensor product operator.
TensorProductOperator(A, B) = A ⊗ B
TensorProductOperator(A, B, C) = A ⊗ B ⊗ C
(A ⊗ B)(u) = vec(B * reshape(u, M, N) * transpose(A))
where M = size(B, 2)
, and N = size(A, 2)
Lazy Scalar Operator Combination
SciMLOperators.AddedScalarOperator
— Typestruct AddedScalarOperator{T, O} <: SciMLOperators.AbstractSciMLScalarOperator{T}
Lazy addition of AbstractSciMLScalarOperator
s
SciMLOperators.ComposedScalarOperator
— Typestruct ComposedScalarOperator{T, O} <: SciMLOperators.AbstractSciMLScalarOperator{T}
Lazy multiplication of AbstractSciMLScalarOperator
s
SciMLOperators.InvertedScalarOperator
— Typestruct InvertedScalarOperator{T, λType} <: SciMLOperators.AbstractSciMLScalarOperator{T}
Lazy inverse of AbstractSciMLScalarOperator
s
Lazy Operator Combination
SciMLOperators.ScaledOperator
— Typestruct ScaledOperator{T, λType, LType} <: SciMLOperators.AbstractSciMLOperator{T}
ScaledOperator
(λ L)*(u) = λ * L(u)
SciMLOperators.AddedOperator
— TypeLazy operator addition
(A1 + A2 + A3...)u = A1*u + A2*u + A3*u ....
SciMLOperators.ComposedOperator
— TypeLazy operator composition
∘(A, B, C)(u) = A(B(C(u)))
ops = (A, B, C)
cache = (B*C*u , C*u)
SciMLOperators.InvertedOperator
— TypeLazy Operator Inverse
SciMLOperators.InvertibleOperator
— TypeStores an operator and its factorization (or inverse operator). Supports left division and ldiv!
via F
, and operator evaluation via L
.
SciMLOperators.AdjointOperator
— Typestruct AdjointOperator{T, LType} <: SciMLOperators.AbstractSciMLOperator{T}
SciMLOperators.TransposedOperator
— Typestruct TransposedOperator{T, LType} <: SciMLOperators.AbstractSciMLOperator{T}