Skip to content

Commit 05eb9ae

Browse files
committed
added is_sliced
1 parent 7c6ce37 commit 05eb9ae

File tree

8 files changed

+44
-6
lines changed

8 files changed

+44
-6
lines changed

docs/src/properties.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ is_orthogonal
2323
is_invertible
2424
is_full_row_rank
2525
is_full_column_rank
26+
is_sliced
2627
```

src/calculus/Compose.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,15 @@ domainType(L::Compose) = domainType(L.A[1])
104104
codomainType(L::Compose) = codomainType(L.A[end])
105105

106106
is_linear(L::Compose) = all(is_linear.(L.A))
107-
is_diagonal(L::Compose) = all(is_diagonal.(L.A))
107+
is_diagonal(L::Compose) = is_sliced(L) ? (length(L.A) == 2 && is_diagonal(L.A[2])) : all(is_diagonal.(L.A))
108108
is_invertible(L::Compose) = all(is_invertible.(L.A))
109109

110+
is_sliced(L::Compose) = typeof(L.A[1]) <: GetIndex
111+
is_AAc_diagonal(L::Compose) = is_sliced(L) && length(L.A) == 2 && is_AAc_diagonal(L.A[2])
112+
113+
diag(L::Compose) = is_sliced(L) ? diag(L.A[2]) : prod(diag.(L.A))
114+
diag_AAc(L::Compose) = is_AAc_diagonal(L) ? diag_AAc(L.A[2]) : error("is_AAc_diagonal( $(typeof(L) ) ) == false")
115+
110116
# utils
111117
import Base: permute
112118
function permute(C::Compose{N,M,L,T}, p::AbstractVector{Int}) where {N,M,L,T}

src/linearoperators/DFT.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ is_invertible(L::FourierTransform) = true
186186
is_full_row_rank(L::FourierTransform) = true
187187
is_full_column_rank(L::FourierTransform) = true
188188

189-
diag_AcA(L::DFT) = prod(size(L,1))
190-
diag_AAc(L::DFT) = prod(size(L,1))
189+
diag_AcA(L::DFT) = float(prod(size(L,1)))
190+
diag_AAc(L::DFT) = float(prod(size(L,1)))
191191

192192
diag_AcA(L::IDFT) = 1/prod(size(L,1))
193193
diag_AAc(L::IDFT) = 1/prod(size(L,1))

src/linearoperators/GetIndex.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fun_name(L::GetIndex) = "↓"
7373

7474
is_AAc_diagonal(L::GetIndex) = true
7575
is_full_row_rank(L::GetIndex) = true
76-
76+
is_sliced(L::GetIndex) = true
7777

7878
# Utils
7979

src/linearoperators/MIMOFilt.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ export MIMOFilt
77
88
Creates a `LinearOperator` which, when multiplied with a matrix `X`, returns a matrix `Y`. Here a Multiple Input Multiple Output system is evaluated: the columns of `X` and `Y` represent the input signals and output signals respectively.
99
10-
`Y[:,i] = ∑j h_{i,j} ⋆ X[:,j]`
10+
```math
11+
\\mathbf{y}_i = \\sum_{j = 1}^{M} \\mathbf{h}_{i,j} * \\mathbf{x}_j
12+
```
13+
where ``\\mathbf{y}_i`` and ``\\mathbf{x}_j`` are the ``i``-th and ``j``-th columns of the output `Y` and input `X` matrices respectively.
1114
12-
The filters `h` can be represented either by providing coefficients `B` and `A` (IIR) or `B` alone (FIR). These coefficients must be given in a `Vector` of `Vector`s.
15+
The filters ``\\mathbf{h}_{i,j}`` can be represented either by providing coefficients `B` and `A` (IIR) or `B` alone (FIR). These coefficients must be given in a `Vector` of `Vector`s.
1316
1417
For example for a `3` by `2` MIMO system (i.e. `size(X,2) == 3` inputs and `size(Y,2) == 2` outputs) `B` must be:
1518

src/properties.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export ndoms,
1414
is_invertible,
1515
is_full_row_rank,
1616
is_full_column_rank,
17+
is_sliced,
1718
diag_AcA,
1819
diag_AAc
1920

@@ -253,6 +254,19 @@ false
253254
"""
254255
is_full_column_rank(L::AbstractOperator) = false
255256

257+
"""
258+
`is_sliced(A::AbstractOperator)`
259+
260+
Test whether `A` is a sliced operator.
261+
262+
```julia
263+
julia> is_sliced(GetIndex((10,), 1:5))
264+
true
265+
266+
```
267+
"""
268+
is_sliced(L::AbstractOperator) = false
269+
256270

257271
import Base: convert
258272
function convert(::Type{T}, dom::Type, dim_in::Tuple, L::T) where {T <: AbstractOperator}

test/test_linear_operators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ op = GetIndex(Float64,(n,m),(1:n,1:m))
482482
op = GetIndex(Float64,(n,),(1:k,))
483483

484484
##properties
485+
@test is_sliced(op) == true
485486
@test is_linear(op) == true
486487
@test is_null(op) == false
487488
@test is_eye(op) == false

test/test_linear_operators_calculus.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ opS2 = Scale(pi,opA2)
4545
@test typeof(opS2*opS1) <: Scale
4646

4747
#properties
48+
@test is_sliced(opC) == false
4849
@test is_linear(opC1) == true
4950
@test is_null(opC1) == false
5051
@test is_eye(opC1) == false
@@ -56,6 +57,18 @@ opS2 = Scale(pi,opA2)
5657
@test is_full_row_rank(opC1) == false
5758
@test is_full_column_rank(opC1) == false
5859

60+
# properties special case
61+
opC = DCT((5,))*GetIndex((10,), 1:5)
62+
@test is_sliced(opC) == true
63+
@test is_AAc_diagonal(opC) == true
64+
@test diag_AAc(opC) == 1.0
65+
66+
d = randn(5)
67+
opC = DiagOp(d)*GetIndex((10,), 1:5)
68+
@test is_sliced(opC) == true
69+
@test is_diagonal(opC) == true
70+
@test diag(opC) == d
71+
5972
###########################
6073
###### test DCAT #######
6174
###########################

0 commit comments

Comments
 (0)