1
1
"""
2
- WeightingOp(::Type{T}; weights::Vector{T}, rep::Int=1) where T
2
+ WeightingOp(::Type{T}; weights::Vector{T}, rep::Int=1) where T
3
3
4
4
generates a `LinearOperator` which multiplies an input vector index-wise with `weights`
5
5
6
6
# Arguments
7
7
* `weights::Vector{T}` - weights vector
8
8
* `rep::Int=1` - number of sub-arrays that need to be multiplied with `weights`
9
9
"""
10
- function WeightingOp (:: Type{T} ; weights:: vecT , rep:: Int = 1 ) where {T <: Number , vecT<: AbstractVector }
11
- weights_cat = repeat (weights,rep)
12
- return opDiagonal (weights_cat)
10
+ mutable struct WeightingOp{T} <: AbstractLinearOperatorFromCollection{T}
11
+ op:: LinearOperator{T}
12
+ weights:: Vector{T}
13
+ function WeightingOp (weights:: vecT , rep:: Int = 1 ) where {T <: Number , vecT<: AbstractVector{T} }
14
+ weights_cat = repeat (weights,rep)
15
+ return new {T} (opDiagonal (weights_cat), weights_cat)
16
+ end
13
17
end
18
+
19
+ function Base. getproperty (wop:: WeightingOp , field:: Symbol )
20
+ if in (field, (:op , :weights ))
21
+ return getfield (wop, field)
22
+ else
23
+ return getproperty (getfield (wop, :op ), field)
24
+ end
25
+ end
26
+ Base. setproperty! (wop:: WeightingOp , field:: Symbol , value) = setproperty! (wop. op, field, value)
27
+
28
+ storage_type (wop:: WeightingOp ) = storage_type (wop. op)
0 commit comments