Skip to content

Backport: Use mutable copies in transform/itransform #626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ApproxFunBase"
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
version = "0.8.63"
version = "0.8.64"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
15 changes: 13 additions & 2 deletions src/Space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ plan_itransform!(sp::Space,v) = ICanonicalTransformPlan(sp, v, Val(true))
# transform converts from values at points(S,n) to coefficients
# itransform converts from coefficients to values at points(S,n)

# convert to strided arrays, as currently the inverse performs inplace scaling
# ideally, this should not be needed if FastTransforms avoids modifying cfs
_toStridedArray(cfs::StridedArray) = cfs
_toStridedArray(cfs::AbstractArray) = convert(Array, cfs)

"""
transform(s::Space, vals)

Expand Down Expand Up @@ -529,7 +534,10 @@ julia> transform(Chebyshev(), v)
0.0
```
"""
transform(S::Space, vals) = plan_transform(S,vals)*vals
function transform(S::Space, vals)
valsf = convert(AbstractArray{float(eltype(vals))}, vals)
plan_transform(S,valsf)*_toStridedArray(valsf)
end

"""
itransform(s::Space,coefficients::AbstractVector)
Expand All @@ -551,7 +559,10 @@ julia> itransform(Chebyshev(), [0.5, 0, 0.5])
0.75
```
"""
itransform(S::Space, cfs) = plan_itransform(S,cfs)*cfs
function itransform(S::Space, cfs)
cfsf = convert(AbstractArray{float(eltype(cfs))}, cfs)
plan_itransform(S,cfsf)*_toStridedArray(cfsf)
end

itransform!(S::Space,cfs) = plan_itransform!(S,cfs)*cfs
transform!(S::Space,cfs) = plan_transform!(S,cfs)*cfs
Expand Down