Skip to content

Commit 0b452e7

Browse files
authored
convert to vector in chop (#168)
* convert to vector in chop * add chebyshev test
1 parent a8f24a3 commit 0b452e7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Fun.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ function chop!(f::Fun,tol...)
282282
f
283283
end
284284

285-
chop(f::Fun,tol) = chop!(Fun(f.space,copy(f.coefficients)),tol)
286-
chop(f::Fun) = chop!(Fun(f.space,copy(f.coefficients)))
285+
chop(f::Fun,tol...) = chop!(Fun(f.space,convert(Vector, f.coefficients)),tol...)
287286

288287
copy(f::Fun) = Fun(space(f),copy(f.coefficients))
289288

test/SpacesTest.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ApproxFunBase, Test
22
import ApproxFunBase: PointSpace, HeavisideSpace, PiecewiseSegment, dimension, Vec, checkpoints
33
using ApproxFunOrthogonalPolynomials
4+
using StaticArrays
45

56
@testset "Spaces" begin
67
@testset "PointSpace" begin
@@ -111,6 +112,11 @@ using ApproxFunOrthogonalPolynomials
111112
g = @inferred (x -> x^2)(f)
112113
@test eltype(coefficients(g)) == Float32
113114
end
115+
116+
@testset "static coeffs" begin
117+
f = Fun(PointSpace(1:3), SA[1,2,3])
118+
@test coefficients(f^2) == coefficients(f).^2
119+
end
114120
end
115121

116122
@testset "Derivative operator for HeavisideSpace" begin
@@ -297,5 +303,11 @@ using ApproxFunOrthogonalPolynomials
297303
@test f + f 2f f*2
298304
end
299305
end
306+
307+
@testset "static coeffs" begin
308+
f = Fun(Chebyshev(), SA[1,2,3])
309+
g = Fun(Chebyshev(), [1,2,3])
310+
@test coefficients(f^2) == coefficients(g^2)
311+
end
300312
end
301313
end

0 commit comments

Comments
 (0)