Sequences
A Sequence is a structure representing a sequence in a prescribed VectorSpace. More precisely, a Sequence is comprised of the two fields space::VectorSpace and coefficients::AbstractVector with matching dimension and length.
julia> a = Sequence(Taylor(1), [1, 2])Sequence in Taylor(1) with coefficients Vector{Int64}: 1 2
The two fields space and coefficients are accessible via the respective functions of the same name.
julia> space(a)Taylor(1)julia> coefficients(a)2-element Vector{Int64}: 1 2
For convenience, the methods zeros, ones, fill and fill! are available:
julia> s = Taylor(1)Taylor(1)julia> zeros(s)Sequence in Taylor(1) with coefficients Vector{Float64}: 0.0 0.0julia> ones(s)Sequence in Taylor(1) with coefficients Vector{Float64}: 1.0 1.0julia> fill(2, s)Sequence in Taylor(1) with coefficients Vector{Int64}: 2 2julia> fill!(zeros(s), 2)Sequence in Taylor(1) with coefficients Vector{Float64}: 2.0 2.0
The coefficients of a Sequence are indexed according to the indices of the space (as given by indices).
julia> a[0:1] # indices(space(a))2-element Vector{Int64}: 1 2
When the space of a Sequence is a CartesianSpace, its coefficients are given as the concatenation of the coefficients associated with each space. The function block extracts a Sequence composing the cartesian space.
julia> b = Sequence(ScalarSpace() × Taylor(1)^2, [1, 2, 3, 4, 5])Sequence in 𝕂 × Taylor(1)² with coefficients Vector{Int64}: 1 2 3 4 5julia> b[1:5] # indices(space(b))5-element Vector{Int64}: 1 2 3 4 5julia> block(b, 1) # extract the sequence associated with the space ScalarSpace()Sequence in 𝕂 with coefficients SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}: 1julia> block(b, 2) # extract the sequence associated with the space Taylor(1)^2Sequence in Taylor(1)² with coefficients SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}: 2 3 4 5julia> block(block(b, 2), 1)Sequence in Taylor(1) with coefficients SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}: 2 3julia> block(block(b, 2), 2)Sequence in Taylor(1) with coefficients SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}: 4 5
Similarly, the function eachblock returns a Generator whose iterates yield each Sequence composing the cartesian space.
Arithmetic
The addition and subtraction operations are implemented as the + and - functions respectively.
julia> c = Sequence(Taylor(1), [0, 1])Sequence in Taylor(1) with coefficients Vector{Int64}: 0 1julia> d = Sequence(Taylor(2), [1, 2, 1])Sequence in Taylor(2) with coefficients Vector{Int64}: 1 2 1julia> c + dSequence in Taylor(2) with coefficients Vector{Int64}: 1 3 1julia> c - dSequence in Taylor(2) with coefficients Vector{Int64}: -1 -1 -1
The discrete convolution between sequences whose spaces are a SequenceSpace is implemented as the *, mul! and ^ functions. Their bar counterparts mul_bar (unicode alias *\bar<tab>) and pow_bar (unicode alias ^\bar<tab>) give the result projected in the smallest compatible space between the operands; in general, mul_bar is not associative.
julia> c * dSequence in Taylor(3) with coefficients Vector{Int64}: 0 1 2 1julia> c ^ 3Sequence in Taylor(3) with coefficients Vector{Int64}: 0 0 0 1julia> mul_bar(c, d) # project(c * d, Taylor(1))Sequence in Taylor(1) with coefficients Vector{Int64}: 0 1julia> pow_bar(c, 3) # project(c ^ 3, Taylor(1))Sequence in Taylor(1) with coefficients Vector{Int64}: 0 0
To improve performance, the FFT algorithm may be used to compute discrete convolutions via the Convolution Theorem. However, the performance gain is tempered with the loss of accuracy which may stop the decay of the coefficients. To circumvent machine precision limitations, the banach_rounding! method enclose rigorously each term of the convolution beyond a prescribed order.[1]
julia> x = Sequence(Taylor(3), interval.([inv(10_000.0 ^ i) for i ∈ 0:3]))Sequence in Taylor(3) with coefficients Vector{Interval{Float64}}: Interval{Float64}(1.0, 1.0, com, true) Interval{Float64}(0.0001, 0.0001, com, true) Interval{Float64}(1.0e-8, 1.0e-8, com, true) Interval{Float64}(1.0e-12, 1.0e-12, com, true)julia> RadiiPolynomial.set_conv_algorithm(:fft):fftjulia> x³ = x ^ 3ERROR: UndefVarError: `D` not defined in `RadiiPolynomial` Suggestion: check for spelling errors or missing imports.julia> RadiiPolynomial.set_conv_algorithm(:sum) # default algorithm:sumjulia> x³ = x ^ 3 # only rounding errorSequence in Taylor(9) with coefficients Vector{Interval{Float64}}: Interval{Float64}(1.0, 1.0, com, true) Interval{Float64}(0.0003, 0.00030000000000000003, com, true) Interval{Float64}(6.0e-8, 6.000000000000001e-8, com, true) Interval{Float64}(1.0e-11, 1.0000000000000003e-11, com, true) Interval{Float64}(1.1999999999999998e-15, 1.2000000000000006e-15, com, true) Interval{Float64}(1.1999999999999996e-19, 1.2000000000000004e-19, com, true) Interval{Float64}(9.999999999999997e-24, 1.0000000000000004e-23, com, true) Interval{Float64}(5.999999999999999e-28, 6.000000000000002e-28, com, true) Interval{Float64}(2.9999999999999995e-32, 3.0000000000000006e-32, com, true) Interval{Float64}(9.999999999999998e-37, 1.0000000000000001e-36, com, true)
API
RadiiPolynomial.AbstractSequence — Type
AbstractSequenceAbstract type for all sequences.
RadiiPolynomial.Sequence — Type
Sequence{T<:VectorSpace,S<:AbstractVector} <: AbstractSequenceCompactly supported sequence in the given space.
Fields:
space :: Tcoefficients :: S
Constructors:
Sequence(::VectorSpace, ::AbstractVector)Sequence(coefficients::AbstractVector): equivalent toSequence(ScalarSpace()^length(coefficients), coefficients)
Examples
julia> Sequence(Taylor(2), [1, 2, 1]) # 1 + 2x + x^2
Sequence in Taylor(2) with coefficients Vector{Int64}:
1
2
1
julia> Sequence(Taylor(1) ⊗ Fourier(1, 1.0), [0.5, 0.5, 0.0, 0.0, 0.5, 0.5]) # (1 + x) cos(y)
Sequence in Taylor(1) ⊗ Fourier(1, 1.0) with coefficients Vector{Float64}:
0.5
0.5
0.0
0.0
0.5
0.5
julia> Sequence([1, 2, 3])
Sequence in 𝕂³ with coefficients Vector{Int64}:
1
2
3RadiiPolynomial.algebraicweight — Method
algebraicweight(a::Sequence{<:SequenceSpace})Compute an approximation of the algebraic decay rate of a by performing the ordinary least squares method on the logarithm of the absolute value of the coefficients of a.
See also: AlgebraicWeight, IdentityWeight, GeometricWeight, geometricweight and BesselWeight.
Examples
julia> rate(algebraicweight(Sequence(Taylor(10), [inv((1.0 + i)^2) for i in 0:10]))) ≈ 2
true
julia> rate.(algebraicweight(Sequence(Taylor(10) ⊗ Fourier(3, 1.0), vec([inv((1.0 + i)^2 * (1.0 + abs(j))^3) for i in 0:10, j in -3:3])))) .≈ (2, 3)
(true, true)RadiiPolynomial.block — Method
block(a::Sequence{<:CartesianSpace}, i)Return the $i$-th Sequence composing the block sequence.
Examples
julia> a = Sequence(Taylor(1)^2, [1, 2, 3, 4])
Sequence in Taylor(1)² with coefficients Vector{Int64}:
1
2
3
4
julia> block(a, 1)
Sequence in Taylor(1) with coefficients SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}:
1
2
julia> block(a, 2)
Sequence in Taylor(1) with coefficients SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}:
3
4RadiiPolynomial.block — Method
block(a::Sequence{<:CartesianSpace})Return the collection of blocks composing the sequence.
Examples
julia> a = Sequence(Taylor(1)^2, [1, 2, 3, 4])
Sequence in Taylor(1)² with coefficients Vector{Int64}:
1
2
3
4
julia> block(a)
2-element Vector{Sequence{Taylor, SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}}}:
Sequence(Taylor(1), [1, 2])
Sequence(Taylor(1), [3, 4])RadiiPolynomial.eachblock — Method
eachblock(a::Sequence{<:CartesianSpace})Create a generator whose iterates yield each Sequence composing the block sequence.
Examples
julia> a = Sequence(Taylor(1)^2, [1, 2, 3, 4])
Sequence in Taylor(1)² with coefficients Vector{Int64}:
1
2
3
4
julia> m = eachblock(a)
Base.Generator{Base.OneTo{Int64}, RadiiPolynomial.var"#eachblock##0#eachblock##1"{Sequence{CartesianPower{Taylor}, Vector{Int64}}}}(RadiiPolynomial.var"#eachblock##0#eachblock##1"{Sequence{CartesianPower{Taylor}, Vector{Int64}}}(Sequence(Taylor(1)², [1, 2, 3, 4])), Base.OneTo(2))
julia> [v for v = m]
2-element Vector{Sequence{Taylor, SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}}}:
Sequence(Taylor(1), [1, 2])
Sequence(Taylor(1), [3, 4])RadiiPolynomial.geometricweight — Method
geometricweight(a::Sequence{<:SequenceSpace})Compute an approximation of the geometric decay rate of a by performing the ordinary least squares method on the logarithm of the absolute value of the coefficients of a.
See also: GeometricWeight, IdentityWeight, AlgebraicWeight, algebraicweight and BesselWeight.
Examples
julia> rate(geometricweight(Sequence(Taylor(10), [inv(2.0^i) for i in 0:10]))) ≈ 2
true
julia> rate.(geometricweight(Sequence(Taylor(10) ⊗ Fourier(3, 1.0), vec([inv(2.0^i * 3.0^abs(j)) for i in 0:10, j in -3:3])))) .≈ (2, 3)
(true, true)- 1J.-P. Lessard, Computing discrete convolutions with verified accuracy via Banach algebras and the FFT, Applications of Mathematics, 63 (2018), 219-235.