11"""
2- WeightingOp(::Type{T}; weights::Vector{T}, rep::Int=1) where T
2+ WeightingOp(::Type{T}; weights::Vector{T}, rep::Int=1) where T
33
44generates a `LinearOperator` which multiplies an input vector index-wise with `weights`
55
66# Arguments
77* `weights::Vector{T}` - weights vector
88* `rep::Int=1` - number of sub-arrays that need to be multiplied with `weights`
99"""
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
1317end
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