Docstrings
PseudostableRecurrences.AbstractLinearRecurrence — TypeAbstractLinearRecurrence{T} <: AbstractRecurrence{T}A recurrence where the results are linear w.r.t. the initial conditions. To support pseudostablization, the following methods are needed:
rdiv!(::AbstractLinearRecurrence, x::Number): divides the system byx. It is used to prevent floating point overflow.LinearAlgebra.norm(step!(::AbstractLinearRecurrence), Inf): computes the ∞-norm of a step. It is used to get the amplification of the system.
PseudostableRecurrences.AbstractLinearRecurrencePlan — TypeAbstractLinearRecurrencePlan <: AbstractRecurrencePlanA recurrence plan where the results are linear w.r.t. the initial conditions. Pseudostablization algorithm on linear recurrences is implemented.
PseudostableRecurrences.AbstractRecurrence — TypeAbstractRecurrence{T}The abstract type where a recurrence instance runs. It needs to support the following methods:
step!(::AbstractRecurrence): step forward the recurrence. Returnsnothingif the recurrence terminates, otherwise returns a view of the stepping result.
PseudostableRecurrences.AbstractRecurrencePlan — TypeAbstractRecurrencePlanThe abstract type of recurrence plans. A recurrence plan should include all the information that can perform a recurrence with a precision. It needs to support the following methods:
init(::AbstractRecurrencePlan; T=Float64, init=:default): generates anAbstractRecurrenceobject where the actual recurrence runs on. Returns a vector of the view of the initial steps as well.Tis the underlying type where the precision is implied.inittells how the initial values are generated. Must support:defaultfor the forward recurrence to run. It is also suggested to support:randfor the pseudostablization algorithm.
PseudostableRecurrences.BandedSylvesterRecurrence — TypeBandedSylvesterRecurrence{T, TA<:AbstractMatrix{T}, TB<:AbstractMatrix{T}, TC<:AbstractMatrix{T}, TX<:AbstractMatrix{T}} <: AbstractLinearRecurrence{slicetype(TX)}The recurrence generated from the infinite Sylvester equation $AX+XB+C=0$, assuming $X$ has infinite number of columns. The upper bandwidth of $A$ has to be finite, the lower bandwidth of $B$ has to be positive and finite and the lower bounding band of $B$ can't contain zero. The recurrence is basically a cross-shaped stencil recurrence, where the width of the stencil is determined by The total bandwidth of $B$ and the height by that of $A$. See also BandedSylvesterRecurrencePlan.
The restriction to the bandwidths may not be optimal, but it's the boundary of our knowledge at the moment.
Properties
A::TA, B::TB, C::TC: the matrices $A$, $B$ and $C$. It's recommended to useBandedMatrices.jlto boost performance. Their dimensions don't have to match. Just make sure that noBoundsErrorhappens during the recurrence.buffer::TX: the buffer that stores temp results.sliceind::Int: the current column index.lastind::Int: the last column index to be computed.
PseudostableRecurrences.BandedSylvesterRecurrencePlan — TypeBandedSylvesterRecurrencePlan{FA<:Function, FB<:Function, FC<:Function, INIT<:Function} <: AbstractLinearRecurrencePlanSee also BandedSylvesterRecurrence.
Properties
fA::FA, fB::FB, fC::FC: the functions that generateA,BandCfor theBandedSylvesterRecurrence. The functions should have the formf(eltype, size...).init::INIT: the function that generates the first few columns of $X$ in order to start the recurrence. It should have the formf(eltype, size...).size::Dims{2}: the size of $X$.bandB::NTuple{2,Int}: the bandwidths ofB. AlthoughBcan have infinite upper bandwidth, that will cause the stencil to have infinite width and hence in practice, the upper bandwidth ofBis always limited by the finite width of $X$.firstind::Int: the first column to be computed. The default value isbandB[2]+1.
PseudostableRecurrences.StencilRecurrence — TypeStencilRecurrence{N,T,S,
COEF<:NTuple{S,AbstractArray{T,N}},
TB<:AbstractArray{T,N},}
(stencil, coef, buffer, slicestart, sliceend, lastind)Parameters
N: system dimensionT: eltypeS: stencil size
Properties
For coef and slicesupport, tt's suggested to use lazy arrays for performance.
stencil::NTuple{S, CartesianIndex{N}}: The relative index of the stencil. Can contain(0,0)(seecoef)coef::COEF<:NTuple{S,AbstractArray{T,N}}: The coefficient associated with each relative index. The one associated withCartesianIndex(0,0)refers to a constant added to that entry. It's suggested to use lazy arrays for performance.buffer::CircularArray{T,N,TB<:AbstractArray{T,N}}: a buffer to store temp results.slicestart::MVector{N, Int}andsliceend::MVector{N, Int}: marks the current range of entries to be determined. TechnicallyNTuple{N-1, Int}should work, butJuliadoesn't support computed type parameters.lastslice::Int: marks the index of the slice where the recurrence terminates.
PseudostableRecurrences.StencilRecurrencePlan — TypeStencilRecurrencePlan{N, D, S, COEF<:NTuple{S,Function}, INIT<:Function} <: AbstractLinearRecurrencePlanParameters
N: system dimensionD: number domain, e.g.Real,Complex, etc.S: stencil size
Properties
stencil::SVector{S, CartesianIndex{N}}: The relative index of the stencil. Can contain(0,0)(seecoef)coef::COEF<:NTuple{S,Function}: The coefficient associated with each relative index. The one associated withCartesianIndex(0,0)refers to a constant added to that entry. The functions should be in the formf(T, I...)whereIis the index of the stencil andTis the suggested return type. Coefficients should be at least as accurate asT. Exact-value types such asIrrational,RationalorIntegerwould do the job, and if that's not possible,BigFloatwould work as well.init::INIT<:Function: the function used for initial values. The functions should be in the formf(I...)orf(T, I...)whereIis the size of the array, excluding the last dimension, andTis the precisiontype. For the former case,fshould return exact values, i.e.Integer,RationalorIrrational.size::Dims{N}: the size of the whole array.offset::NTuple{N,Int}: the very first index where the recurrence starts at.
PseudostableRecurrences.ToPrecision — TypeToPrecision{F}(f::F) <: FunctionCreate a function where the first argument specifies the returned precisiontype: (f::ToPrecision)(T, args...) = convert_precisiontype(precisiontype(T), f.f(args...))
Examples
julia> f() = π
f (generic function with 1 method)
julia> f(n) = 1//n + (n-1)//n*im
f (generic function with 2 methods)
julia> g = ToPrecision(f)
(::PseudostableRecurrences.ToPrecision{typeof(f)}) (generic function with 1 method)
julia> g(Float64)
3.141592653589793
julia> g(BigFloat)
3.141592653589793238462643383279502884197169399375105820974944592307816406286198
julia> g(Float16, 7)
Float16(0.1428) + Float16(0.857)im
julia> g(Float32, 3)
0.33333334f0 + 0.6666667f0imPseudostableRecurrences._dotu — Method_dotu(x, y) = mapreduce(*, +, x, y)Not to be confused with LinearAlgebra.BLAS.dotu. See https://github.com/JuliaLang/julia/pull/27677
PseudostableRecurrences.method_to_precision — Methodmethod_to_precision(f, argtypes)If hasmethod(f, argtypes), return ToPrecision(f). Otherwise return f.
Examples
julia> f() = π
julia> Tf = methodtoprecision(BigFloat, f, Tuple{})
PseudostableRecurrences.precision_shift — Methodprecision_shift(P::AbstractLinearRecurrencePlan)Estimates log2 of the amplification of P by performing a full recurrence based on random initial conditions.
PseudostableRecurrences.slicetype — Methodslicetype(T)Get the type of a slice of T
Examples
julia> using PseudostableRecurrences: slicetype
julia> slicetype(Matrix{Float64})
Vector{Float64} (alias for Array{Float64, 1})
julia> slicetype(UnitRange{Int})
Int64
julia> slicetype(BitArray{3})
BitMatrix (alias for BitArray{2})