Skip to content

Commit fa060bd

Browse files
authored
Backport: Use mutable copies in transform/itransform (JuliaApproximation#626)
* Backport: Use mutable copies in transform/itransform * Backport: Convert to float in transform/itransform JuliaApproximation#627
1 parent a007136 commit fa060bd

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.8.63"
3+
version = "0.8.64"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/Space.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,11 @@ plan_itransform!(sp::Space,v) = ICanonicalTransformPlan(sp, v, Val(true))
500500
# transform converts from values at points(S,n) to coefficients
501501
# itransform converts from coefficients to values at points(S,n)
502502

503+
# convert to strided arrays, as currently the inverse performs inplace scaling
504+
# ideally, this should not be needed if FastTransforms avoids modifying cfs
505+
_toStridedArray(cfs::StridedArray) = cfs
506+
_toStridedArray(cfs::AbstractArray) = convert(Array, cfs)
507+
503508
"""
504509
transform(s::Space, vals)
505510
@@ -529,7 +534,10 @@ julia> transform(Chebyshev(), v)
529534
0.0
530535
```
531536
"""
532-
transform(S::Space, vals) = plan_transform(S,vals)*vals
537+
function transform(S::Space, vals)
538+
valsf = convert(AbstractArray{float(eltype(vals))}, vals)
539+
plan_transform(S,valsf)*_toStridedArray(valsf)
540+
end
533541

534542
"""
535543
itransform(s::Space,coefficients::AbstractVector)
@@ -551,7 +559,10 @@ julia> itransform(Chebyshev(), [0.5, 0, 0.5])
551559
0.75
552560
```
553561
"""
554-
itransform(S::Space, cfs) = plan_itransform(S,cfs)*cfs
562+
function itransform(S::Space, cfs)
563+
cfsf = convert(AbstractArray{float(eltype(cfs))}, cfs)
564+
plan_itransform(S,cfsf)*_toStridedArray(cfsf)
565+
end
555566

556567
itransform!(S::Space,cfs) = plan_itransform!(S,cfs)*cfs
557568
transform!(S::Space,cfs) = plan_transform!(S,cfs)*cfs

0 commit comments

Comments
 (0)