Skip to content

Commit 24609db

Browse files
Merge pull request #197 from vpuri3/docs
minor fixes
2 parents deab4e8 + 34eacb6 commit 24609db

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/func.jl

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
"""
3-
Matrix free operators (given by a function)
3+
Matrix free operator given by a function
44
55
$(FIELDS)
66
"""
@@ -115,45 +115,36 @@ is assumed to be of the same type and share as the input.
115115
116116
# Keyword Arguments
117117
118-
Keyword arguments are used to pass in the adjoint operator, `op_adjoint`,
119-
the inverse operator, `op_inverse`, and the adjoint-inverse operator
120-
`adjoint_inverse`. All are assumed to have the same calling signature and
118+
Keyword arguments are used to pass in the adjoint evaluation function,
119+
`op_adjoint`, the inverse function, `op_inverse`, and the adjoint-inverse
120+
function `adjoint_inverse`. All are assumed to have the same calling signature and
121121
below traits.
122122
123123
## Traits
124124
Keyword arguments are used to set operator traits, which are assumed to be
125125
uniform across `op`, `op_adjoint`, `op_inverse`, `op_adjoint_inverse`.
126126
127+
* `p` - Prototype of parameter struct passed to the operator during evaluation, i.e. `L(u, p, t)`. `p` is set to `nothing` if no value is provided.
128+
* `t` - Protype of scalar time variable passed to the operator during evaluation. `t` is set to `zero(T)` if no value is provided.
129+
* `accepted_kwargs` - `Tuple` of `Symbol`s corresponding to the keyword arguments accepted by `op*`, and `update_coefficients[!]`. For example, if `op` accepts kwarg `scale`, as in `op(u, p, t; scale)`, then `accepted_kwargs = (:scale,)`.
130+
131+
* `T` - `eltype` of the operator. If no value is provided, the constructor inferrs the value from types of `input`, and `output`
127132
* `isinplace` - `true` if the operator can be used is a mutating way with in-place allocations. This trait is inferred if no value is provided.
128133
* `outofplace` - `true` if the operator can be used is a non-mutating way with in-place allocations. This trait is inferred if no value is provided.
129-
* `isconstant` - `true` if the operator is constant, and doesn't need to be updated via `update_coefficients[!]` during operator evaluation.
130134
* `has_mul5` - `true` if the operator provides a five-argument `mul!` via the signature `op(v, u, p, t, α, β; <accepted_kwargs>)`. This trait is inferred if no value is provided.
131-
* `cache` - Pregenerated cache arrays for in-place evaluations. Expected to be of type and shape `(similar(input), similar(output),)`. The constructor generates cache if no values are provided. Cache generation by the constructor can be disabled by setting the kwarg `ifcache = false`.
132-
* `T` - `eltype` of the operator. If no value is provided, the constructor inferrs the value from types of `input`, and `output`
133-
* `p` - Prototype of parameter struct passed to the operator during evaluation, i.e. `L(u, p, t)`. `p` is set to `nothing` if no value is provided.
134-
* `t` - Protype of scalar time variable passed to the operator during evaluation. `t` is set to `zero(T)` if no value is provided.
135-
* `ifcache` - Allocate cache arrays in constructor. Defaults to `true`. Cache can be generated afterwards by calling `cache_operator(L, input, output)`
135+
* `isconstant` - `true` if the operator is constant, and doesn't need to be updated via `update_coefficients[!]` during operator evaluation.
136136
* `islinear` - `true` if the operator is linear. Defaults to `false`.
137+
* `ifcache` - Allocate cache arrays in constructor. Defaults to `true`. Cache can be generated afterwards by calling `cache_operator(L, input, output)`
138+
* `cache` - Pregenerated cache arrays for in-place evaluations. Expected to be of type and shape `(similar(input), similar(output),)`. The constructor generates cache if no values are provided. Cache generation by the constructor can be disabled by setting the kwarg `ifcache = false`.
137139
* `opnorm` - The norm of `op`. Can be a `Number`, or function `opnorm(p::Integer)`. Defaults to `nothing`.
138140
* `issymmetric` - `true` if the operator is linear and symmetric. Defaults to `false`.
139141
* `ishermitian` - `true` if the operator is linear and hermitian. Defaults to `false`.
140142
* `isposdef` - `true` if the operator is linear and positive-definite. Defaults to `false`.
141-
142-
Cache arrays can optionally be passed in via the
143-
kwarg `cache`, and
144-
disabled by passing the kwarg `cach`
145143
"""
146144
function FunctionOperator(op,
147145
input::AbstractVecOrMat,
148146
output::AbstractVecOrMat = input;
149147

150-
isinplace::Union{Nothing,Bool}=nothing,
151-
outofplace::Union{Nothing,Bool}=nothing,
152-
isconstant::Bool = false,
153-
has_mul5::Union{Nothing,Bool}=nothing,
154-
cache::Union{Nothing, NTuple{2}}=nothing,
155-
T::Union{Type{<:Number},Nothing}=nothing,
156-
157148
op_adjoint=nothing,
158149
op_inverse=nothing,
159150
op_adjoint_inverse=nothing,
@@ -162,11 +153,18 @@ function FunctionOperator(op,
162153
t::Union{Number,Nothing}=nothing,
163154
accepted_kwargs::NTuple{N,Symbol} = (),
164155

165-
ifcache::Bool = true,
166-
167156
# traits
157+
T::Union{Type{<:Number},Nothing}=nothing,
158+
isinplace::Union{Nothing,Bool}=nothing,
159+
outofplace::Union{Nothing,Bool}=nothing,
160+
has_mul5::Union{Nothing,Bool}=nothing,
161+
isconstant::Bool = false,
168162
islinear::Bool = false,
169163

164+
ifcache::Bool = true,
165+
cache::Union{Nothing, NTuple{2}}=nothing,
166+
167+
# LinearAlgebra traits
170168
opnorm = nothing,
171169
issymmetric::Bool = false,
172170
ishermitian::Bool = false,

src/matrix.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ adjoints, transposes.
2828
2929
# Example
3030
31+
Out-of-place update and usage
3132
```
3233
u = rand(4)
3334
p = rand(4, 4)
@@ -43,6 +44,7 @@ L = cache_operator(M, u)
4344
v = L(u, p, t; scale = 1.0)
4445
```
4546
47+
In-place update and usage
4648
```
4749
v = zero(4)
4850
u = rand(4)

0 commit comments

Comments
 (0)