TPS Methods
GTPSA.clearord
— Functionclearord(t1::TPS, order::Integer)
Returns a new TPS equal to t1
but with all monomial coefficients at the given order
cleared (set equal to 0).
GTPSA.clearord!
— Functionclearord!(t::TPS, order::Integer)
Clears all monomial coefficients in t
at order order
.
GTPSA.clear!
— Functionclear!(t::TPS)
Clears all monomial coefficients in the TPS
(sets to 0).
GTPSA.complex!
— Functioncomplex!(t::ComplexTPS64; tre=nothing, tim=nothing)
Sets t
to so that real(t)=tre
and imag(t)=tim
in place.
GTPSA.compose!
— Functioncompose!(m::AbstractVector{<:Union{TPS64,ComplexTPS64}}, m2::AbstractVector{<:Union{TPS64,ComplexTPS64}}, m1::AbstractVector{<:Union{TPS64,ComplexTPS64}}; work::Union{Nothing,AbstractVector{ComplexTPS64}}=nothing)
Composes the vector functions m2 ∘ m1
and stores the result in-place in m
. Promotion is allowed, provided the output vector function m
has the correct type.
If promotion is occuring, then one of the input vectors must be promoted to ComplexTPS64
. A vector of pre-allocated ComplexTPS64
s can optionally provided in work
, and has the requirement:
If eltype(m.x) != eltype(m1.x)
(then m1
must be promoted): work = m1_prom # Length >= length(m1), Vector{ComplexTPS64}
else if eltype(m.x) != eltype(m2.x)
(then m2
must be promoted): work = m2_prom # Length >= length(m2) = length(m), Vector{ComplexTPS64}
The ComplexTPS64
s in work
must be defined and have the same Descriptor
.
compose!(m::TPS, m2::TPS, m1::AbstractVector{<:Union{TPS64,ComplexTPS64}}; work::Union{Nothing,ComplexTPS64,AbstractVector{ComplexTPS64}}=nothing)
Composes the scalar TPS function m2
with vector function m1
, and stores the result in-place in m
. Promotion is allowed, provided the output function m
has the correct type.
If promotion is occuring, then the inputs must be promoted to ComplexTPS64
. If m1
is to be promoted, a vector of pre-allocated ComplexTPS64
s can optionally provided in work
, and has the requirement:
If eltype(m.x) != eltype(m1.x)
(then m1
must be promoted): work = m1_prom # Length >= length(m1), Vector{ComplexTPS64}
Else if m2
is to be promoted (typeof(m.x) != typeof(m2.x)
), a single ComplexTPS64
can be provided in work
:
work = m2_prom # ComplexTPS64
The ComplexTPS64
(s) in work
must be defined and have the same Descriptor
.
GTPSA.cutord
— Functioncutord(t1::TPS, order::Integer)
Cuts out the monomials in t1
at the given order and above. Or, if order
is negative, will cut monomials with orders at and below abs(order)
.
Examples
julia> d = Descriptor(1,10);
julia> x = vars(d);
julia> cutord(sin(x[1]), 5)
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 1 1
-1.6666666666666666e-01 3 3
julia> cutord(sin(x[1]), -5)
TPS:
Coefficient Order Exponent
-1.9841269841269841e-04 7 7
2.7557319223985893e-06 9 9
GTPSA.cutord!
— Functioncutord!(t::TPS{T}, t1::TPS{T}, order::Integer) where {T<:TPS}
Cuts out the monomials in t1
at the given order and above. Or, if order
is negative, will cut monomials with orders at and below abs(order)
. t
is filled in-place with the result. See the documentation for cutord
for examples.
GTPSA.cycle!
— Functioncycle!(t::TPS, i, n, m_, v_)
Given a starting index i
(-1 if starting at 0), will optionally fill monomial m_
(if m != C_NULL
, and m_
is a DenseVector{UInt8}
) with the monomial at index i
and optionally the value at v_
with the monomials coefficient (if v_ != C_NULL
, and v_
is a Ref{<:Union{Float64,ComplexF64}}
), and return the next NONZERO monomial index in the TPS
. This is useful for iterating through each monomial in the TPSA.
Input
t
– TPS to scani
– Index to start from (-1 to start at 0)n
– Length of monomialm_
– (Optional) Monomial to be filled if providedv_
– (Optional) Pointer to value of coefficient
Output
i
– Index of next nonzero monomial in the TPSA, or -1 if reached the end
GTPSA.deriv
— Functionderiv(t1::TPS, v::Union{TPSIndexType, Nothing}=nothing; param::Union{Integer,Nothing}=nothing, params::Union{SMIndexType, Nothing}=nothing)
∂(t1::TPS, v::Union{TPSIndexType, Nothing}=nothing; param::Union{Integer,Nothing}=nothing, params::Union{SMIndexType, Nothing}=nothing)
Differentiates t1
wrt the variable/parameter specified by the variable/parameter index, or alternatively any monomial specified by indexing-by-order OR indexing-by-sparse monomial.
Input
v
– An integer (for variable index), vector/tuple of orders for each variable (for indexing-by-order), or vector/tuple of pairs (sparse monomial)param
– (Keyword argument, optional) An integer for the parameter indexparams
– (Keyword argument, optional) Vector/tuple of pairs for sparse-monomial indexing
Examples: Variable/Parameter Index:
julia> d = Descriptor(1,5,1,5);
julia> x1 = vars(d)[1]; k1 = params(d)[1];
julia> deriv(x1*k1, 1)
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 1 0 1
julia> deriv(x1*k1, param=1)
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 1 1 0
Examples: Monomial Index-by-Order
julia> deriv(x1*k1, [1,0])
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 1 0 1
julia> deriv(x1*k1, [0,1])
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 1 1 0
julia> deriv(x1*k1, [1,1])
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 0 0 0
Examples: Monomial Index-by-Sparse Monomial
julia> deriv(x1*k1, [1=>1])
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 1 0 1
julia> deriv(x1*k1, params=[1=>1])
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 1 1 0
julia> deriv(x1*k1, [1=>1], params=[1=>1])
TPS:
Coefficient Order Exponent
1.0000000000000000e+00 0 0 0
GTPSA.deriv!
— Functionderiv!(t::TPS{T}, t1::TPS{T}, v::Union{TPSIndexType, Nothing}=nothing; param::Union{Integer,Nothing}=nothing, params::Union{SMIndexType, Nothing}=nothing) where {T}
∂!(t::TPS{T}, t1::TPS{T}, v::Union{TPSIndexType, Nothing}=nothing; param::Union{Integer,Nothing}=nothing, params::Union{SMIndexType, Nothing}=nothing) where {T}
Differentiates t1
wrt the variable/parameter specified by the variable/parameter index, or alternatively any monomial specified by indexing-by-order OR indexing-by-sparse monomial, and sets t
equal to the result in-place. See the deriv
documentation for examples.
Input
v
– An integer (for variable index), vector/tuple of orders for each variable (for indexing-by-order), or vector/tuple of pairs (sparse monomial)param
– (Keyword argument, optional) An integer for the parameter indexparams
– (Keyword argument, optional) Vector/tuple of pairs for sparse-monomial indexing
GTPSA.evaluate
— Functionevaluate(F::Vector{TPS{T}}, x::Vector{<:Number}) where {T}
Evaluates the vector function F
at the point x
, and returns the result.
GTPSA.evaluate!
— Functionevaluate!(y::Vector{T}, F::Vector{TPS{T}}, x::Vector{<:Number}) where {T}
Evaluates the vector function F
at the point x
, and fills y
with the result.
GTPSA.getord
— Functiongetord(t1::TPS, order::Integer)
Extracts one homogenous polynomial from t1
of the given order.
GTPSA.getord!
— Functiongetord!(t::TPS{T}, t1::TPS{T}, order::Integer) where {T}
Extracts one homogenous polynomial from t1
of the given order and fills t
with the result in-place.
GTPSA.integ
— Functioninteg(t1::TPS, var::Integer=1)
∫(t1::TPS, var::Integer=1)
Integrates t1
wrt the variable var
. Integration wrt parameters is not allowed, and integration wrt higher order monomials is not currently supported.
GTPSA.integ!
— Functioninteg!(t::TPS{T}, t1::TPS{T}, var::Integer=1) where {T}
∫!(t::TPS{T}, t1::TPS{T}, var::Integer=1) where {T}
Integrates t1
wrt the variable var
and fills t
with the result. Integration wrt parameters is not allowed, and integration wrt higher order monomials is not currently supported.
GTPSA.normTPS
— FunctionnormTPS(t1::TPS)
Calculates the 1-norm of the TPS
, which is the sum of the abs
of all coefficients.
GTPSA.numcoefs
— Functionnumcoefs(t::TPS)
Returns the maximum number of monomials (including the scalar part) in the TPS
/ComplexTPS64
given its Descriptor
.
GTPSA.scalar
— Functionscalar(t::TPS)
Extracts the scalar part of the TPS. Equivalent to t[0]
but this can be easily broadcasted.
GTPSA.setTPS!
— FunctionsetTPS!(t::TPS, t1::Number; change::Bool=false)
General function for setting a TPS/ComplexTPS64 t
equal to t1
. If change
is true
, then t
and t1
can have different Descriptor
s (with invalid monomials removed) so long as the number of variables + number of parameters are equal.
GTPSA.translate
— Functiontranslate(m1::Vector{<:TPS{T}}, x::Vector{<:Number}) where {T}
returns a vector function equal to m1
with its expansion point translated by x
.
GTPSA.translate!
— Functiontranslate!(m::Vector{<:TPS{T}}, m1::Vector{<:TPS{T}}, x::Vector{<:Number}) where {T}
Fills m
with the vector function equal to m1
with its expansion point translated by x
.