Skip to content

Commit

Permalink
Use SVector instead of Vec (#846)
Browse files Browse the repository at this point in the history
* Use SVector instead of Vec

* Lower compat bound for BandedMatrices
  • Loading branch information
jishnub authored Nov 18, 2022
1 parent 1615fdb commit 81b94a7
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 81 deletions.
11 changes: 8 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name = "ApproxFun"
uuid = "28f2ccd6-bb30-5033-b560-165f7b14dc2f"
version = "0.13.11"
version = "0.13.12"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
ApproxFunBase = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
ApproxFunFourier = "59844689-9c9d-51bf-9583-5b794ec66d30"
ApproxFunOrthogonalPolynomials = "b70543e2-c0d9-56b8-a290-0d4d6d4de211"
ApproxFunSingularities = "f8fcb915-6b99-5be2-b79a-d6dbef8e6e7e"
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"
Expand All @@ -17,15 +18,17 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
AbstractFFTs = "1.0"
ApproxFunBase = "0.7.30"
ApproxFunBase = "0.7.34"
ApproxFunBaseTest = "0.1"
ApproxFunFourier = "0.3"
ApproxFunOrthogonalPolynomials = "0.5"
ApproxFunSingularities = "0.3"
Aqua = "0.5"
BandedMatrices = "0.16, 0.17"
Calculus = "0.5"
DomainSets = "0.3, 0.4, 0.5"
DualNumbers = "0.6.2"
Expand All @@ -34,14 +37,16 @@ FastTransforms = "0.13, 0.14"
RecipesBase = "1.0"
Reexport = "1.0"
SpecialFunctions = "1.1, 2"
StaticArrays = "1"
julia = "1.6"

[extras]
ApproxFunBaseTest = "a931bfaf-0cfd-4a5c-b69c-bf2eed002b43"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["ApproxFunBaseTest", "Aqua", "Documenter", "Random", "Test"]
test = ["ApproxFunBaseTest", "Aqua", "BlockBandedMatrices", "Documenter", "Random", "Test"]
3 changes: 2 additions & 1 deletion examples/Eigenvalue_symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

using ApproxFun
using LinearAlgebra
using BandedMatrices

# Define parameters
ω = 25.0
Expand All @@ -32,7 +33,7 @@ R = D1*Q;
# This inversion is computed approximately, such that
# ``\mathrm{C}^{-1} \mathrm{C} ≈ \mathrm{I}`` up to a certain bandwidth
C = Conversion(domainspace(L), rangespace(L))
P = cache(PartialInverseOperator(C, (0, ApproxFun.bandwidth(L, 1) + ApproxFun.bandwidth(R, 1) + ApproxFun.bandwidth(C, 2))));
P = cache(PartialInverseOperator(C, (0, bandwidth(L, 1) + bandwidth(R, 1) + bandwidth(C, 2))));

A = R'D1*P*L*D2*R
B = R'R;
Expand Down
2 changes: 1 addition & 1 deletion examples/PDE_Helmholtz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ L = [Dirichlet(d); Laplacian()+100I];

# We compute the QR decomposition of the operator to speed up the solution
Q = qr(L);
ApproxFun.resizedata!(Q,:,4000);
ApproxFunBase.resizedata!(Q,:,4000);

# The boundary condition is a function that is equal to one on each edge
boundary_cond = ones((d));
Expand Down
100 changes: 32 additions & 68 deletions src/ApproxFun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,84 +10,53 @@ import Calculus
@reexport using ApproxFunOrthogonalPolynomials
@reexport using ApproxFunSingularities

import ApproxFunBase: normalize!, flipsign, FiniteRange, Fun, MatrixFun, UnsetSpace, VFun, RowVector,
UnivariateSpace, AmbiguousSpace, SumSpace, SubSpace, WeightSpace, NoSpace, Space,
HeavisideSpace, PointSpace,
IntervalOrSegment, RaggedMatrix, AlmostBandedMatrix,
AnyDomain, ZeroSpace, ArraySpace, TrivialInterlacer, BlockInterlacer,
AbstractTransformPlan, TransformPlan, ITransformPlan,
ConcreteConversion, ConcreteMultiplication, ConcreteDerivative, ConcreteIntegral, CalculusOperator,
ConcreteVolterra, Volterra, VolterraWrapper,
MultiplicationWrapper, ConversionWrapper, DerivativeWrapper, Evaluation, EvaluationWrapper,
Conversion, defaultConversion, defaultcoefficients, default_Fun, Multiplication, Derivative, Integral, bandwidths,
ConcreteEvaluation, ConcreteDefiniteLineIntegral, ConcreteDefiniteIntegral, ConcreteIntegral,
DefiniteLineIntegral, DefiniteIntegral, ConcreteDefiniteIntegral, ConcreteDefiniteLineIntegral, IntegralWrapper,
ReverseOrientation, ReverseOrientationWrapper, ReverseWrapper, Reverse, NegateEven,
Dirichlet, ConcreteDirichlet, DirichletWrapper,
TridiagonalOperator, SubOperator, Space, @containsconstants, spacescompatible,
hasfasttransform, canonicalspace, domain, setdomain, prectype, domainscompatible,
plan_transform, plan_itransform, plan_transform!, plan_itransform!, transform, itransform, hasfasttransform,
CanonicalTransformPlan, ICanonicalTransformPlan,
Integral,
domainspace, rangespace, boundary,
union_rule, conversion_rule, maxspace_rule, conversion_type, maxspace, hasconversion, points,
rdirichlet, ldirichlet, lneumann, rneumann, ivp, bvp,
linesum, differentiate, integrate, linebilinearform, bilinearform,
UnsetNumber, coefficienttimes, subspace_coefficients, sumspacecoefficients, specialfunctionnormalizationpoint,
Segment, IntervalOrSegmentDomain, PiecewiseSegment, isambiguous, Vec, eps, isperiodic,
arclength, complexlength,
invfromcanonicalD, fromcanonical, tocanonical, fromcanonicalD, tocanonicalD, canonicaldomain, setcanonicaldomain, mappoint,
reverseorientation, checkpoints, evaluate, mul_coefficients, coefficients, coefficientmatrix, isconvertible,
clenshaw, ClenshawPlan, sineshaw,
toeplitz_getindex, toeplitz_axpy!, sym_toeplitz_axpy!, hankel_axpy!, ToeplitzOperator, SymToeplitzOperator, hankel_getindex,
SpaceOperator, ZeroOperator, InterlaceOperator,
interlace!, reverseeven!, negateeven!, cfstype, pad!, alternatesign!, mobius,
extremal_args, hesseneigvals, chebyshev_clenshaw, recA, recB, recC, roots,splitatroots,
chebmult_getindex, intpow, alternatingsum,
domaintype, diagindshift, rangetype, weight, isapproxinteger, default_Dirichlet, scal!, dotu,
components, promoterangespace, promotedomainspace, choosedomainspace,
block, blockstart, blockstop, blocklengths, isblockbanded, pointscompatible,
import ApproxFunBase: Fun, UnsetSpace, VFun, UnivariateSpace, SumSpace, Space,
HeavisideSpace, PointSpace, IntervalOrSegment, ArraySpace,
TransformPlan, ITransformPlan, Evaluation,
Conversion, default_Fun, Derivative, Integral,
Dirichlet, domain, plan_transform,
plan_itransform, transform, domainspace,
rangespace, boundary, points, differentiate, integrate,
Segment, arclength, fromcanonical, checkpoints, evaluate,
coefficients, coefficientmatrix, clenshaw, ClenshawPlan,
SpaceOperator, InterlaceOperator, cfstype, pad!,
isapproxinteger, components, promotedomainspace, choosedomainspace,
AbstractProductSpace, MultivariateFun, BivariateSpace,
@wrapperstructure, @wrapperspaces, @wrapper, @calculus_operator, resizedata!, slnorm,
sample, chop!, isbanded, colrange, bandwidth,
∇, 𝒟, Δ, ∫, ⨜, Σ, ∮, ⨍, ⨎
@calculus_operator, slnorm, sample, chop!, 𝒟, ∫, ⨜, ⨍

export ∫, ⨜, ⨍, 𝒟

import ApproxFunOrthogonalPolynomials: order

import BandedMatrices: bandwidths

import AbstractFFTs: Plan, fft, ifft
import FFTW: plan_r2r!, fftwNumber, REDFT10, REDFT01, REDFT00, RODFT00, R2HC, HC2R,
r2r!, r2r, plan_fft, plan_ifft, plan_ifft!, plan_fft!
import FFTW: plan_fft, plan_ifft, plan_ifft!

import Base: values, convert, getindex, setindex!, *, +, -, ==, <, <=, >, |, !, !=, eltype, iterate,
>=, /, ^, \, , transpose, size, tail, broadcast, broadcast!, copyto!, copy, to_index, (:),
similar, map, vcat, hcat, hvcat, show, summary, stride, sum, cumsum, sign, 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,
minimum, maximum, extrema, argmax, argmin, findmax, findmin, isfinite,
zeros, zero, one, promote_rule, repeat, length, resize!, isinf,
getproperty, findfirst, unsafe_getindex, fld, cld, div, real, imag,
@_inline_meta, eachindex, firstindex, lastindex, keys, isreal, OneTo,
Array, Vector, Matrix, view, ones, @propagate_inbounds, print_array,
split
import Base: convert, getindex, *, +, -, /, ^, \, sum, cumsum,
first, last, isempty, zeros, promote_rule, real,
# the following functions names are listed in Calculus.symbolic_derivatives_1arg(),
# and methods are added to them here
sqrt, cbrt, abs2, inv, log, log10, log2, log1p,
exp, exp2, expm1, sin, cos, tan, sec, csc, cot,
sind, cosd, tand, secd, cscd, cotd, asin, acos, atan, asec, acsc, acot,
asind, acosd, atand, asecd, acscd, acotd, sinh, cosh, tanh, sech, csch,
coth, asinh, acosh, atanh, asech, acsch, acoth, deg2rad, rad2deg

import Base.Broadcast: BroadcastStyle, Broadcasted, AbstractArrayStyle, broadcastable,
DefaultArrayStyle, broadcasted
import LinearAlgebra: eigvals, dot, adjoint



import LinearAlgebra: BlasInt, BlasFloat, norm, ldiv!, mul!, det, eigvals, dot, cross,
qr, qr!, rank, isdiag, istril, istriu, issymmetric, ishermitian,
Tridiagonal, diagm, diagm_container, factorize, nullspace,
Hermitian, Symmetric, adjoint, transpose, char_uplo
import SpecialFunctions: erf, erfinv, erfc, erfcinv, erfi, gamma, lgamma, digamma, invdigamma,
trigamma, airyai, airybi, airyaiprime, airybiprime, besselj0, besselj1,
bessely0, bessely1, erfcx, dawson

# import Arpack: eigs


import FastTransforms: ChebyshevTransformPlan, IChebyshevTransformPlan, plan_chebyshevtransform,
plan_chebyshevtransform!, plan_ichebyshevtransform, plan_ichebyshevtransform!
import FastTransforms: ChebyshevTransformPlan, plan_chebyshevtransform,
plan_chebyshevtransform!, plan_ichebyshevtransform,
plan_ichebyshevtransform!

using StaticArrays: SVector

"""
`Curve` Represents a domain defined by the image of a Fun. Example
Expand All @@ -106,11 +75,6 @@ Curve(f::Fun{<:Space{<:ChebyshevInterval}}) = IntervalCurve(f)

export Curve



import Base: view


##Testing
export bisectioninv

Expand Down
7 changes: 2 additions & 5 deletions src/Extras/dualnumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,15 @@ function dualFun(f,S,n)
end

function dualcfsFun(f,S)
T = float(eltype(domain(S)))
if T <: Complex
T = T.parameters[1] #get underlying real representation
end
T = real(float(eltype(domain(S))))
r=checkpoints(S)
f0=f(first(r))

if isa(f0,AbstractArray) && size(S) size(f0)
return dualcfsFun(f,Space(fill(S,size(f0))))
end

tol =T==Any ? 100eps() : 100eps(T)
tol = 100eps(T)


fr=typeof(f0)[f(x) for x=r]
Expand Down
2 changes: 1 addition & 1 deletion src/Plot/Plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ end
# end
end

@recipe function f(dd::Segment{<:Vec{2}})
@recipe function f(dd::Segment{<:SVector{2}})
a,b = endpoints(dd)
[a[1],b[1]], [a[2],b[2]]
end
Expand Down
5 changes: 3 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ApproxFun, Random, Test
using ApproxFunBase: testbandedblockbandedoperator, blocklengths, ∞
using BlockBandedMatrices: blockbandwidths, subblockbandwidths

using Aqua
@testset "Project quality" begin
Expand Down Expand Up @@ -99,8 +100,8 @@ end

sp = Space(dom)
Dr = Derivative(sp, [1,0])
@test ApproxFunBase.blockbandwidths(Dr) == (-1,1)
@test ApproxFunBase.subblockbandwidths(Dr) == (1,3)
@test blockbandwidths(Dr) == (-1,1)
@test subblockbandwidths(Dr) == (1,3)

= Derivative(sp, [0,1])
Mr = Multiplication(Fun( (r, θ) -> r, sp ), sp)
Expand Down

2 comments on commit 81b94a7

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/72463

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.13.12 -m "<description of version>" 81b94a71426bf884b05f8f1aec4e6a05e9c2f695
git push origin v0.13.12

Please sign in to comment.