Skip to content

Commit 9d641fb

Browse files
committed
improve docstrings
1 parent 1dc9c65 commit 9d641fb

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

src/kronecker.jl

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,22 @@ for k in 3:8 # is 8 sufficient?
7979
kron($(mapargs...), $(Symbol(:A, k)), convert_to_lmaps(As...)...)
8080
end
8181

82-
"""
82+
@doc raw"""
8383
squarekron(A₁::MapOrMatrix, A₂::MapOrMatrix, A₃::MapOrMatrix, Aᵢ::MapOrMatrix...)::CompositeMap
8484
8585
Construct a (lazy) representation of the Kronecker product `⨂ᵢ₌₁ⁿ Aᵢ` of at least 3 _square_
8686
Kronecker factors. In contrast to [`kron`](@ref), this function assumes that all Kronecker
8787
factors are square, and makes use of the following identity[^1]:
8888
89-
```
90-
\\bigotimes_{i=1}^n A_i = \\prod_{i=1}^n I_1 \\otimes \\ldots \\otimes I_{i-1} \\otimes A_i \\otimes I_{i+1} \\otimes \\ldots \\otimes I_n
89+
```math
90+
\bigotimes_{i=1}^n A_i = \prod_{i=1}^n I_1 \otimes \ldots \otimes I_{i-1} \otimes A_i \otimes I_{i+1} \otimes \ldots \otimes I_n
9191
```
9292
93-
where ```I_k``` is an identity matrix of the size of ```A_k```. By associativity, the
93+
where ``I_k`` is an identity matrix of the size of ``A_k``. By associativity, the
9494
Kronecker product of the identity operators may be combined to larger identity operators
95-
```I_{1:i-1}``` and ```I_{i+1:n}```, which yields
95+
``I_{1:i-1}`` and ``I_{i+1:n}``, which yields
9696
97-
```
97+
```math
9898
\\bigotimes_{i=1}^n A_i = \\prod_{i=1}^n I_{1:i-1} \\otimes A_i \\otimes I_{i+1:n}
9999
```
100100
@@ -103,9 +103,7 @@ outer `UniformScalingMap`s and the respective Kronecker factor. This representat
103103
expected to yield significantly faster multiplication (and reduce memory allocation)
104104
compared to [`kron`](@ref), but benchmarking intended use cases is highly recommended.
105105
106-
[^1]: Fernandes, P. and Plateau, B. and Stewart, W. J. ["Efficient Descriptor-Vector
107-
Multiplications in Stochastic Automata Networks"](https://doi.org/10.1145/278298.278303),
108-
_Journal of the ACM_, 45(3), 381–414, 1998.
106+
[^1]: Fernandes, P. and Plateau, B. and Stewart, W. J. ["Efficient Descriptor-Vector Multiplications in Stochastic Automata Networks"](https://doi.org/10.1145/278298.278303), _Journal of the ACM_, 45(3), 381–414, 1998.
109107
"""
110108
function squarekron(A::MapOrMatrix, B::MapOrMatrix, C::MapOrMatrix, Ds::MapOrMatrix...)
111109
maps = (A, B, C, Ds...)
@@ -326,24 +324,24 @@ kronsum(A::MapOrMatrix, B::MapOrMatrix) =
326324
kronsum(A::MapOrMatrix, B::MapOrMatrix, C::MapOrMatrix, Ds::MapOrMatrix...) =
327325
kronsum(A, kronsum(B, C, Ds...))
328326

329-
"""
327+
@doc raw"""
330328
sumkronsum(A, B)::LinearCombination
331329
sumkronsum(A, B, Cs...)::LinearCombination
332330
333331
Construct a (lazy) representation of the Kronecker sum `A⊕B` of two or more square
334332
objects of type `LinearMap` or `AbstractMatrix`. This function makes use of the following
335333
representation of Kronecker sums[^1]:
336334
337-
```
338-
\\bigoplus_{i=1}^n A_i = \\sum_{i=1}^n I_1 \\otimes \\ldots \\otimes I_{i-1} \\otimes A_i \\otimes I_{i+1} \\otimes \\ldots \\otimes I_n
335+
```math
336+
\bigoplus_{i=1}^n A_i = \sum_{i=1}^n I_1 \otimes \ldots \otimes I_{i-1} \otimes A_i \otimes I_{i+1} \otimes \ldots \otimes I_n
339337
```
340338
341-
where ```I_k``` is the identity operator of the size of ```A_k```. By associativity, the
339+
where ``I_k`` is the identity operator of the size of ``A_k``. By associativity, the
342340
Kronecker product of the identity operators may be combined to larger identity operators
343-
```I_{1:i-1}``` and ```I_{i+1:n}```, which yields
341+
``I_{1:i-1}`` and ``I_{i+1:n}``, which yields
344342
345-
```
346-
\\bigoplus_{i=1}^n A_i = \\sum_{i=1}^n I_{1:i-1} \\otimes A_i \\otimes I_{i+1:n}
343+
```math
344+
\bigoplus_{i=1}^n A_i = \sum_{i=1}^n I_{1:i-1} \otimes A_i \otimes I_{i+1:n},
347345
```
348346
349347
i.e., a `LinearCombination` where each summand is a Kronecker product consisting of three
@@ -369,9 +367,7 @@ julia> Matrix(Δ₁) == Matrix(Δ₂) == Matrix(Δ₃)
369367
true
370368
```
371369
372-
[^1]: Fernandes, P. and Plateau, B. and Stewart, W. J. ["Efficient Descriptor-Vector
373-
Multiplications in Stochastic Automata Networks"](https://doi.org/10.1145/278298.278303),
374-
_Journal of the ACM_, 45(3), 381–414, 1998.
370+
[^1]: Fernandes, P. and Plateau, B. and Stewart, W. J. ["Efficient Descriptor-Vector Multiplications in Stochastic Automata Networks"](https://doi.org/10.1145/278298.278303), _Journal of the ACM_, 45(3), 381–414, 1998.
375371
"""
376372
function sumkronsum(A::MapOrMatrix, B::MapOrMatrix)
377373
LinearAlgebra.checksquare(A, B)

0 commit comments

Comments
 (0)