From d4922b3709b987b2cc1339e08cc55cf25afbe501 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Wed, 17 Jul 2019 17:59:36 +0200 Subject: [PATCH] Dl/jacobiplan (#6) * Add type to JacobiTransformPlan * Update Project.toml * Prune exact zeros in roots * update for ApproxFunBase v0.1.2 --- Project.toml | 6 +++--- src/ApproxFunOrthogonalPolynomials.jl | 2 +- src/Spaces/Jacobi/jacobitransform.jl | 17 ++++++++++++----- src/roots.jl | 1 + 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 18397ec..dab4af3 100644 --- a/Project.toml +++ b/Project.toml @@ -30,13 +30,13 @@ ToeplitzMatrices = "c751599d-da0a-543b-9d20-d0a503d91d24" [compat] AbstractFFTs = "≥ 0.3.1" -ApproxFunBase = "0.1.1" +ApproxFunBase = "0.1.2" BandedMatrices = "0.9.0" BlockArrays = "0.9" BlockBandedMatrices = "0.4.3" Calculus = "≥ 0.1.15" DSP = "≥ 0.5.1" -DomainSets = "0.0.2" +DomainSets = "0.0.2, 0.1" DualNumbers = "≥ 0.4.0" FFTW = "≥ 0.2.4" FastGaussQuadrature = "≥ 0.3.2" @@ -44,7 +44,7 @@ FastTransforms = "≥ 0.4.2" FillArrays = "≥ 0.5.0" InfiniteArrays = "0.1" IntervalSets = "≥ 0.3.1" -LazyArrays = "0.8" +LazyArrays = "0.8, 0.9" LowRankApprox = "≥ 0.2" Reexport = "≥ 0.2.0" SpecialFunctions = "≥ 0.7.0" diff --git a/src/ApproxFunOrthogonalPolynomials.jl b/src/ApproxFunOrthogonalPolynomials.jl index 91b8deb..24488a3 100644 --- a/src/ApproxFunOrthogonalPolynomials.jl +++ b/src/ApproxFunOrthogonalPolynomials.jl @@ -56,7 +56,7 @@ import BandedMatrices: bandrange, bandshift, bandwidths, _BandedMatrix, BandedMatrix import Base: values, convert, getindex, setindex!, *, +, -, ==, <, <=, >, |, !, !=, eltype, iterate, - >=, /, ^, \, ∪, transpose, size, reindex, tail, broadcast, broadcast!, copyto!, copy, to_index, (:), + >=, /, ^, \, ∪, transpose, size, tail, broadcast, broadcast!, copyto!, copy, to_index, (:), similar, map, vcat, hcat, hvcat, show, summary, stride, sum, cumsum, sign, imag, conj, inv, complex, reverse, exp, sqrt, abs, abs2, sign, issubset, values, in, first, last, rand, intersect, setdiff, isless, union, angle, join, isnan, isapprox, isempty, sort, merge, promote_rule, diff --git a/src/Spaces/Jacobi/jacobitransform.jl b/src/Spaces/Jacobi/jacobitransform.jl index b9fe0aa..be844c3 100644 --- a/src/Spaces/Jacobi/jacobitransform.jl +++ b/src/Spaces/Jacobi/jacobitransform.jl @@ -1,25 +1,32 @@ points(S::Jacobi, n) = points(Chebyshev(domain(S)), n) -struct JacobiTransformPlan{CPLAN,CJT} +struct JacobiTransformPlan{T,CPLAN,CJT} <: AbstractTransformPlan{T} chebplan::CPLAN cjtplan::CJT end +JacobiTransformPlan(chebplan::CPLAN, cjtplan::CJT) where {CPLAN,CJT} = + JacobiTransformPlan{eltype(chebplan),CPLAN,CJT}(chebplan, cjtplan) + plan_transform(S::Jacobi, v::AbstractVector) = JacobiTransformPlan(plan_transform(Chebyshev(), v), plan_icjt(v, S.a, S.b)) -*(P::JacobiTransformPlan, vals) = P.cjtplan*(P.chebplan*vals) +*(P::JacobiTransformPlan, vals::AbstractVector) = P.cjtplan*(P.chebplan*vals) -struct JacobiITransformPlan{CPLAN,CJT} +struct JacobiITransformPlan{T,CPLAN,CJT} <: AbstractTransformPlan{T} ichebplan::CPLAN icjtplan::CJT end +JacobiITransformPlan(chebplan::CPLAN, cjtplan::CJT) where {CPLAN,CJT} = + JacobiITransformPlan{eltype(chebplan),CPLAN,CJT}(chebplan, cjtplan) + + -plan_itransform(S::Jacobi,v::AbstractVector) = +plan_itransform(S::Jacobi, v::AbstractVector) = JacobiITransformPlan(plan_itransform(Chebyshev(), v), plan_cjt(v, S.a, S.b)) -*(P::JacobiITransformPlan,cfs) = P.ichebplan*(P.icjtplan*cfs) +*(P::JacobiITransformPlan, cfs::AbstractVector) = P.ichebplan*(P.icjtplan*cfs) function coefficients(f::AbstractVector,a::Jacobi,b::Chebyshev) diff --git a/src/roots.jl b/src/roots.jl index 9cf6568..b046b44 100644 --- a/src/roots.jl +++ b/src/roots.jl @@ -132,6 +132,7 @@ end function colleague_matrix( c::Vector{T} ) where T<:Number #TODO: This is command isn't typed correctly # COMPUTE THE ROOTS OF A LOW DEGREE POLYNOMIAL BY USING THE COLLEAGUE MATRIX: + c = chop(c,0) # prune exact zeros n = length(c) - 1 A=zeros(T,n,n)