TPS-Specific Functions
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) -> tClears 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, m2, m1) -> mComposes the TPSs (or TPS maps) m2 ∘ m1, and sets m equal to the result. If the GTPSA has more than 1 variable or parameter, then m1 must be an array with length equal to the total number of variables and parameters.
Arguments
m::Union{AbstractArray{TPS{T,D}},TPS{T,D}}m2::Union{AbstractArray{TPS{T,D2}},TPS{T,D2}}m1::Union{AbstractArray{TPS{T,D1}},TPS{T,D1}}
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 = first(@vars(d));
julia> cutord(sin(Δx), 5)
TPS64{Descriptor(NV=1, MO=10)}:
Coefficient Order Exponent
1.0000000000000000e+00 1 1
-1.6666666666666666e-01 3 3
julia> cutord(sin(Δx), -5)
TPS64{Descriptor(NV=1, MO=10)}:
Coefficient Order Exponent
-1.9841269841269841e-04 7 7
2.7557319223985893e-06 9 9GTPSA.cutord! — Functioncutord!(t::TPS{T}, t1::TPS{T}, order::Integer) where {T} -> tCuts 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 set to 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, monomialindex)
∂(t1::TPS, monomialindex)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.
Examples: Variable/Parameter Index:
julia> d = Descriptor(2, 5);
julia> Δx = @vars(d);
julia> deriv(Δx[1] + 2*Δx[2] + 3*Δx[1]*Δx[2], 1)
TPS64{Descriptor(NV=2, MO=5)}:
Coefficient Order Exponent
1.0000000000000000e+00 0 0 0
3.0000000000000000e+00 1 0 1
julia> deriv(Δx[1] + 2*Δx[2] + 3*Δx[1]*Δx[2], 2)
TPS64{Descriptor(NV=2, MO=5)}:
Coefficient Order Exponent
2.0000000000000000e+00 0 0 0
3.0000000000000000e+00 1 1 0Examples: Monomial Index-by-Order
julia> deriv(Δx[1] + 2*Δx[2] + 3*Δx[1]*Δx[2], [1,0])
TPS64{Descriptor(NV=2, MO=5)}:
Coefficient Order Exponent
1.0000000000000000e+00 0 0 0
3.0000000000000000e+00 1 0 1
julia> deriv(Δx[1] + 2*Δx[2] + 3*Δx[1]*Δx[2], [1,1])
TPS64{Descriptor(NV=2, MO=5)}:
Coefficient Order Exponent
3.0000000000000000e+00 0 0 0Examples: Monomial Index-by-Sparse Monomial
julia> deriv(Δx[1] + 2*Δx[2] + 3*Δx[1]*Δx[2], [1=>1])
TPS64{Descriptor(NV=2, MO=5)}:
Coefficient Order Exponent
1.0000000000000000e+00 0 0 0
3.0000000000000000e+00 1 0 1
julia> deriv(Δx[1] + 2*Δx[2] + 3*Δx[1]*Δx[2], [2=>1])
TPS64{Descriptor(NV=2, MO=5)}:
Coefficient Order Exponent
2.0000000000000000e+00 0 0 0
3.0000000000000000e+00 1 1 0GTPSA.deriv! — Functionderiv!(t::TPS{T}, t1::TPS{T}, monomialindex) where {T} -> t
∂!(t::TPS{T}, t1::TPS{T}, monomialindex) where {T} -> tDifferentiates 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.
GTPSA.evaluate — Functionevaluate(m, x)Evaluates the TPS function m at the result x.
Arguments
m::Union{TPS,AbstractArray{TPS{T,D}}}–TPSorTPSmap to evaluatex::Union{Number,AbstractArray{<:Number}}– Value(s) of the variable(s) to evaluatemat
Evaluate can also be called by "calling" m, e.g. m(x), m([x[1], x[2], ...]), or m(x[1], x[2], ...) is also allowed.
GTPSA.evaluate! — Functionevaluate!(y, m, x) -> yEvaluates the TPS function m at the point x and mutates y to contain the result.
Arguments
y::Union{Ref{T},AbstractArray{T}}– Container to store result of evaluatingmatxm::Union{TPS{T,D},AbstractArray{TPS{T,D}}}–TPSorTPSmap to evaluatex::Union{Ref{T},AbstractArray{T}}– Value(s) of the variables to evaluatemat
GTPSA.fgrad — Functionfgrad(F::AbstractArray{TPS{T,D}}, h::TPS) where {T,D}Calculates F⋅∇h.
GTPSA.fgrad! — Functionfgrad!(g::TPS{T}, F::AbstractArray{TPS{T,D}}, h::TPS{T}) where {T,D} -> gCalculates F⋅∇h and sets g equal to 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} -> tExtracts one homogenous polynomial from t1 of the given order and sets t to the result in-place.
GTPSA.integ — Functioninteg(t1::TPS, var::Integer=1)
∫(t1::TPS, var::Integer=1)Integrates t1 wrt the variable var.
GTPSA.integ! — Functioninteg!(t::TPS{T}, t1::TPS{T}, var=1) where {T} -> t
∫!(t::TPS{T}, t1::TPS{T}, var=1) where {T} -> tIntegrates t1 wrt the variable var and sets t equal to the result.
GTPSA.inv! — Functioninv!(m, m1)Inverts the TPS map m1 and sets m equal to the result. The scalar part of m1 is ignored, so the user is responsible for ensuring the coordinate system is correct by either translating m or translating the coordinate system.
Also see GTPSA.inv, which only acts on AbstractArray{TPS{T,D}} types.
Arguments
m::Union{AbstractArray{TPS{T,D}},TPS{T,D}}m1::Union{AbstractArray{TPS{T,D1}},TPS{T,D1}}
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.numtype — Functionnumtype(t::Number)
numtype(::Type{T}) where {T<:Number}If a TPS, then returns the type of number which the TPS represents. Else, returns that number type.
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) -> tGeneral function for setting a TPS t equal to t1. If change is true, then t and t1 can have different Descriptors (with invalid monomials removed) so long as the number of variables + number of parameters are equal.
GTPSA.translate — Functiontranslate(m1, x) where {T1,D}Translates the expansion point of m1 by x.
Arguments
m1::Union{AbstractArray{TPS{T1,D}},TPS}–TPSorTPSmap to translatex::Union{Number,AbstractArray{<:Number}}– Amount(s) to translate the expansion point of each variable
GTPSA.translate! — Functiontranslate!(m, m1, x) -> mSets m to m1 with its expansion point translated by x.
Arguments
m::Union{AbstractArray{TPS{T,D}},TPS{T,D}}– OutputTPSorTPSmap containingmtranslated byxm1::Union{AbstractArray{TPS{T,D1}},TPS{T,D1}}–TPSorTPSmap to translate byxx::Union{Ref{T},AbstractArray{T}}– Amount to translate the expansion point ofm1by each variable. If the GTPSA has only 1 variable, then this may be aRef.