Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions src/bases/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@


function plan_grid_transform(lay, L, szs::NTuple{N,Int}, dims=1:N) where N
p = grid(L)
p, InvPlan(factorize(L[p,:]), dims)
p = grid(L, szs...)
p, InvPlan(factorize(L[p,1:length(p)]), dims)
end

function plan_grid_transform(::MappedBasisLayout, L, szs::NTuple{N,Int}, dims=1:N) where N
x,F = plan_grid_transform(demap(L), szs, dims)
invmap(parentindices(L)[1])[x], F
end


plan_grid_transform(L, szs::NTuple{N,Int}, dims=1:N) where N = plan_grid_transform(MemoryLayout(L), L, szs, dims)

plan_grid_transform(L, arr::AbstractArray, dims...) = plan_grid_transform(L, size(arr), dims...)
Expand Down Expand Up @@ -316,19 +317,33 @@


"""
WeightedFactorization(w, F)
WeightedPlan(w, F)

weights a factorization `F` by `w`.
weights a plan `F` by `w`.
"""
struct WeightedFactorization{T, WW, FAC<:Factorization{T}} <: Factorization{T}
struct WeightedPlan{T, WW, FAC<:Plan{T}, Dims} <: Plan{T}
w::WW
F::FAC
dims::Dims
end

function *(F::WeightedPlan, b::AbstractVecOrMat)
ret = copy(b)
for d in F.dims
if d == 1
b .= b ./ F.w
else
@assert d == 2
b .= b ./ transpose(F.w)

Check warning on line 337 in src/bases/bases.jl

View check run for this annotation

Codecov / codecov/patch

src/bases/bases.jl#L336-L337

Added lines #L336 - L337 were not covered by tests
end
end
F.F * b
end

_factorize(::WeightedBasisLayouts, wS, dims...; kws...) = WeightedFactorization(weight(wS), factorize(unweighted(wS), dims...; kws...))


\(F::WeightedFactorization, b::AbstractQuasiVector) = F.F \ (b ./ F.w)
function plan_grid_transform(::WeightedBasisLayout, L, szs::NTuple{N,Int}, dims=1:N) where N
x,F = plan_grid_transform(unweighted(L), szs, dims)
x, WeightedPlan(weight(L)[x], F, dims)
end

##
# Algebra
Expand Down