Skip to content

Commit 3dc0ae0

Browse files
fix a lot of docstrings
1 parent efdb2e7 commit 3dc0ae0

File tree

5 files changed

+49
-46
lines changed

5 files changed

+49
-46
lines changed

src/basic.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
$(TYPEDEF)
33
4-
Operator representing the identity function `id(u) = u`
4+
Operator representing the identity function `id(v) = v`
55
"""
66
struct IdentityOperator <: AbstractSciMLOperator{Bool}
77
len::Int
@@ -116,7 +116,7 @@ end
116116
"""
117117
$(TYPEDEF)
118118
119-
Operator representing the null function `n(u) = 0 * u`
119+
Operator representing the null function `n(v) = 0 * v`
120120
"""
121121
struct NullOperator <: AbstractSciMLOperator{Bool}
122122
len::Int
@@ -218,7 +218,7 @@ $TYPEDEF
218218
219219
ScaledOperator
220220
221-
(λ L)*(u) = λ * L(u)
221+
(λ L)*(v) = λ * L(v)
222222
"""
223223
struct ScaledOperator{T,
224224
λType,
@@ -417,7 +417,7 @@ end
417417
"""
418418
Lazy operator addition
419419
420-
(A1 + A2 + A3...)u = A1*u + A2*u + A3*u ....
420+
(A1 + A2 + A3...)v = A1*v + A2*v + A3*v ....
421421
"""
422422
struct AddedOperator{T,
423423
O <: Tuple{Vararg{AbstractSciMLOperator}}
@@ -649,10 +649,10 @@ end
649649
"""
650650
Lazy operator composition
651651
652-
∘(A, B, C)(u) = A(B(C(u)))
652+
∘(A, B, C)(v) = A(B(C(v)))
653653
654654
ops = (A, B, C)
655-
cache = (B*C*u , C*u)
655+
cache = (B*C*v , C*v)
656656
"""
657657
struct ComposedOperator{T, O, C} <: AbstractSciMLOperator{T}
658658
""" Tuple of N operators to be applied in reverse"""

src/func.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $(FIELDS)
66
"""
77
mutable struct FunctionOperator{iip, oop, mul5, T <: Number, F, Fa, Fi, Fai, Tr, P, Tt,
88
C, iType, oType} <: AbstractSciMLOperator{T}
9-
""" Function with signature op(u, p, t) and (if isinplace) op(v, u, p, t) """
9+
""" Function with signature op(v, u, p, t) and (if isinplace) op(w, v, u, p, t) """
1010
op::F
1111
""" Adjoint operator"""
1212
op_adjoint::Fa
@@ -134,17 +134,17 @@ $(SIGNATURES)
134134
Wrap callable object `op` within an `AbstractSciMLOperator`. `op`
135135
is assumed to have signature
136136
137-
op(u, p, t; <accepted_kwargs>) -> v
137+
op(v, u, p, t; <accepted_kwargs>) -> w
138138
139139
or
140140
141-
op(v, u, p, t; <accepted_kwargs>) -> [modifies v]
141+
op(w, v, u, p, t; <accepted_kwargs>) -> [modifies w]
142142
143143
and optionally
144144
145-
op(v, u, p, t, α, β; <accepted_kwargs>) -> [modifies v]
145+
op(w, v, u, p, t, α, β; <accepted_kwargs>) -> [modifies w]
146146
147-
where `u`, `v` are `AbstractArray`s, `p` is a parameter object, and
147+
where `u`, `v`, `w` are `AbstractArray`s, `p` is a parameter object, and
148148
`t`, `α`, `β` are scalars. The first signature corresponds to applying
149149
the operator with `Base.*`, and the latter two correspond to the
150150
three-argument, and the five-argument `mul!` respectively.

src/interface.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ u = rand(4)
5656
p = rand(4)
5757
t = 1.0
5858
59-
# Update the operator and apply it to `u`
59+
# Update the operator to `(u,p,t)` and apply it to `v`
6060
L = update_coefficients(L, u, p, t; scale = 2.0)
61-
result = L * u
61+
result = L * v
6262
6363
# Or use the interface which separrates the update from the application
64-
result = L(u, u, p, t; scale = 2.0)
64+
result = L(v, u, p, t; scale = 2.0)
6565
```
6666
6767
"""
@@ -96,7 +96,7 @@ p = rand(4)
9696
t = 1.0
9797
9898
update_coefficients!(L, u, p, t)
99-
L * u
99+
L * v
100100
```
101101
102102
"""
@@ -200,14 +200,14 @@ has_adjoint(L::AbstractSciMLOperator) = false # L', adjoint(L)
200200
"""
201201
$SIGNATURES
202202
203-
Check if `expmv!(v, L, u, t)`, equivalent to `mul!(v, exp(t * A), u)`, is
204-
defined for `Number` `t`, and `AbstractArray`s `u, v` of appropriate sizes.
203+
Check if `expmv!(w, L, v, t)`, equivalent to `mul!(w, exp(t * A), v)`, is
204+
defined for `Number` `t`, and `AbstractArray`s `w, v` of appropriate sizes.
205205
"""
206206
has_expmv!(L::AbstractSciMLOperator) = false # expmv!(v, L, t, u)
207207
"""
208208
$SIGNATURES
209209
210-
Check if `expmv(L, u, t)`, equivalent to `exp(t * A) * u`, is defined for
210+
Check if `expmv(L, v, t)`, equivalent to `exp(t * A) * v`, is defined for
211211
`Number` `t`, and `AbstractArray` `u` of appropriate size.
212212
"""
213213
has_expmv(L::AbstractSciMLOperator) = false # v = exp(L, t, u)
@@ -220,26 +220,26 @@ has_exp(L::AbstractSciMLOperator) = islinear(L)
220220
"""
221221
$SIGNATURES
222222
223-
Check if `L * u` is defined for `AbstractArray` `u` of appropriate size.
223+
Check if `L * v` is defined for `AbstractArray` `u` of appropriate size.
224224
"""
225225
has_mul(L::AbstractSciMLOperator) = true # du = L*u
226226
"""
227227
$SIGNATURES
228228
229-
Check if `mul!(v, L, u)` is defined for `AbstractArray`s `u, v` of
229+
Check if `mul!(w, L, v)` is defined for `AbstractArray`s `w, v` of
230230
appropriate sizes.
231231
"""
232232
has_mul!(L::AbstractSciMLOperator) = true # mul!(du, L, u)
233233
"""
234234
$SIGNATURES
235235
236-
Check if `L \\ u` is defined for `AbstractArray` `u` of appropriate size.
236+
Check if `L \\ v` is defined for `AbstractArray` `v` of appropriate size.
237237
"""
238238
has_ldiv(L::AbstractSciMLOperator) = false # du = L\u
239239
"""
240240
$SIGNATURES
241241
242-
Check if `ldiv!(v, L, u)` is defined for `AbstractArray`s `u, v` of
242+
Check if `ldiv!(w, L, v)` is defined for `AbstractArray`s `w, v` of
243243
appropriate sizes.
244244
"""
245245
has_ldiv!(L::AbstractSciMLOperator) = false # ldiv!(du, L, u)

src/matrix.jl

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $SIGNATURES
44
55
Represents a linear operator given by an `AbstractMatrix` that may be
66
applied to an `AbstractVecOrMat`. Its state is updated by the user-provided
7-
`update_func` during operator evaluation (`L([v,], u, p, t)`), or by calls
7+
`update_func` during operator evaluation (`L([w,], v, u, p, t)`), or by calls
88
to `update_coefficients[!](L, u, p, t)`. Both recursively call the
99
`update_function`, `update_func` which is assumed to have the signature
1010
@@ -30,6 +30,7 @@ adjoints, transposes.
3030
3131
Out-of-place update and usage
3232
```
33+
v = rand(4)
3334
u = rand(4)
3435
p = rand(4, 4)
3536
t = rand()
@@ -38,38 +39,39 @@ mat_update = (A, u, p, t; scale = 0.0) -> t * p
3839
M = MatrixOperator(0.0; update_func = mat_update, accepted_kwargs = (:scale,))
3940
4041
L = M * M + 3I
41-
L = cache_operator(L, u)
42+
L = cache_operator(L, v)
4243
4344
# update and evaluate
44-
v = L(u, u, p, t; scale = 1.0)
45+
w = L(v, u, p, t; scale = 1.0)
4546
4647
# In-place evaluation
47-
w = similar(u)
48-
L(w, u, u, p, t; scale = 1.0)
48+
w = similar(v)
49+
L(w, v, u, p, t; scale = 1.0)
4950
5051
# In-place with scaling
5152
β = 0.5
52-
L(w, u, u, p, t, 2.0, β; scale = 1.0) # w = 2.0*(L*u) + 0.5*w
53+
L(w, v, u, p, t, 2.0, β; scale = 1.0) # w = 2.0*(L*v) + 0.5*w
5354
```
5455
5556
In-place update and usage
5657
```
58+
w = zeros(4)
5759
v = zeros(4)
5860
u = rand(4)
5961
p = rand(4) # Must be non-nothing
6062
t = rand()
6163
62-
mat_update! = (A, u, p, t; scale = 0.0) -> (A .= t * p * p' * scale)
64+
mat_update! = (A, u, p, t; scale = 0.0) -> (A .= t * p * u' * scale)
6365
M = MatrixOperator(zeros(4, 4); update_func! = mat_update!, accepted_kwargs = (:scale,))
6466
L = M * M + 3I
65-
L = cache_operator(L, u)
67+
L = cache_operator(L, v)
6668
6769
# update L in-place and evaluate
6870
update_coefficients!(L, u, p, t; scale = 1.0)
69-
mul!(v, L, u)
71+
mul!(w, L, v)
7072
7173
# Or use the new interface that separates update and application
72-
L(v, u, u, p, t; scale = 1.0)
74+
L(w, v, u, p, t; scale = 1.0)
7375
```
7476
"""
7577
struct MatrixOperator{T, AT <: AbstractMatrix{T}, F, F!} <: AbstractSciMLOperator{T}
@@ -250,16 +252,16 @@ $SIGNATURES
250252
Represents an elementwise scaling (diagonal-scaling) operation that may
251253
be applied to an `AbstractVecOrMat`. When `diag` is an `AbstractVector`
252254
of length N, `L = DiagonalOperator(diag, ...)` can be applied to
253-
`AbstractArray`s with `size(u, 1) == N`. Each column of the `u` will be
254-
scaled by `diag`, as in `LinearAlgebra.Diagonal(diag) * u`.
255+
`AbstractArray`s with `size(u, 1) == N`. Each column of the `v` will be
256+
scaled by `diag`, as in `LinearAlgebra.Diagonal(diag) * v`.
255257
256258
When `diag` is a multidimensional array, `L = DiagonalOperator(diag, ...)` forms
257259
an operator of size `(N, N)` where `N = size(diag, 1)` is the leading length of `diag`.
258-
`L` then is the elementwise-scaling operation on arrays of `length(u) = length(diag)`
260+
`L` then is the elementwise-scaling operation on arrays of `length(v) = length(diag)`
259261
with leading length `size(u, 1) = N`.
260262
261263
Its state is updated by the user-provided `update_func` during operator
262-
evaluation (`L([v,], u, p, t)`), or by calls to
264+
evaluation (`L([w,], v, u, p, t)`), or by calls to
263265
`update_coefficients[!](L, u, p, t)`. Both recursively call the
264266
`update_function`, `update_func` which is assumed to have the signature
265267
@@ -446,10 +448,10 @@ end
446448
"""
447449
$SIGNATURES
448450
449-
Represents a generalized affine operation (`v = A * u + B * b`) that may
451+
Represents a generalized affine operation (`w = A * v + B * b`) that may
450452
be applied to an `AbstractVecOrMat`. The user-provided update functions,
451453
`update_func[!]` update the `AbstractVecOrMat` `b`, and are called
452-
during operator evaluation (`L([v,], u, p, t)`), or by calls
454+
during operator evaluation (`L([w,], v, u, p, t)`), or by calls
453455
to `update_coefficients[!](L, u, p, t)`. The update functions are
454456
assumed to have the syntax
455457
@@ -459,8 +461,8 @@ or
459461
update_func!(b::AbstractVecOrMat, u ,p , t; <accepted kwargs>) -> [modifies b]
460462
461463
and `B`, `b` are expected to have an appropriate size so that
462-
`A * u + B * b` makes sense. Specifically, `size(A, 1) == size(B, 1)`, and
463-
`size(u, 2) == size(b, 2)`.
464+
`A * v + B * b` makes sense. Specifically, `size(A, 1) == size(B, 1)`, and
465+
`size(v, 2) == size(b, 2)`.
464466
465467
The set of keyword-arguments accepted by `update_func[!]` must be provided
466468
to `AffineOperator` via the kwarg `accepted_kwargs` as a tuple of `Symbol`s.
@@ -470,19 +472,20 @@ are not provided.
470472
# Example
471473
472474
```
475+
v = rand(4)
473476
u = rand(4)
474477
p = rand(4)
475478
t = rand()
476479
477480
A = MatrixOperator(rand(4, 4))
478481
B = MatrixOperator(rand(4, 4))
479482
480-
vec_update_func = (b, u, p, t) -> p * t
483+
vec_update_func = (b, u, p, t) -> p .* u * t
481484
L = AffineOperator(A, B, zero(4); update_func = vec_update_func)
482-
L = cache_operator(M, u)
485+
L = cache_operator(M, v)
483486
484487
# update L and evaluate
485-
v = L(u, p, t) # == A * u + B * (p * t)
488+
w = L(v, u, p, t) # == A * v + B * (p .* u * t)
486489
```
487490
488491
"""
@@ -532,7 +535,7 @@ end
532535
"""
533536
$SIGNATURES
534537
535-
Represents the affine operation `v = I * u + I * b`. The update functions,
538+
Represents the affine operation `w = I * v + I * b`. The update functions,
536539
`update_func[!]` update the state of `AbstractVecOrMat ` `b`. See
537540
documentation of `AffineOperator` for more details.
538541
"""
@@ -552,7 +555,7 @@ end
552555
"""
553556
$SIGNATURES
554557
555-
Represents the affine operation `v = I * u + B * b`. The update functions,
558+
Represents the affine operation `w = I * v + B * b`. The update functions,
556559
`update_func[!]` update the state of `AbstractVecOrMat ` `b`. See
557560
documentation of `AffineOperator` for more details.
558561
"""

src/scalar.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ $SIGNATURES
112112
113113
Represents a linear scaling operator that may be applied to a `Number`,
114114
or an `AbstractArray` subtype. Its state is updated by the user-provided
115-
`update_func` during operator evaluation (`L([v,] u, p, t)`), or by
115+
`update_func` during operator evaluation (`L([w,] v, u, p, t)`), or by
116116
calls to `update_coefficients[!]`. Both recursively call the
117117
update function, `update_func` which is assumed to have the signature:
118118

0 commit comments

Comments
 (0)