GTPSA.CTPSA
— Type`CTPSA`
This is a 1-to-1 struct for the C definition ctpsa
(complex TPSA) in GTPSA.
Fields
d::Ptr{Cvoid}
– Pointer toDesc
for thisCTPSA
uid::Cint
– Special user field for external use (and padding)mo::Cuchar
– max ord (allocated)lo::Cuchar
– lowest used ordhi::Cuchar
– highest used ordnz::Culonglong
– zero/nonzero homogenous polynomials. Note: Int64 if 64 bit compiled C code, else 32 bitnam::NTuple{NAMSZ,Cuchar}
– tpsa name max string length 16 NAMSZcoef::Ptr{ComplexF64}
– warning: must be identical to ctpsa up to coef excluded
GTPSA.ComplexTPS
— TypeComplexTPS(cta::Union{Number,Nothing}=nothing; use::Union{Descriptor,TPS,ComplexTPS,Nothing}=nothing)::ComplexTPS
Constructor to create a new ComplexTPS
equal to the number cta
. If cta
is a ComplexTPS
(or TPS
), this is equivalent to a copy constructor, with the result by default having the same Descriptor
as cta
. If cta
is not a TPS
orComplexTPS
, then the Descriptor
used will by default be GTPSA.desc_current
. The Descriptor
for the constructed ComplexTPS
can be set using use
. If a TPS
or ComplexTPS
is passed to use
, the Descriptor
for that TPS will be used.
The constructor can also be used to create a copy of a ComplexTPS
under one Descriptor
to instead have a different Descriptor
. In this case, invalid monomials under the new Descriptor
are removed.
Input
cta
– AnyNumber
use
– (Optional) specify whichDescriptor
to use, default isnothing
which uses theDescriptor
forcta
ifcta <: Union{TPS,ComplexTPS}
, else usesGTPSA.desc_current
Output
ret
– NewComplexTPS
equal tocta
with removal of invalid monomials ifcta
is aTPS
/ComplexTPS
and a newDescriptor
is specified
GTPSA.Desc
— Type`Desc`
This is a 1-to-1 struct for the C definition desc
(descriptor) in GTPSA. Descriptors include all information about the TPSA, including the number of variables/parameters and their orders, lookup tables for the monomials, monomial indexing function, and pre-allocated permanent temporaries for fast evaluation.
Fields
id::Cint
– Index in list of registered descriptorsnn::Cint
– Number of variables + number of parameters,nn = nv+np <= 100000
nv::Cint
– Number of variablesnp::Cint
– Number of parametersmo::Cuchar
– Max order of both variables AND parameterspo::Cuchar
– Max order of parameterssto::Cuchar
– Global order of truncation. Note:ord_t
in gtpsa istypedef
forunsigned char
(Cuchar
)no::Ptr{Cuchar}
– Array of orders of each variable (firstnv
entries) and parameters (lastnp
entries), lengthnn
. Note: In C this isconst
uno::Cint
– User provided array of orders of each variable/parameter (withmad_desc_newvpo
)nth::Cint
– Max number of threads or 1nc::Cuint
– Number of coefficients (max length of TPSA)monos::Ptr{Cuchar}
– 'Matrix' storing the monomials (sorted by variable)ords::Ptr{Cuchar}
– Order of each monomial ofTo
prms::Ptr{Cuchar}
– Order of parameters in each monomial ofTo
(zero = no parameters)To::Ptr{Ptr{Cuchar}}
– Table by orders - pointers to monomials, sorted by orderTv::Ptr{Ptr{Cuchar}}
– Table by vars - pointers to monomials, sorted by variableocs::Ptr{Ptr{Cuchar}}
–ocs[t,i]
->o
in mul, computeo
on threadt 3 <= o <= mo
aterminated with 0ord2idx::Ptr{Cint}
– Order to polynomial start index inTo
(i.e. in TPSAcoef
)tv2to::Ptr{Cint}
– Lookuptv
->to
to2tv::Ptr{Cint}
– Lookupto
->tv
H::Ptr{Cint}
– Indexing matrix inTv
L::Ptr{Ptr{Cint}}
– Multiplication indexesL[oa,ob]
->L_ord
L_ord[ia,ib]
->ic
L_idx::Ptr{Ptr{Ptr{Cint}}}
–L_idx[oa,ob]
->[start] [split] [end]
idxs inL
size::Culonglong
– Bytes used bydesc
.Unsigned Long Int
: In 32 bit system isInt32
but 64 bit isInt64
. UsingCulonglong
assuming 64 bitt::Ptr{Ptr{Cvoid}}
– Temporary array contains 8 pointers toRTPSA
s already initializedct::Ptr{Ptr{Cvoid}}
– Temporary array contains 8 pointers toCTPSA
s already initializedti::Ptr{Cint}
– idx of tmp used by each thread (length = # threads)cti::Ptr{Cint}
– idx of tmp used by each thread (length = # threads)
GTPSA.Descriptor
— MethodDescriptor(nv::Integer, vo::Integer, np::Integer, po::Integer)::Descriptor
Creates a TPSA Descriptor
with nv
variables each with truncation order vo
, and np
parameters each with truncation order po
Input
nv
– Number of variables in the TPSAvo
– Truncation order of the variables in the TPSAnp
– Number of parameters in the TPSApo
– Truncation order of the parameters
GTPSA.Descriptor
— MethodDescriptor(nv::Integer, vo::Integer)::Descriptor
Creates a TPSA Descriptor
with nv
variables of maximum order vo
for each.
Input
nv
– Number of variables in the TPSAvo
– Maximum order of the variables in the TPSA
GTPSA.Descriptor
— MethodDescriptor(vos::Vector{<:Integer}, pos::Vector{<:Integer})::Descriptor
Creates a TPSA Descriptor
with length(vos)
variables with individual truncation orders specified in vos
, and length(pos)
parameters with individual truncation orders specified in pos
.
Input
vos
–Vector
of the individual truncation orders of each variablepos
–Vector
of the individual truncation orders of each parameter
GTPSA.Descriptor
— MethodDescriptor(vos::Vector{<:Integer})::Descriptor
Creates a TPSA Descriptor
with length(mos)
variables with individual truncation orders specified in the Vector vos
.
Input
vos
–Vector
of the individual truncation orders of each variable
GTPSA.RTPSA
— Type`RTPSA`
This is a 1-to-1 struct for the C definition tpsa
(real TPSA) in GTPSA.
Fields
d::Ptr{Cvoid}
– Ptr to tpsa descriptoruid::Cint
– Special user field for external use (and padding)mo::Cuchar
– max ord (allocated)lo::Cuchar
– lowest used ordhi::Cuchar
– highest used ordnz::Culonglong
– zero/nonzero homogenous polynomials. Note: Int64 if 64 bit compiled C code, else 32 bitnam::NTuple{NAMSZ,Cuchar}
– tpsa name max string length 16 NAMSZcoef::Ptr{Cdouble}
– warning: must be identical to ctpsa up to coef excluded
GTPSA.TPS
— TypeTPS(ta::Union{Real,Nothing}=nothing; use::Union{Descriptor,TPS,ComplexTPS,Nothing}=nothing)::TPS
Constructor to create a new TPS
equal to the real value ta
. If ta
is a TPS
, this is equivalent to a copy constructor, with the result by default having the same Descriptor
as ta
. If ta
is not a TPS
, then the Descriptor
used will by default be GTPSA.desc_current
. The Descriptor
for the constructed TPS
can be set using use
. If a TPS
or ComplexTPS
is passed to use
, the Descriptor
for that TPS will be used.
The constructor can also be used to create a copy of a TPS
under one Descriptor
to instead have a different Descriptor
. In this case, invalid monomials under the new Descriptor
are removed.
Input
ta
– AnyReal
use
– (Optional) specify whichDescriptor
to use, default isnothing
which uses theDescriptor
forta
ifta isa TPS
, else usesGTPSA.desc_current
Output
ret
– NewTPS
equal tota
with removal of invalid monomials ifta
is aTPS
and a newDescriptor
is specified
Base.inv
— Methodinv(ma::Vector{<:Union{TPS,ComplexTPS}})
Inverts the map ma
such that ma ∘ inv(ma) = 1
in the variables.
Example
julia> d = Descriptor(2,10); x = vars()[1]; p = vars()[2];
julia> time = 0.01; k = 2; m = 0.01;
julia> h = p^2/(2m) + 1/2*k*x^2;
julia> hf = getvectorfield(h);
julia> map = exppb(-time*hf, [x, p]);
julia> map ∘ inv(map)
2-element Vector{TPS}:
Out Coefficient Order Exponent
-------------------------------------------------
1: 1.0000000000000000e+00 1 1 0
-------------------------------------------------
2: 1.0000000000000002e+00 1 0 1
GTPSA.complexparams
— Functioncomplexparams(d::Descriptor=GTPSA.desc_current)::Vector{ComplexTPS}
Returns ComplexTPS
s corresponding to the parameters for the Descriptor
specified by use
. Default value is GTPSA.desc_current
.
Input
use
– (Optional) Specify which TPSADescriptor
to use, default isGTPSA.desc_current
Output
k
–Vector
containing unitComplexTPS
s corresponding to each parameter
GTPSA.complexvars
— Functioncomplexvars(use::Union{Descriptor,TPS,ComplexTPS}=GTPSA.desc_current)::Vector{ComplexTPS}
Returns ComplexTPS
s corresponding to the variables for the Descriptor
specified by use
. Default value is GTPSA.desc_current
.
Input
use
– (Optional) Specify which TPSADescriptor
to use, default isGTPSA.desc_current
Output
x
–Vector
containing unitComplexTPS
s corresponding to each variable
GTPSA.cutord
— Methodcutord(t1::Union{TPS, ComplexTPS}, 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.deriv
— Functionderiv(t1::Union{TPS,ComplexTPS}, v::Union{Integer, Vector{<:Union{<:Pair{<:Integer,<:Integer},<:Integer}}, Nothing}=nothing; param::Union{<:Integer,Nothing}=nothing, params::Union{Vector{<:Pair{<:Integer,<:Integer}}, Nothing}=nothing)
∂(t1::Union{TPS,ComplexTPS}, v::Union{Integer, Vector{<:Union{<:Pair{<:Integer,<:Integer},<:Integer}}, Nothing}=nothing; param::Union{<:Integer,Nothing}=nothing, params::Union{Vector{<:Pair{<:Integer,<:Integer}}, 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), an array of orders for each variable (for indexing-by-order), or an array of pairs (sparse monomial)param
– (Keyword argument, optional) An integer for the parameter indexparams
– (Keyword argument, optional) An array 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.evaluate
— Methodevaluate(ct1::ComplexTPS, x::Vector{<:Number})::ComplexF64
Evaluates ct1
at the point x
.
GTPSA.evaluate
— Methodevaluate(t1::TPS, x::Vector{<:Real})::Float64
Evaluates t1
at the point x
.
GTPSA.evaluate
— Methodevaluate(m::Vector{ComplexTPS}, x::Vector{<:Number})::Vector{ComplexF64}
Evaluates m
at the point x
.
GTPSA.evaluate
— Methodevaluate(m::Vector{TPS}, x::Vector{<:Real})::Vector{Float64}
Evaluates m
at the point x
.
GTPSA.exppb
— Functionexppb(F::Vector{<:Union{TPS,ComplexTPS}}, m::Vector{<:Union{TPS,ComplexTPS}}=vars(first(F)))
Calculates exp(F⋅∇)m = m + F⋅∇m + (F⋅∇)²m/2! + ...
. If m
is not provided, it is assumed to be the identity.
Example
julia> d = Descriptor(2,10); x = vars()[1]; p = vars()[2];
julia> time = 0.01; k = 2; m = 0.01;
julia> h = p^2/(2m) + 1/2*k*x^2;
julia> hf = getvectorfield(h);
julia> map = exppb(-time*hf, [x, p])
2-element Vector{TPS}:
Out Coefficient Order Exponent
-------------------------------------------------
1: 9.9001665555952290e-01 1 1 0
1: 9.9666999841313930e-01 1 0 1
-------------------------------------------------
2: -1.9933399968262787e-02 1 1 0
2: 9.9001665555952378e-01 1 0 1
GTPSA.fgrad
— Methodfgrad(F::Vector{<:Union{TPS,ComplexTPS}}, g::Union{TPS,ComplexTPS})
Calculates F⋅∇g
.
GTPSA.gethamiltonian
— Methodgethamiltonian(F::Vector{<:Union{TPS,ComplexTPS}})
Assuming the variables in the TPSA are canonically-conjugate, and ordered so that the canonically- conjugate variables are consecutive (q₁, p₁, q₂, p₂, ...), this function calculates the Hamiltonian from a vector field F
that can be obtained from a Hamiltonian (e.g. by getvectorfield
). Explicitly, ∫ F₁ dp₁ - ∫ F₂ dq₁ + ... + ∫ F₂ₙ₋₁ dpₙ - ∫ F₂ₙ dqₙ
Example
julia> d = Descriptor(2,10); x = vars();
julia> h = (x[1]^2 + x[2]^2)/2
TPS:
Coefficient Order Exponent
5.0000000000000000e-01 2 2 0
5.0000000000000000e-01 2 0 2
julia> F = getvectorfield(h)
2-element Vector{TPS}:
Out Coefficient Order Exponent
-------------------------------------------------
1: -1.0000000000000000e+00 1 0 1
-------------------------------------------------
2: 1.0000000000000000e+00 1 1 0
julia> gethamiltonian(F)
TPS:
Coefficient Order Exponent
5.0000000000000000e-01 2 2 0
5.0000000000000000e-01 2 0 2
GTPSA.getord
— Methodgetord(t1::Union{TPS, ComplexTPS}, order::Integer)
Extracts one homogenous polynomial from t1
of the given order.
GTPSA.getvectorfield
— Methodgetvectorfield(h::Union{TPS,ComplexTPS})::Vector{<:typeof(h)}
Assuming the variables in the TPSA are canonically-conjugate, and ordered so that the canonically- conjugate variables are consecutive (q₁, p₁, q₂, p₂, ...), calculates the vector field (Hamilton's equations) from the passed Hamiltonian, defined as [∂h/∂p₁, -∂h/∂q₁, ...]
Example
julia> d = Descriptor(2,10); x = vars();
julia> h = (x[1]^2 + x[2]^2)/2
TPS:
Coefficient Order Exponent
5.0000000000000000e-01 2 2 0
5.0000000000000000e-01 2 0 2
julia> getvectorfield(h)
2-element Vector{TPS}:
Out Coefficient Order Exponent
-------------------------------------------------
1: -1.0000000000000000e+00 1 0 1
-------------------------------------------------
2: 1.0000000000000000e+00 1 1 0
GTPSA.gradient!
— Methodgradient!(result::Vector{ComplexF64}, ct::ComplexTPS; include_params=false)
Extracts the first-order partial derivatives (evaluated at 0) from the ComplexTPS
and fills the result
vector in-place. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the first-order monomial coefficients already in the ComplexTPS
.
Input
ct
–ComplexTPS
to extract the gradient frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
result
– PreallocatedVector
to fill with the gradient of the ComplexTPS
GTPSA.gradient!
— Methodgradient!(result::Vector{Float64}, t::TPS; include_params=false)
Extracts the first-order partial derivatives (evaluated at 0) from the TPS
and fills the result
vector in-place. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the first-order monomial coefficients already in the TPS
.
Input
t
–TPS
to extract the gradient frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
result
– PreallocatedVector
to fill with the gradient of the TPS
GTPSA.gradient
— Methodgradient(ct::ComplexTPS; include_params=false)::Vector{ComplexF64}
Extracts the first-order partial derivatives (evaluated at 0) from the ComplexTPS
. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the first-order monomial coefficients already in the ComplexTPS
.
Input
ct
–ComplexTPS
to extract the gradient frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
grad
– Gradient of the ComplexTPS
GTPSA.gradient
— Methodgradient(t::TPS; include_params=false)::Vector{Float64}
Extracts the first-order partial derivatives (evaluated at 0) from the TPS
. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the first-order monomial coefficients already in the TPS
.
Input
t
–TPS
to extract the gradient frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
grad
– Gradient of the TPS
GTPSA.hessian!
— Methodhessian!(result::Matrix{ComplexF64},ct::ComplexTPS; include_params=false)
Extracts the second-order partial derivatives (evaluated at 0) from the ComplexTPS
and fills the result
matrix in-place. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the second-order monomial coefficients already in the ComplexTPS
.
Input
ct
–ComplexTPS
to extract the Hessian frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
result
– Preallocated matrix to fill with the Hessian of the ComplexTPS
GTPSA.hessian!
— Methodhessian!(result::Matrix{Float64},t::TPS; include_params=false)
Extracts the second-order partial derivatives (evaluated at 0) from the TPS
and fills the result
matrix in-place. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the second-order monomial coefficients already in the TPS
.
Input
t
–TPS
to extract the Hessian frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
result
– Preallocated matrix to fill with the Hessian of the TPS
GTPSA.hessian
— Methodhessian(ct::ComplexTPS; include_params=false)::Matrix{ComplexF64}
Extracts the second-order partial derivatives (evaluated at 0) from the ComplexTPS
. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the second-order monomial coefficients already in the ComplexTPS
.
Input
t
–ComplexTPS
to extract the Hessian frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
H
– Hessian of the ComplexTPS
GTPSA.hessian
— Methodhessian(t::TPS; include_params=false)::Matrix{Float64}
Extracts the second-order partial derivatives (evaluated at 0) from the TPS
. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the second-order monomial coefficients already in the TPS
.
Input
t
–TPS
to extract the Hessian frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
H
– Hessian of the TPS
GTPSA.integ
— Functioninteg(t1::Union{TPS, ComplexTPS}, var::Integer=1)
∫(t1::Union{TPS, ComplexTPS}, 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.jacobian!
— Methodjacobian!(result::Matrix{ComplexF64}, m::Vector{ComplexTPS}; include_params=false)
Extracts the first-order partial derivatives (evaluated at 0) from the Vector of ComplexTPS
s. and fills the result
matrix in-place. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the first-order monomial coefficients already in the ComplexTPS
s.
Input
m
–Vector
ofComplexTPS
s. to extract the Jacobian frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
result
– Preallocated matrix to fill with the Jacobian ofm
GTPSA.jacobian!
— Methodjacobian!(result::Matrix{Float64}, m::Vector{TPS}; include_params=false)
Extracts the first-order partial derivatives (evaluated at 0) from the Vector of TPS
s. and fills the result
matrix in-place. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the first-order monomial coefficients already in the TPS
s.
Input
m
–Vector
ofTPS
s. to extract the Jacobian frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
result
– Preallocated matrix to fill with the Jacobian ofm
GTPSA.jacobian
— Methodjacobian(m::Vector{ComplexTPS}; include_params=false)::Matrix{ComplexF64}
Extracts the first-order partial derivatives (evaluated at 0) from the Vector of ComplexTPS
s. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the first-order monomial coefficients already in the ComplexTPS
s.
Input
m
–Vector
ofComplexTPS
s. to extract the Jacobian frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
J
– Jacobian ofm
GTPSA.jacobian
— Methodjacobian(m::Vector{TPS}; include_params=false)::Matrix{Float64}
Extracts the first-order partial derivatives (evaluated at 0) from the Vector of TPS
s. The partial derivatives wrt the parameters will also be extracted when the include_params
flag is set to true
. Note that this function is not calculating anything - just extracting the first-order monomial coefficients already in the TPS
s.
Input
m
–Vector
ofTPS
s. to extract the Jacobian frominclude_params
– (Optional) Extract partial derivatives wrt parameters. Default is false
Output
J
– Jacobian ofm
GTPSA.lb
— Methodlb(A::Vector{<:Union{TPS,ComplexTPS}}, F::Vector{<:Union{TPS,ComplexTPS}})
Computes the Lie bracket of the vector functions A
and F
, defined over N variables as Σᵢᴺ Aᵢ (∂F/∂xᵢ) - Fᵢ (∂A/∂xᵢ)
Example
julia> d = Descriptor(2,10); x = vars();
julia> A = [-x[2], x[1]]
2-element Vector{TPS}:
Out Coefficient Order Exponent
-------------------------------------------------
1: -1.0000000000000000e+00 1 0 1
-------------------------------------------------
2: 1.0000000000000000e+00 1 1 0
julia> F = [-x[1]^2, 2*x[1]*x[2]]
2-element Vector{TPS}:
Out Coefficient Order Exponent
-------------------------------------------------
1: -1.0000000000000000e+00 2 2 0
-------------------------------------------------
2: 2.0000000000000000e+00 2 1 1
julia> lb(A,F)
2-element Vector{TPS}:
Out Coefficient Order Exponent
-------------------------------------------------
1: 4.0000000000000000e+00 2 1 1
-------------------------------------------------
2: 3.0000000000000000e+00 2 2 0
2: -2.0000000000000000e+00 2 0 2
GTPSA.logpb
— Functionlogpb(mf::Vector{<:Union{TPS,ComplexTPS}}, mi::Vector{<:Union{TPS,ComplexTPS}}=vars(first(F)))
Given a final map mf
and initial map mi
, this function calculates the vector field F
such that mf=exp(F⋅∇)mi
. If mi
is not provided, it is assumed to be the identity.
julia> d = Descriptor(2,10); x = vars()[1]; p = vars()[2];
julia> time = 0.01; k = 2; m = 0.01;
julia> h = p^2/(2m) + 1/2*k*x^2;
julia> hf = getvectorfield(h);
julia> map = exppb(-time*hf);
julia> logpb(map) == -time*hf
true
GTPSA.mad_ctpsa_acc!
— Methodmad_ctpsa_acc!(a::Ptr{CTPSA}, v::ComplexF64, c::Ptr{CTPSA})
Adds a*v
to TPSA c
. Aliasing OK.
Input
a
– Source TPSAa
v
– Scalar with double precision
Output
c
– Destination TPSAc += v*a
GTPSA.mad_ctpsa_acc_r!
— Methodmad_ctpsa_acc_r!(a::Ptr{CTPSA}, v_re::Cdouble, v_im::Cdouble, c::Ptr{CTPSA})
Adds a*v
to TPSA c
. Aliasing OK. Without complex-by-value arguments.
Input
a
– Source TPSAa
v_re
– Real part of scalar with double precisionv_im
– Imaginary part of scalar with double precision
Output
c
– Destination TPSAc += v*a
GTPSA.mad_ctpsa_acos!
— Methodmad_ctpsa_acos!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the acos
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = acos(a)
GTPSA.mad_ctpsa_acosh!
— Methodmad_ctpsa_acosh!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the acosh
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = acosh(a)
GTPSA.mad_ctpsa_acot!
— Methodmad_ctpsa_acot!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the acot
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = acot(a)
GTPSA.mad_ctpsa_acoth!
— Methodmad_ctpsa_acoth!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the acoth
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = acoth(a)
GTPSA.mad_ctpsa_add!
— Methodmad_ctpsa_add!(a::Ptr{CTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets the destination TPSA c = a + b
Input
a
– Source TPSAa
b
– Source TPSAb
Output
c
– Destination TPSAc = a + b
GTPSA.mad_ctpsa_addt!
— Methodmad_ctpsa_addt!(a::Ptr{CTPSA}, b::Ptr{RTPSA}, c::Ptr{CTPSA})
Sets the destination CTPSA c = a + b
(internal real-to-complex conversion).
Input
a
– Source CTPSAa
b
– Source RTPSAb
Output
c
– Destination CTPSAc = a + b
GTPSA.mad_ctpsa_asin!
— Methodmad_ctpsa_asin!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the asin
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = asin(a)
GTPSA.mad_ctpsa_asinc!
— Methodmad_ctpsa_asinc!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the asinc(a) = asin(a)/a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = asinc(a) = asin(a)/a
GTPSA.mad_ctpsa_asinh!
— Methodmad_ctpsa_asinh!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the asinh
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = asinh(a)
GTPSA.mad_ctpsa_asinhc!
— Methodmad_ctpsa_asinhc!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the asinhc
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = asinhc(a)
GTPSA.mad_ctpsa_atan!
— Methodmad_ctpsa_atan!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the atan
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = atan(a)
GTPSA.mad_ctpsa_atanh!
— Methodmad_ctpsa_atanh!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the atanh
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = atanh(a)
GTPSA.mad_ctpsa_ax2pby2pcz2!
— Methodmad_ctpsa_ax2pby2pcz2!(a::ComplexF64, x::Ptr{CTPSA}, b::ComplexF64, y::Ptr{CTPSA}, c::ComplexF64, z::Ptr{CTPSA}, r::Ptr{CTPSA})
r = a*x^2 + b*y^2 + c*z^2
Input
a
– Scalara
x
– TPSAx
b
– Scalarb
y
– TPSAy
c
– Scalarc
z
– TPSAz
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_ax2pby2pcz2_r!
— Methodmad_ctpsa_ax2pby2pcz2_r!(a_re::Cdouble, a_im::Cdouble, x::Ptr{CTPSA}, b_re::Cdouble, b_im::Cdouble, y::Ptr{CTPSA}, c_re::Cdouble, c_im::Cdouble, z::Ptr{CTPSA}, r::Ptr{CTPSA})
r = a*x^2 + b*y^2 + c*z^2
. Same as mad_ctpsa_ax2pby2pcz2
without complex-by-value arguments.
Input
a_re
– Real part of Scalara
a_im
– Imag part of Scalara
x
– TPSAx
b_re
– Real part of Scalarb
b_im
– Imag part of Scalarb
y
– TPSAy
c_re
– Real part of Scalarc
c_im
– Imag part of Scalarc
z
– TPSAz
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axpb!
— Methodmad_ctpsa_axpb!(a::ComplexF64, x::Ptr{CTPSA}, b::ComplexF64, r::Ptr{CTPSA})
r = a*x + b
Input
a
– Scalara
x
– TPSAx
b
– Scalarb
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axpb_r!
— Methodmad_ctpsa_axpb_r!(a_re::Cdouble, a_im::Cdouble, x::Ptr{CTPSA}, b_re::Cdouble, b_im::Cdouble, r::Ptr{CTPSA})
r = a*x + b
. Same as mad_ctpsa_axpb
without complex-by-value arguments.
Input
a_re
– Real part of Scalara
a_im
– Imag part of Scalara
x
– TPSAx
b_re
– Real part of Scalarb
b_im
– Imag part of Scalarb
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axpbypc!
— Methodmad_ctpsa_axpbypc!(a::ComplexF64, x::Ptr{CTPSA}, b::ComplexF64, y::Ptr{CTPSA}, c::ComplexF64, r::Ptr{CTPSA})
r = a*x+b*y+c
Input
a
– Scalara
x
– TPSAx
b
– Scalarb
y
– TPSAy
c
– Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axpbypc_r!
— Methodmad_ctpsa_axpbypc_r!(a_re::Cdouble, a_im::Cdouble, x::Ptr{CTPSA}, b_re::Cdouble, b_im::Cdouble, y::Ptr{CTPSA}, c_re::Cdouble, c_im::Cdouble, r::Ptr{CTPSA})
r = a*x + b*y + c
. Same as mad_ctpsa_axpbypc
without complex-by-value arguments.
Input
a_re
– Real part of Scalara
a_im
– Imag part of Scalara
x
– TPSAx
b_re
– Real part of Scalarb
b_im
– Imag part of Scalarb
y
– TPSAy
c_re
– Real part of Scalarc
c_im
– Imag part of Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axpsqrtbpcx2!
— Methodmad_ctpsa_axpsqrtbpcx2!(x::Ptr{CTPSA}, a::ComplexF64, b::ComplexF64, c::ComplexF64, r::Ptr{CTPSA})
r = a*x + sqrt(b + c*x^2)
Input
x
– TPSAx
a
– Scalara
b
– Scalarb
c
– Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axpsqrtbpcx2_r!
— Methodmad_ctpsa_axpsqrtbpcx2_r!(x::Ptr{CTPSA}, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble, c_re::Cdouble, c_im::Cdouble, r::Ptr{CTPSA})
r = a*x + sqrt(b + c*x^2)
. Same as mad_ctpsa_axpsqrtbpcx2
without complex-by-value arguments.
Input
a_re
– Real part of Scalara
a_im
– Imag part of Scalara
b_re
– Real part of Scalarb
b_im
– Imag part of Scalarb
c_re
– Real part of Scalarc
c_im
– Imag part of Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axypb!
— Methodmad_ctpsa_axypb!(a::ComplexF64, x::Ptr{CTPSA}, y::Ptr{CTPSA}, b::ComplexF64, r::Ptr{CTPSA})
r = a*x*y + b
Input
a
– Scalara
x
– TPSAx
y
– TPSAy
b
– Scalarb
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axypb_r!
— Methodmad_ctpsa_axypb_r!(a_re::Cdouble, a_im::Cdouble, x::Ptr{CTPSA}, y::Ptr{CTPSA}, b_re::Cdouble, b_im::Cdouble, r::Ptr{CTPSA})
r = a*x*y + b
. Same as mad_ctpsa_axypb
without complex-by-value arguments.
Input
a_re
– Real part of Scalara
a_im
– Imag part of Scalara
x
– TPSAx
y
– TPSAy
b_re
– Real part of Scalarb
b_im
– Imag part of Scalarb
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axypbvwpc!
— Methodmad_ctpsa_axypbvwpc!(a::ComplexF64, x::Ptr{CTPSA}, y::Ptr{CTPSA}, b::ComplexF64, v::Ptr{CTPSA}, w::Ptr{CTPSA}, c::ComplexF64, r::Ptr{CTPSA})
r = a*x*y + b*v*w + c
Input
a
– Scalara
x
– TPSAx
y
– TPSAy
b
– Scalarb
v
– TPSA vw
– TPSA wc
– Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axypbvwpc_r!
— Methodmad_ctpsa_axypbvwpc_r!(a_re::Cdouble, a_im::Cdouble, x::Ptr{CTPSA}, y::Ptr{CTPSA}, b_re::Cdouble, b_im::Cdouble, v::Ptr{CTPSA}, w::Ptr{CTPSA}, c_re::Cdouble, c_im::Cdouble, r::Ptr{CTPSA})
r = a*x*y + b*v*w + c
. Same as mad_ctpsa_axypbvwpc
without complex-by-value arguments.
Input
a_re
– Real part of Scalara
a_im
– Imag part of Scalara
x
– TPSAx
y
– TPSAy
b_re
– Real part of Scalarb
b_im
– Imag part of Scalarb
v
– TPSA vw
– TPSA wc_re
– Real part of Scalarc
c_im
– Imag part of Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axypbzpc!
— Methodmad_ctpsa_axypbzpc!(a::ComplexF64, x::Ptr{CTPSA}, y::Ptr{CTPSA}, b::ComplexF64, z::Ptr{CTPSA}, c::ComplexF64, r::Ptr{CTPSA})
r = a*x*y + b*z + c
Input
a
– Scalara
x
– TPSAx
y
– TPSAy
b
– Scalarb
z
– TPSAz
c
– Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_axypbzpc_r!
— Methodmad_ctpsa_axypbzpc_r!(a_re::Cdouble, a_im::Cdouble, x::Ptr{CTPSA}, y::Ptr{CTPSA}, b_re::Cdouble, b_im::Cdouble, z::Ptr{CTPSA}, c_re::Cdouble, c_im::Cdouble, r::Ptr{CTPSA})
r = a*x*y + b*z + c
. Same as mad_ctpsa_axypbzpc
without complex-by-value arguments.
Input
a_re
– Real part of Scalara
a_im
– Imag part of Scalara
x
– TPSAx
y
– TPSAy
b_re
– Real part of Scalarb
b_im
– Imag part of Scalarb
z
– TPSAz
c_re
– Real part of Scalarc
c_im
– Imag part of Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_cabs!
— Methodmad_ctpsa_cabs!(t::Ptr{CTPSA}, r::Ptr{RTPSA})
Sets the RTPSA r
equal to the aboslute value of CTPSA t
. Specifically, the result contains a TPSA with the abs
of all coefficients.
Input
t
– Source CTPSA
Output
r
– Destination RTPSA withr = |t|
GTPSA.mad_ctpsa_carg!
— Methodmad_ctpsa_carg!(t::Ptr{CTPSA}, r::Ptr{RTPSA})
Sets the RTPSA r
equal to the argument (phase) of CTPSA t
Input
t
– Source CTPSA
Output
r
– Destination RTPSA withr = carg(t)
GTPSA.mad_ctpsa_clear!
— Methodmad_ctpsa_clear!(t::Ptr{CTPSA})
Clears the TPSA (reset to 0)
Input
t
– Complex TPSA
GTPSA.mad_ctpsa_compose!
— Methodmad_ctpsa_compose!(na::Cint, ma::Vector{Ptr{CTPSA}}, nb::Cint, mb::Vector{Ptr{CTPSA}}, mc::Vector{Ptr{CTPSA}})
Composes two maps.
Input
na
– Number of TPSAs in Mapma
ma
– Mapma
nb
– Number of TPSAs in Mapmb
mb
– Mapmb
Output
mc
– Composition of mapsma
andmb
GTPSA.mad_ctpsa_conj!
— Methodmad_ctpsa_conj(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Calculates the complex conjugate of of TPSA a
.
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = conj(a)
GTPSA.mad_ctpsa_convert!
— Methodmad_ctpsa_convert!(t::Ptr{CTPSA}, r::Ptr{CTPSA}, n::Cint, t2r_::Vector{Cint}, pb::Cint)
General function to convert TPSAs to different orders and reshuffle canonical coordinates. The destination TPSA will be of order n
, and optionally have the variable reshuffling defined by t2r_
and poisson bracket sign. e.g. if t2r_ = {1,2,3,4,6,5}
and pb = -1
, canonical coordinates 6 and 5 are swapped and the new 5th canonical coordinate will be negated. Useful for comparing with different differential algebra packages.
Input
t
– Source complex TPSAn
– Length of vectort2r_
– (Optional) Vector of index lookuppb
– Poisson bracket, 0, 1:fwd, -1:bwd
Output
r
– Destination complex TPSA with specified order and canonical coordinate reshuffling.
GTPSA.mad_ctpsa_copy!
— Methodmad_ctpsa_copy!(t::Ptr{CTPSA}, r::Ptr{CTPSA})
Makes a copy of the complex TPSA t
to r
.
Input
t
– Source complex TPSA
Output
r
– Destination complex TPSA
GTPSA.mad_ctpsa_cos!
— Methodmad_ctpsa_cos!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the cos
of TPSA a
.
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = cos(a)
GTPSA.mad_ctpsa_cosh!
— Methodmad_ctpsa_cosh!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the cosh
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = cosh(a)
GTPSA.mad_ctpsa_cot!
— Methodmad_ctpsa_cot!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the cot
of TPSA a
.
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = cot(a)
GTPSA.mad_ctpsa_coth!
— Methodmad_ctpsa_coth!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the coth
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = coth(a)
GTPSA.mad_ctpsa_cplx!
— Methodmad_ctpsa_cplx!(re_::Ptr{RTPSA}, im_::Ptr{RTPSA}, r::Ptr{CTPSA})
Creates a CTPSA with real and imaginary parts from the RTPSAs re_
and im_
respectively.
Input
re_
– Real part of CTPSA to makeim_
– Imaginary part of CTPSA to make
Output
r
– Destination CTPSA withr = re_ + im*im_
GTPSA.mad_ctpsa_cutord!
— Methodmad_ctpsa_cutord!(t::Ptr{CTPSA}, r::Ptr{CTPSA}, ord::Cint)
Cuts the TPSA off at the given order and above, or if ord
is negative, will cut orders below abs(ord)
(e.g. if ord
= -3, then orders 0-3 are cut off).
Input
t
– Source complex TPSAord
– Cut order:0..-ord
orord..mo
Output
r
– Destination complex TPSA
GTPSA.mad_ctpsa_cycle!
— Methodmad_ctpsa_cycle!(t::Ptr{CTPSA}, i::Cint, n::Cint, m_::Vector{Cuchar}, v_::Ref{ComplexF64})::Cint
Used for scanning through each nonzero monomial in the TPSA. Given a starting index (-1 if starting at 0), will optionally fill monomial m_
with the monomial at index i
and the value at v_
with the monomials coefficient, and return the next NONZERO monomial index in the TPSA. This is useful for building an iterator through the TPSA.
Input
t
– TPSA to scani
– Index to start from (-1 to start at 0)n
– Size 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.mad_ctpsa_debug
— Methodmad_ctpsa_debug(t::Ptr{CTPSA}, name_::Cstring, fnam_::Cstring, line_::Cint, stream_::Ptr{Cvoid})
Prints TPSA with all information of data structure.
Input
t
– TPSAname_
– (Optional) Name of TPSAfnam_
– (Optional) File name to print toline_
– (Optional) Line number in file to start atstream_
– (Optional) I/O stream to print to, default isstdout
GTPSA.mad_ctpsa_del!
— Methodmad_ctpsa_del!(t::Ptr{CTPSA})
Calls the destructor for the complex TPSA.
Input
t
– Complex TPSA to destruct
GTPSA.mad_ctpsa_deriv!
— Methodmad_ctpsa_deriv!(a::Ptr{CTPSA}, c::Ptr{CTPSA}, iv::Cint)
Differentiates TPSA with respect to the variable with index iv
.
Input
a
– Source TPSA to differentiateiv
– Index of variable to take derivative wrt to (e.g. derivative wrtx
,iv = 1
).
Output
c
– Destination TPSA
GTPSA.mad_ctpsa_derivm!
— Methodmad_ctpsa_derivm!(a::Ptr{CTPSA}, c::Ptr{CTPSA}, n::Cint, m::Vector{Cuchar})
Differentiates TPSA with respect to the monomial defined by byte array m
.
Input
a
– Source TPSA to differentiaten
– Length of monomial to differentiate wrtm
– Monomial to take derivative wrt
Output
c
– Destination TPSA
GTPSA.mad_ctpsa_desc
— Methodmad_ctpsa_desc(t::Ptr{CTPSA})::Ptr{Desc}
Gets the descriptor for the complex TPSA.
Input
t
– Complex TPSA
Output
ret
– Descriptor for the TPSA
GTPSA.mad_ctpsa_dif!
— Methodmad_ctpsa_dif!(a::Ptr{CTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
For each homogeneous polynomial in TPSAs a
and b
, calculates either the relative error or absolute error for each order. If the maximum coefficient for a given order in a
is > 1, the relative error is computed for that order. Else, the absolute error is computed. This is very useful for comparing maps between codes or doing unit tests. In Julia, essentially:
c_i = (a_i.-b_i)/maximum([abs.(a_i)...,1])
where a_i
and b_i
are vectors of the monomials for an order i
Input
a
– Source TPSAa
b
– Source TPSAb
Output
c
– Destination TPSAc
GTPSA.mad_ctpsa_dift!
— Methodmad_ctpsa_dift!(a::Ptr{CTPSA}, b::Ptr{RTPSA}, c::Ptr{CTPSA})
For each homogeneous polynomial in CTPSA a
and RTPSA b
, calculates either the relative error or absolute error for each order. If the maximum coefficient for a given order in a
is > 1, the relative error is computed for that order. Else, the absolute error is computed. This is very useful for comparing maps between codes or doing unit tests. In Julia, essentially:
c_i = (a_i.-b_i)/maximum([abs.(a_i)...,1])
where a_i
and b_i
are vectors of the monomials for an order i
Input
a
– Source CTPSAa
b
– Source RTPSAb
Output
c
– Destination CTPSAc
GTPSA.mad_ctpsa_div!
— Methodmad_ctpsa_div!(a::Ptr{CTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets the destination TPSA c = a / b
Input
a
– Source TPSAa
b
– Source TPSAb
Output
c
– Destination TPSAc = a / b
GTPSA.mad_ctpsa_divt!
— Methodmad_ctpsa_divt!(a::Ptr{CTPSA}, b::Ptr{RTPSA}, c::Ptr{CTPSA})
Sets the destination CTPSA c = a / b
(internal real-to-complex conversion).
Input
a
– Source CTPSAa
b
– Source RTPSAb
Output
c
– Destination CTPSAc = a / b
GTPSA.mad_ctpsa_equ
— Methodmad_ctpsa_equ(a::Ptr{CTPSA}, b::Ptr{CTPSA}, tol_::Cdouble)::Cuchar
Checks if the TPSAs a
and b
are equal within the specified tolerance tol_
. If tol_
is not specified, DBL_GTPSA.show_epsILON
is used.
Input
a
– TPSAa
b
– TPSAb
tol_
– (Optional) Difference below which the TPSAs are considered equal
Output
ret
- True ifa == b
withintol_
GTPSA.mad_ctpsa_equt
— Methodmad_ctpsa_equt(a::Ptr{CTPSA}, b::Ptr{RTPSA}, tol_::Cdouble)::Cuchar
Checks if the CTPSA a
is equal to the RTPSA b
within the specified tolerance tol_
(internal real-to-complex conversion).
Input
a
– CTPSAa
b
– RTPSAb
tol_
– (Optional) Difference below which the TPSAs are considered equal
Output
ret
- True ifa == b
withintol_
GTPSA.mad_ctpsa_erf!
— Methodmad_ctpsa_erf!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the erf
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = erf(a)
GTPSA.mad_ctpsa_erfc!
— Methodmad_ctpsa_erfc!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the erfc
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = erfc(a)
GTPSA.mad_ctpsa_eval!
— Methodmad_ctpsa_eval!(na::Cint, ma::Vector{Ptr{CTPSA}}, nb::Cint, tb::Vector{ComplexF64}, tc::Vector{ComplexF64})
Evaluates the map at the point tb
Input
na
– Number of TPSAs in the mapma
– Mapma
nb
– Length oftb
tb
– Point at which to evaluate the map
Output
tc
– Values for each TPSA in the map evaluated at the pointtb
GTPSA.mad_ctpsa_exp!
— Methodmad_ctpsa_exp!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the exp
of TPSA a
.
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = exp(a)
GTPSA.mad_ctpsa_exppb!
— Methodmad_ctpsa_exppb!(na::Cint, ma::Vector{Ptr{CTPSA}}, mb::Vector{Ptr{CTPSA}}, mc::Vector{Ptr{CTPSA}})
Computes the exponential of fgrad of the vector fields ma
and mb
, literally exppb(ma, mb) = mb + fgrad(ma, mb) + fgrad(ma, fgrad(ma, mb))/2! + ...
Input
na
– Length ofma
andmb
ma
– Vector of TPSAma
mb
– Vector of TPSAmb
Output
mc
– Destination vector of TPSAmc
GTPSA.mad_ctpsa_fgrad!
— Methodmad_ctpsa_fgrad!(na::Cint, ma::Vector{Ptr{CTPSA}}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Calculates dot(ma, grad(b))
Input
na
– Length ofma
consistent with number of variables inb
ma
– Vector of TPSAb
– TPSA
Output
c
–dot(ma, grad(b))
GTPSA.mad_ctpsa_fld2vec!
— Methodmad_ctpsa_fld2vec!(na::Cint, ma::Vector{Ptr{CTPSA}}, c::Ptr{CTPSA})
Assuming the variables in the TPSA are canonically-conjugate, and ordered so that the canonically- conjugate variables are consecutive (q1, p1, q2, p2, ...), calculates the Hamiltonian one obtains from ther vector field (in the form [da/dp1, -da/dq1, ...]
)
Input
na
– Number of TPSA inma
consistent with number of variables inc
ma
– Vector field
Output
c
– Hamiltonian as a TPSA derived from the vector fieldma
GTPSA.mad_ctpsa_get0
— Methodmad_ctpsa_get0(t::Ptr{CTPSA})::ComplexF64
Gets the 0th order (scalar) value of the TPSA
Input
t
– TPSA
Output
ret
– Scalar value of TPSA
GTPSA.mad_ctpsa_get0_r!
— Methodmad_ctpsa_get0_r!(t::Ptr{CTPSA}, r::Ref{ComplexF64})
Gets the 0th order (scalar) value of the TPSA in place.
Input
t
– TPSA
Output
r
– Scalar value of TPSA
GTPSA.mad_ctpsa_geti
— Methodmad_ctpsa_geti(t::Ptr{CTPSA}, i::Cint)::ComplexF64
Gets the coefficient of the monomial at index i
. Generally should use mad_tpsa_cycle
instead of this.
Input
t
– TPSAi
– Monomial index
Output
ret
– Coefficient of monomial at indexi
GTPSA.mad_ctpsa_geti_r!
— Methodmad_ctpsa_geti_r!(t::Ptr{CTPSA}, i::Cint, r::Ref{ComplexF64})
Gets the coefficient of the monomial at index i
in place. Generally should use mad_tpsa_cycle
instead of this.
Input
t
– TPSAi
– Monomial index
Output
r
– Coefficient of monomial at indexi
GTPSA.mad_ctpsa_getm
— Methodmad_ctpsa_getm(t::Ptr{CTPSA}, n::Cint, m::Vector{Cuchar})::ComplexF64
Gets the coefficient of the monomial m
defined as a byte array. Generally should use mad_tpsa_cycle
instead of this.
Input
t
– TPSAn
– Length of monomialm
– Monomial as byte array
Output
ret
– Coefficient of monomialm
in TPSA
GTPSA.mad_ctpsa_getm_r!
— Methodmad_ctpsa_getm_r!(t::Ptr{CTPSA}, n::Cint, m::Vector{Cuchar}, r::Ref{ComplexF64})
Gets the coefficient of the monomial m
defined as a byte array in place. Generally should use mad_tpsa_cycle
instead of this.
Input
t
– TPSAn
– Length of monomialm
– Monomial as byte array
Output
r
– Coefficient of monomialm
in TPSA
GTPSA.mad_ctpsa_getord!
— Methodmad_ctpsa_getord!(t::Ptr{CTPSA}, r::Ptr{CTPSA}, ord::Cuchar)
Extract one homogeneous polynomial of the given order
Input
t
– Sourcecomplex TPSAord
– Order to retrieve
Output
r
– Destination complex TPSA
GTPSA.mad_ctpsa_gets
— Methodmad_ctpsa_gets(t::Ptr{CTPSA}, n::Cint, s::Cstring)::ComplexF64
Gets the coefficient of the monomial s
defined as a string. Generally should use mad_tpsa_cycle
instead of this.
Input
t
– TPSAn
– Size of monomials
– Monomial as string
Output
ret
– Coefficient of monomials
in TPSA
GTPSA.mad_ctpsa_gets_r!
— Methodmad_ctpsa_gets_r!(t::Ptr{CTPSA}, n::Cint, s::Cstring, r::Ref{ComplexF64})
Gets the coefficient of the monomial s
defined as a string in place. Generally should use mad_tpsa_cycle
instead of this.
Input
t
– TPSAn
– Length of monomials
– Monomial as string
Output
r
– Coefficient of monomials
in TPSA
GTPSA.mad_ctpsa_getsm
— Methodmad_ctpsa_getsm(t::Ptr{CTPSA}, n::Cint, m::Vector{Cint})::ComplexF64
Gets the coefficient of the monomial m
defined as a sparse monomial. Generally should use mad_tpsa_cycle
instead of this.
Input
t
– TPSAn
– Length of monomialm
– Monomial as sparse monomial
Output
ret
– Coefficient of monomialm
in TPSA
GTPSA.mad_ctpsa_getsm_r!
— Methodmad_ctpsa_getsm_r!(t::Ptr{CTPSA}, n::Cint, m::Vector{Cint}, r::Ref{ComplexF64})
Gets the coefficient of the monomial m
defined as a sparse monomial in place. Generally should use mad_tpsa_cycle
instead of this.
Input
t
– TPSAn
– Length of monomialm
– Monomial as sparse monomial
Output
r
– Coefficient of monomialm
in TPSA
GTPSA.mad_ctpsa_getv!
— Methodmad_ctpsa_getv!(t::Ptr{CTPSA}, i::Cint, n::Cint, v::Vector{ComplexF64})
Vectorized getter of the coefficients for monomials with indices i..i+n
. Useful for extracting the 1st order parts of a TPSA to construct a matrix (i = 1
, n = nv+np = nn
).
Input
t
– TPSAi
– Starting index of monomials to get coefficientsn
– Number of monomials to get coefficients of starting ati
Output
v
– Array of coefficients for monomialsi..i+n
GTPSA.mad_ctpsa_hypot!
— Methodmad_ctpsa_hypot!(x::Ptr{CTPSA}, y::Ptr{CTPSA}, r::Ptr{CTPSA})
Sets TPSA r
to sqrt(real(x)^2+real(y)^2) + im*sqrt(imag(x)^2+imag(y)^2)
Input
x
– Source TPSAx
y
– Source TPSAy
Output
r
– Destination TPSAsqrt(real(x)^2+real(y)^2) + im*sqrt(imag(x)^2+imag(y)^2)
GTPSA.mad_ctpsa_hypot3!
— Methodmad_ctpsa_hypot3!(x::Ptr{CTPSA}, y::Ptr{CTPSA}, z::Ptr{CTPSA}, r::Ptr{CTPSA})
Sets TPSA r
to sqrt(x^2+y^2+z^2)
. Does NOT allow for r = x, y, z !!!
Input
x
– Source TPSAx
y
– Source TPSAy
z
– Source TPSAz
Output
r
– Destination TPSAr = sqrt(x^2+y^2+z^2)
GTPSA.mad_ctpsa_idxm
— Methodmad_ctpsa_idxm(t::Ptr{CTPSA}, n::Cint, m::Vector{Cuchar})::Cint
Returns index of monomial in the TPSA given the monomial as a byte array. This generally should not be used, as there are no assumptions about which monomial is attached to which index.
Input
t
– TPSAn
– Length of monomials
– Monomial as byte array
Output
ret
– Index of monomial in TPSA
GTPSA.mad_ctpsa_idxs
— Methodmad_ctpsa_idxs(t::Ptr{CTPSA}, n::Cint, s::Cstring)::Cint
Returns index of monomial in the TPSA given the monomial as string. This generally should not be used, as there are no assumptions about which monomial is attached to which index.
Input
t
– TPSAn
– Length of monomials
– Monomial as string
Output
ret
– Index of monomial in TPSA
GTPSA.mad_ctpsa_idxsm
— Methodmad_ctpsa_idxsm(t::Ptr{CTPSA}, n::Cint, m::Vector{Cint})::Cint
Returns index of monomial in the TPSA given the monomial as a sparse monomial. This generally should not be used, as there are no assumptions about which monomial is attached to which index.
Input
t
– TPSAn
– Length of monomials
– Monomial as sparse monomial
Output
ret
– Index of monomial in TPSA
GTPSA.mad_ctpsa_imag!
— Methodmad_ctpsa_imag!(t::Ptr{CTPSA}, r::Ptr{RTPSA})
Sets the RTPSA r
equal to the imaginary part of CTPSA t
.
Input
t
– Source CTPSA
Output
r
– Destination RTPSA withr = Im(t)
GTPSA.mad_ctpsa_init!
— Methodmad_ctpsa_init(t::Ptr{CTPSA}, d::Ptr{Desc}, mo::Cuchar)::Ptr{CTPSA}
Unsafe initialization of an already existing TPSA t
with maximum order mo
to the descriptor d
. mo
must be less than the maximum order of the descriptor. t
is modified in place and also returned.
Input
t
– TPSA to initialize to descriptord
d
– Descriptormo
– Maximum order of the TPSA (must be less than maximum order of the descriptor)
Output
t
– TPSA initialized to descriptord
with maximum ordermo
GTPSA.mad_ctpsa_integ!
— Methodmad_ctpsa_integ!(a::Ptr{CTPSA}, c::Ptr{CTPSA}, iv::Cint)
Integrates TPSA with respect to the variable with index iv
.
Input
a
– Source TPSA to integrateiv
– Index of variable to integrate over (e.g. integrate overx
,iv = 1
).
Output
c
– Destination TPSA
GTPSA.mad_ctpsa_inv!
— Methodmad_ctpsa_inv!(a::Ptr{CTPSA}, v::ComplexF64, c::Ptr{CTPSA})
Sets TPSA c
to v/a
.
Input
a
– Source TPSAa
v
– Scalar with double precision
Output
c
– Destination TPSAc = v/a
GTPSA.mad_ctpsa_inv_r!
— Methodmad_ctpsa_inv_r!(a::Ptr{CTPSA}, v_re::Cdouble, v_im::Cdouble, c::Ptr{CTPSA})
Sets TPSA c
to v/a
. Without complex-by-value arguments.
Input
a
– Source TPSAa
v_re
– Real part of scalar with double precisionv_im
– Imaginary part of scalar with double precision
Output
c
– Destination TPSAc = v*a
GTPSA.mad_ctpsa_invsqrt!
— Methodmad_ctpsa_invsqrt!(a::Ptr{CTPSA}, v::ComplexF64, c::Ptr{CTPSA})
Sets TPSA c
to v/sqrt(a)
.
Input
a
– Source TPSAa
v
– Scalar with double precision
Output
c
– Destination TPSAc = v/sqrt(a)
GTPSA.mad_ctpsa_invsqrt_r!
— Methodmad_ctpsa_invsqrt_r!(a::Ptr{CTPSA}, v_re::Cdouble, v_im::Cdouble, c::Ptr{CTPSA})
Sets TPSA c
to v/sqrt(a)
. Without complex-by-value arguments.
Input
a
– Source TPSAa
v_re
– Real part of scalar with double precisionv_im
– Imaginary part of scalar with double precision
Output
c
– Destination TPSAc = v*a
GTPSA.mad_ctpsa_isnul
— Methodmad_ctpsa_isnul(t::Ptr{CTPSA})::Cuchar
Checks if TPSA is 0 or not
Input
t
– Complex TPSA to check
Output
ret
– True or false
GTPSA.mad_ctpsa_isvalid
— Methodmad_ctpsa_isvalid(t::Ptr{CTPSA})::Cuchar
Sanity check of the TPSA integrity.
Input
t
– Complex TPSA to check if valid
Output
ret
– True if valid TPSA, false otherwise
GTPSA.mad_ctpsa_len
— Methodmad_ctpsa_len(t::Ptr{CTPSA})::Cint
Gets the length of the TPSA itself (e.g. the descriptor may be order 10 but TPSA may only be order 2)
Input
t
– Complex TPSA
Output
ret
– Length of CTPSA
GTPSA.mad_ctpsa_liebra!
— Methodmad_ctpsa_liebra!(na::Cint, ma::Vector{Ptr{CTPSA}}, mb::Vector{Ptr{CTPSA}}, mc::Vector{Ptr{CTPSA}})
Computes the Lie bracket of the vector fields ma
and mb
, defined as sumi mai (dmb/dxi) - mbi (dma/dx_i).
Input
na
– Length ofma
andmb
ma
– Vector of TPSAma
mb
– Vector of TPSAmb
Output
mc
– Destination vector of TPSAmc
GTPSA.mad_ctpsa_log!
— Methodmad_ctpsa_log!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the log
of TPSA a
.
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = log(a)
GTPSA.mad_ctpsa_logaxpsqrtbpcx2!
— Methodmad_ctpsa_logaxpsqrtbpcx2!(x::Ptr{CTPSA}, a::ComplexF64, b::ComplexF64, c::ComplexF64, r::Ptr{CTPSA})
r = log(a*x + sqrt(b + c*x^2))
Input
x
– TPSAx
a
– Scalara
b
– Scalarb
c
– Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_logaxpsqrtbpcx2_r!
— Methodmad_ctpsa_logaxpsqrtbpcx2_r!(x::Ptr{CTPSA}, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble, c_re::Cdouble, c_im::Cdouble, r::Ptr{CTPSA})
r = log(a*x + sqrt(b + c*x^2))
. Same as mad_ctpsa_logaxpsqrtbpcx2
without complex-by-value arguments.
Input
a_re
– Real part of Scalara
a_im
– Imag part of Scalara
b_re
– Real part of Scalarb
b_im
– Imag part of Scalarb
c_re
– Real part of Scalarc
c_im
– Imag part of Scalarc
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_logpb!
— Methodmad_ctpsa_logpb!(na::Cint, ma::Vector{Ptr{CTPSA}}, mb::Vector{Ptr{CTPSA}}, mc::Vector{Ptr{CTPSA}})
Computes the log of the Poisson bracket of the vector of TPSA ma
and mb
; the result is the vector field F
used to evolve to ma
from mb
.
Input
na
– Length ofma
andmb
ma
– Vector of TPSAma
mb
– Vector of TPSAmb
Output
mc
– Destination vector of TPSAmc
GTPSA.mad_ctpsa_logxdy!
— Methodmad_ctpsa_logxdy!(x::Ptr{CTPSA}, y::Ptr{CTPSA}, r::Ptr{CTPSA})
r = log(x / y)
Input
x
– TPSAx
y
– TPSAy
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_maxord
— Methodmad_ctpsa_maxord(t::Ptr{CTPSA}, n::Cint, idx_::Vector{Cint})::Cint
Returns the index to the monomial with maximum abs(coefficient) in the TPSA for all orders 0 to n
. If idx_
is provided, it is filled with the indices for the maximum abs(coefficient) monomial for each order up to n
.
Input
t
– Complex TPSAn
– Highest order to include in finding the maximum abs(coefficient) in the TPSA, length ofidx_
if provided
Output
idx_
– (Optional) If provided, is filled with indices to the monomial for each order up ton
with maximum abs(coefficient)mi
– Index to the monomial in the TPSA with maximum abs(coefficient)
GTPSA.mad_ctpsa_mconv!
— Methodmad_ctpsa_mconv!(na::Cint, ma::Vector{Ptr{CTPSA}}, nc::Cint, mc::Vector{Ptr{CTPSA}}, n::Cint, t2r_::Vector{Cint}, pb::Cint)
Equivalent to mad_tpsa_convert
, but applies the conversion to all TPSAs in the map ma
.
Input
na
– Number of TPSAs in the mapma
– Mapma
nc
– Number of TPSAs in the output mapmc
n
– Length of vector (size oft2r_
)t2r_
– (Optional) Vector of index lookuppb
– Poisson bracket, 0, 1:fwd, -1:bwd
Output
mc
– Mapmc
with specified conversions
GTPSA.mad_ctpsa_minv!
— Methodmad_ctpsa_minv!(na::Cint, ma::Vector{Ptr{CTPSA}}, mc::Vector{Ptr{CTPSA}})
Inverts the map.
Input
na
– Number of TPSAs in the mapma
– Mapma
Output
mc
– Inversion of Mapma
GTPSA.mad_ctpsa_mnrm
— Methodmad_ctpsa_mnrm(na::Cint, ma::Vector{Ptr{CTPSA}})::Cdouble
Computes the norm of the map (sum of absolute value of coefficients of all TPSAs in the map).
Input
na
– Number of TPSAs in the mapma
– Mapma
Output
nrm
– Norm of map (sum of absolute value of coefficients of all TPSAs in the map)
GTPSA.mad_ctpsa_mono!
— Methodmad_ctpsa_mono!(t::Ptr{CTPSA}, i::Cint, n::Cint, m_::Vector{Cuchar}, p_::Vector{Cuchar})::Cuchar
Returns the order of the monomial at index i
in the TPSA and optionally the monomial at that index is returned in m_
and the order of parameters in the monomial in p_
Input
t
– TPSAi
– Index valid in TPSAn
– Length of monomial
Output
m_
– (Optional) Monomial at indexi
in TPSAp_
– (Optional) Order of parameters in monomialret
– Order of monomial in TPSAa
indexi
GTPSA.mad_ctpsa_mul!
— Methodmad_ctpsa_mul!(a::Ptr{CTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets the destination TPSA c = a * b
Input
a
– Source TPSAa
b
– Source TPSAb
Output
c
– Destination TPSAc = a * b
GTPSA.mad_ctpsa_mult!
— Methodmad_ctpsa_mult!(a::Ptr{CTPSA}, b::Ptr{RTPSA}, c::Ptr{CTPSA})
Sets the destination CTPSA c = a * b
(internal real-to-complex conversion).
Input
a
– Source CTPSAa
b
– Source RTPSAb
Output
c
– Destination CTPSAc = a * b
GTPSA.mad_ctpsa_nam
— Methodmad_ctpsa_nam(t::Ptr{CTPSA})::Cstring
Get the name of the TPSA.
Input
t
– Complex TPSA
Output
ret
– Name of CTPSA (Null terminated in C)
GTPSA.mad_ctpsa_new
— Methodmad_ctpsa_new(t::Ptr{CTPSA}, mo::Cuchar)::Ptr{CTPSA}
Creates a blank TPSA with same number of variables/parameters of the inputted TPSA, with maximum order specified by mo
. If MAD_TPSA_SAME
is passed for mo
, the mo
currently in t
is used for the created TPSA. Ok with t=(tpsa_t*)ctpsa
Input
t
– TPSAmo
– Maximum order of new TPSA
Output
ret
– New blank TPSA with maximum ordermo
GTPSA.mad_ctpsa_newd
— Methodmad_ctpsa_newd(d::Ptr{Desc}, mo::Cuchar)::Ptr{CTPSA}
Creates a complex TPSA defined by the specified descriptor and maximum order. If MADCTPSADEFAULT is passed for mo
, the mo
defined in the descriptor is used. If mo > d_mo
, then mo = d_mo
.
Input
d
– Descriptormo
– Maximum order
Output
t
– New complex TPSA defined by the descriptor
GTPSA.mad_ctpsa_nrm
— Methodmad_ctpsa_nrm(a::Ptr{CTPSA})::Cdouble
Calculates the 1-norm of TPSA a
(sum of abs
of all coefficients)
Input
a
– TPSA
Output
nrm
– 1-Norm of TPSAa
GTPSA.mad_ctpsa_ord
— Methodmad_ctpsa_ord(t::Ptr{CTPSA})::Cuchar
Gets the TPSA order.
Input
t
– Complex TPSA
Output
ret
– Order of TPSA
GTPSA.mad_ctpsa_ordn
— Methodmad_ctpsa_ordn(n::Cint, t::Vector{Ptr{CTPSA}})::Cuchar
Returns the max order of all TPSAs in t
.
Input
n
– Number of TPSAst
– Array of TPSAs
Output
mo
– Maximum order of all TPSAs
GTPSA.mad_ctpsa_ordv
— Methodmad_ctpsa_ordv(t::Ptr{CTPSA}, ts::Ptr{CTPSA}...)::Cuchar
Returns maximum order of all TPSAs provided.
Input
t
– TPSAts
– Variable number of TPSAs passed as parameters
Output
mo
– Maximum order of all TPSAs provided
GTPSA.mad_ctpsa_pminv!
— Methodmad_ctpsa_pminv!(na::Cint, ma::Vector{Ptr{CTPSA}}, mc::Vector{Ptr{CTPSA}}, select::Vector{Cint})
Computes the partial inverse of the map with only the selected variables, specified by 0s or 1s in select.
Input
na
– Number of TPSAs inma
ma
– Mapma
select
– Array of 0s or 1s defining which variables to do inverse on (atleast same size as na)
Output
mc
– Partially inverted map using variables specified as 1 in the select array
GTPSA.mad_ctpsa_poisbra!
— Methodmad_ctpsa_poisbra!(a::Ptr{CTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA}, nv::Cint)
Sets TPSA c
to the poisson bracket of TPSAs a
and b
.
Input
a
– Source TPSAa
b
– Source TPSAb
nv
– Number of variables in the TPSA
Output
c
– Destination TPSAc
GTPSA.mad_ctpsa_poisbrat!
— Methodmad_ctpsa_poisbrat!(a::Ptr{CTPSA}, b::Ptr{RTPSA}, c::Ptr{CTPSA}, nv::Cint)
Sets TPSA c
to the poisson bracket of CTPSA a
and RTPSA b
(internal real-to-complex conversion).
Input
a
– Source CTPSAa
b
– Source RTPSAb
nv
– Number of variables in the TPSA
Output
c
– Destination CTPSAc
GTPSA.mad_ctpsa_polar!
— Methodmad_ctpsa_polar!(t::Ptr{CTPSA}, r::Ptr{CTPSA})
Sets r = |t| + im*atan2(Im(t), Re(t))
Input
t
– Source CTPSAr
– Destination CTPSA
GTPSA.mad_ctpsa_pow!
— Methodmad_ctpsa_pow!(a::Ptr{CTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets the destination TPSA c = a ^ b
Input
a
– Source TPSAa
b
– Source TPSAb
Output
c
– Destination TPSAc = a ^ b
GTPSA.mad_ctpsa_powi!
— Methodmad_ctpsa_powi!(a::Ptr{CTPSA}, n::Cint, c::Ptr{CTPSA})
Sets the destination TPSA c = a ^ n
where n
is an integer.
Input
a
– Source TPSAa
n
– Integer power
Output
c
– Destination TPSAc = a ^ n
GTPSA.mad_ctpsa_pown!
— Methodmad_ctpsa_pown!(a::Ptr{CTPSA}, v::ComplexF64, c::Ptr{CTPSA})
Sets the destination TPSA c = a ^ v
where v
is of double precision.
Input
a
– Source TPSAa
v
– Power, ComplexF64
Output
c
– Destination TPSAc = a ^ v
GTPSA.mad_ctpsa_pown_r!
— Methodmad_ctpsa_pown_r!(a::Ptr{CTPSA}, v_re::Cdouble, v_im::Cdouble, c::Ptr{CTPSA})
Sets the destination TPSA c = a ^ v
where v
is of double precision. Without complex-by-value arguments.
Input
a
– Source TPSAa
v_re
– Real part of powerv_im
– Imaginary part of power
Output
c
– Destination TPSAc = a ^ v
GTPSA.mad_ctpsa_powt!
— Methodmad_ctpsa_powt!(a::Ptr{CTPSA}, b::Ptr{RTPSA}, c::Ptr{CTPSA})
Sets the destination CTPSA c = a ^ b
(internal real-to-complex conversion).
Input
a
– Source CTPSAa
b
– Source RTPSAb
Output
c
– Destination CTPSAc = a ^ b
GTPSA.mad_ctpsa_print
— Methodmad_ctpsa_print(t::Ptr{CTPSA}, name_::Cstring, eps_::Cdouble, nohdr_::Cint, stream_::Ptr{Cvoid})
Prints the TPSA coefficients with precision eps_
. If nohdr_
is not zero, the header is not printed.
Input
t
– TPSA to printname_
– (Optional) Name of TPSAeps_
– (Optional) Precision to outputnohdr_
– (Optional) If True, no header is printedstream_
– (Optional)FILE
pointer of output stream. Default isstdout
GTPSA.mad_ctpsa_real!
— Methodmad_ctpsa_real!(t::Ptr{CTPSA}, r::Ptr{RTPSA})
Sets the RTPSA r
equal to the real part of CTPSA t
.
Input
t
– Source CTPSA
Output
r
– Destination RTPSA withr = Re(t)
GTPSA.mad_ctpsa_rect!
— Methodmad_ctpsa_rect!(t::Ptr{CTPSA}, r::Ptr{CTPSA})
Sets r = Re(t)*cos(Im(t)) + im*Re(t)*sin(Im(t))
Input
t
– Source CTPSAr
– Destination CTPSA
GTPSA.mad_ctpsa_scan
— Methodmad_ctpsa_scan(stream_::Ptr{Cvoid})::Ptr{CTPSA}
Scans in a TPSA from the stream_
.
Input
stream_
– (Optional) I/O stream from which to read the TPSA, default isstdin
Output
t
– TPSA scanned from I/Ostream_
GTPSA.mad_ctpsa_scan_coef!
— Methodmad_ctpsa_scan_coef!(t::Ptr{CTPSA}, stream_::Ptr{Cvoid})
Read TPSA coefficients into TPSA t
. This should be used with mad_tpsa_scan_hdr
for external languages using this library where the memory is managed NOT on the C side.
Input
stream_
– (Optional) I/O stream to read TPSA from, default isstdin
Output
t
– TPSA with coefficients scanned fromstream_
GTPSA.mad_ctpsa_scan_hdr
— Methodmad_ctpsa_scan_hdr(kind_::Ref{Cint}, name_::Ptr{Cuchar}, stream_::Ptr{Cvoid})::Ptr{Desc}
Read TPSA header. Returns descriptor for TPSA given the header. This is useful for external languages using this library where the memory is managed NOT on the C side.
Input
kind_
– (Optional) Real or complex TPSA, or detect automatically if not provided.name_
– (Optional) Name of TPSAstream_
– (Optional) I/O stream to read TPSA from, default isstdin
Output
ret
– Descriptor for the TPSA
GTPSA.mad_ctpsa_scl!
— Methodmad_ctpsa_scl!(a::Ptr{CTPSA}, v::ComplexF64, c::Ptr{CTPSA})
Sets TPSA c
to v*a
.
Input
a
– Source TPSAa
v
– Scalar with double precision
Output
c
– Destination TPSAc = v*a
GTPSA.mad_ctpsa_scl_r!
— Methodmad_ctpsa_scl_r!(a::Ptr{CTPSA}, v_re::Cdouble, v_im::Cdouble,, c::Ptr{CTPSA})
Sets TPSA c
to v*a
. Without complex-by-value arguments.
Input
a
– Source TPSAa
v_re
– Real part of scalar with double precisionv_im
– Imaginary part of scalar with double precision
Output
c
– Destination TPSAc = v*a
GTPSA.mad_ctpsa_sclord!
— Methodmad_ctpsa_sclord!(t::Ptr{CTPSA}, r::Ptr{CTPSA}, inv::Cuchar, prm::Cuchar)
Scales all coefficients by order. If inv == 0
, scales coefficients by order (derivation), else scales coefficients by 1/order (integration).
Input
t
– Source complex TPSAinv
– Put order up, divide, scale byinv
of value of orderprm
– Parameters flag. If set to 0x0, the scaling excludes the order of the parameters in the monomials. Else, scaling is with total order of monomial
Output
r
– Destination complex TPSA
GTPSA.mad_ctpsa_set0!
— Methodmad_ctpsa_set0!(t::Ptr{CTPSA}, a::ComplexF64, b::ComplexF64)
Sets the 0th order coefficient (scalar part of TPSA) according to coef[0] = a*coef[0] + b
. Does not modify other values in TPSA.
Input
t
– TPSAa
– Scaling of current 0th order valueb
– Constant added to current 0th order value
GTPSA.mad_ctpsa_set0_r!
— Methodmad_ctpsa_set0_r!(t::Ptr{CTPSA}, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble)
Sets the 0th order coefficient (scalar part of TPSA) according to coef[0] = a*coef[0] + b
. Does not modify other values in TPSA. Equivalent to mad_ctpsa_set0
but without complex-by-value arguments.
Input
t
– TPSAa_re
– Real part ofa
a_im
– Imaginary part ofa
b_re
– Real part ofb
b_im
– Imaginary part ofb
GTPSA.mad_ctpsa_seti!
— Methodmad_ctpsa_seti!(t::Ptr{CTPSA}, i::Cint, a::ComplexF64, b::ComplexF64)
Sets the coefficient of monomial at index i
to coef[i] = a*coef[i] + b
. Does not modify other values in TPSA.
Input
t
– TPSAi
– Index of monomiala
– Scaling of current coefficientb
– Constant added to current coefficient
GTPSA.mad_ctpsa_seti_r!
— Methodmad_ctpsa_seti_r!(t::Ptr{CTPSA}, i::Cint, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble)
Sets the coefficient of monomial at index i
to coef[i] = a*coef[i] + b
. Does not modify other values in TPSA. Equivalent to mad_ctpsa_seti
but without complex-by-value arguments.
Input
t
– TPSAi
– Index of monomiala_re
– Real part ofa
a_im
– Imaginary part ofa
b_re
– Real part ofb
b_im
– Imaginary part ofb
GTPSA.mad_ctpsa_setm!
— Methodmad_ctpsa_setm!(t::Ptr{CTPSA}, n::Cint, m::Vector{Cuchar}, a::ComplexF64, b::ComplexF64)
Sets the coefficient of monomial defined by byte array m
to coef = a*coef + b
. Does not modify other values in TPSA.
Input
t
– TPSAn
– Length of monomialm
– Monomial as byte arraya
– Scaling of current coefficientb
– Constant added to current coefficient
GTPSA.mad_ctpsa_setm_r!
— Methodmad_ctpsa_setm_r!(t::Ptr{CTPSA}, n::Cint, m::Vector{Cuchar}, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble)
Sets the coefficient of monomial defined by byte array m
to coef = a*coef + b
. Does not modify other values in TPSA. Equivalent to mad_ctpsa_setm
but without complex-by-value arguments.
Input
t
– TPSAn
– Length of monomialm
– Monomial as byte arraya_re
– Real part ofa
a_im
– Imaginary part ofa
b_re
– Real part ofb
b_im
– Imaginary part ofb
GTPSA.mad_ctpsa_setnam!
— Methodmad_ctpsa_setnam!(t::Ptr{CTPSA}, nam::Cstring)
Sets the name of the CTPSA.
Input
t
– Complex TPSAnam
– Name to set for CTPSA
GTPSA.mad_ctpsa_sets!
— Methodmad_ctpsa_sets!(t::Ptr{CTPSA}, n::Cint, s::Cstring, a::ComplexF64, b::ComplexF64)
Sets the coefficient of monomial defined by string s
to coef = a*coef + b
. Does not modify other values in TPSA.
Input
t
– TPSAn
– Length of monomials
– Monomial as stringa
– Scaling of current coefficientb
– Constant added to current coefficient
GTPSA.mad_ctpsa_sets_r!
— Methodmad_ctpsa_sets_r!(t::Ptr{CTPSA}, n::Cint, s::Cstring, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble)
Sets the coefficient of monomial defined by string s
to coef = a*coef + b
. Does not modify other values in TPSA. Equivalent to mad_ctpsa_set
but without complex-by-value arguments.
Input
t
– TPSAn
– Length of monomials
– Monomial as stringa_re
– Real part ofa
a_im
– Imaginary part ofa
b_re
– Real part ofb
b_im
– Imaginary part ofb
GTPSA.mad_ctpsa_setsm!
— Methodmad_ctpsa_setsm!(t::Ptr{CTPSA}, n::Cint, m::Vector{Cint}, a::ComplexF64, b::ComplexF64)
Sets the coefficient of monomial defined by sparse monomial m
to coef = a*coef + b
. Does not modify other values in TPSA.
Input
t
– TPSAn
– Length of monomialm
– Monomial as sparse monomiala
– Scaling of current coefficientb
– Constant added to current coefficient
GTPSA.mad_ctpsa_setsm_r!
— Methodmad_ctpsa_setsm_r!(t::Ptr{CTPSA}, n::Cint, m::Vector{Cint}, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble)
Sets the coefficient of monomial defined by sparse monomial m to coef = a*coef + b
. Does not modify other values in TPSA. Equivalent to mad_ctpsa_setsm
but without complex-by-value arguments.
Input
t
– TPSAn
– Length of monomialm
– Monomial as sparse monomiala_re
– Real part ofa
a_im
– Imaginary part ofa
b_re
– Real part ofb
b_im
– Imaginary part ofb
GTPSA.mad_ctpsa_setv!
— Methodmad_ctpsa_setv!(t::Ptr{CTPSA}, i::Cint, n::Cint, v::Vector{ComplexF64})
Vectorized setter of the coefficients for monomials with indices i..i+n
. Useful for putting a matrix into a map.
Input
t
– TPSAi
– Starting index of monomials to set coefficientsn
– Number of monomials to set coefficients of starting ati
v
– Array of coefficients for monomialsi..i+n
GTPSA.mad_ctpsa_setval!
— Methodmad_ctpsa_setval!(t::Ptr{CTPSA}, v::ComplexF64)
Sets the scalar part of the TPSA to v
and all other values to 0 (sets the TPSA order to 0).
Input
t
– TPSA to set to scalarv
– Scalar value to set TPSA
GTPSA.mad_ctpsa_setval_r!
— Methodmad_ctpsa_setval_r!(t::Ptr{CTPSA}, v_re::Cdouble, v_im::Cdouble)
Sets the scalar part of the TPSA to v
and all other values to 0 (sets the TPSA order to 0). Equivalent to mad_ctpsa_setval
but without complex-by-value arguments.
Input
t
– TPSA to set to scalarv_re
– Real part of scalar value to set TPSAv_im
– Imaginary part of scalar value to set TPSA
GTPSA.mad_ctpsa_setvar!
— Methodmad_ctpsa_setvar!(t::Ptr{CTPSA}, v::ComplexF64, iv_::Cint, scl_::ComplexF64)
Sets the 0th and 1st order values for the variables.
Input
t
– Real TPSAv
– 0th order value (coefficient)iv_
– (Optional) Variable index, optional if order of TPSA is 0 (behaves likemad_ctpsa_setval
then)scl_
– 1st order variable value (typically will be 1)
GTPSA.mad_ctpsa_setvar_r!
— Methodmad_ctpsa_setvar_r!(t::Ptr{CTPSA}, v_re::Cdouble, v_im::Cdouble, iv_::Cint, scl_re_::Cdouble, scl_im_::Cdouble)
Sets the 0th and 1st order values for the variables. Equivalent to mad_ctpsa_setvar
but without complex-by-value arguments.
Input
t
– Complex TPSAv_re
– Real part of 0th order valuev_im
– Imaginary part of 0th order valueiv_
– (Optional) Variable index, optional if order of TPSA is 0 (behaveslike mad_ctpsa_setval
then)scl_re_
– (Optional) Real part of 1st order variable valuescl_im_
– (Optional)Imaginary part of 1st order variable value
GTPSA.mad_ctpsa_sin!
— Methodmad_ctpsa_sin!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the sin
of TPSA a
.
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = sin(a)
GTPSA.mad_ctpsa_sinc!
— Methodmad_ctpsa_sinc!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the sinc
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = sinc(a)
GTPSA.mad_ctpsa_sincos!
— Methodmad_ctpsa_sincos!(a::Ptr{CTPSA}, s::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA s = sin(a)
and TPSA c = cos(a)
Input
a
– Source TPSAa
Output
s
– Destination TPSAs = sin(a)
c
– Destination TPSAc = cos(a)
GTPSA.mad_ctpsa_sincosh!
— Methodmad_ctpsa_sincosh!(a::Ptr{CTPSA}, s::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA s = sinh(a)
and TPSA c = cosh(a)
Input
a
– Source TPSAa
Output
s
– Destination TPSAs = sinh(a)
c
– Destination TPSAc = cosh(a)
GTPSA.mad_ctpsa_sinh!
— Methodmad_ctpsa_sinh!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the sinh
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = sinh(a)
GTPSA.mad_ctpsa_sinhc!
— Methodmad_ctpsa_sinhc!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the sinhc
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = sinhc(a)
GTPSA.mad_ctpsa_sqrt!
— Methodmad_ctpsa_sqrt!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the sqrt
of TPSA a
.
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = sqrt(a)
GTPSA.mad_ctpsa_sub!
— Methodmad_ctpsa_sub!(a::Ptr{CTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets the destination TPSA c = a - b
Input
a
– Source TPSAa
b
– Source TPSAb
Output
c
– Destination TPSAc = a - b
GTPSA.mad_ctpsa_subt!
— Methodmad_ctpsa_subt!(a::Ptr{CTPSA}, b::Ptr{RTPSA}, c::Ptr{CTPSA})
Sets the destination CTPSA c = a - b
(internal real-to-complex conversion).
Input
a
– Source CTPSAa
b
– Source RTPSAb
Output
c
– Destination CTPSAc = a - b
GTPSA.mad_ctpsa_tan!
— Methodmad_ctpsa_tan!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the tan
of TPSA a
.
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = tan(a)
GTPSA.mad_ctpsa_tanh!
— Methodmad_ctpsa_tanh!(a::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets TPSA c
to the tanh
of TPSA a
Input
a
– Source TPSAa
Output
c
– Destination TPSAc = tanh(a)
GTPSA.mad_ctpsa_taylor!
— Methodmad_ctpsa_taylor!(a::Ptr{CTPSA}, n::Cint, coef::Vector{ComplexF64}, c::Ptr{CTPSA})
Computes the result of the Taylor series up to order n-1
with Taylor coefficients coef
for the scalar value in a
. That is, c = coef[0] + coef[1]*a_0 + coef[2]*a_0^2 + ...
where a_0
is the scalar part of TPSA a
Input
a
– TPSAa
n
–Order-1
of Taylor expansion, size ofcoef
arraycoef
– Array of coefficients in Taylors
c
– Result
GTPSA.mad_ctpsa_tdif!
— Methodmad_ctpsa_tdif!(a::Ptr{RTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
For each homogeneous polynomial in RTPSA a
and CTPSA b
, calculates either the relative error or absolute error for each order. If the maximum coefficient for a given order in a
is > 1, the relative error is computed for that order. Else, the absolute error is computed. This is very useful for comparing maps between codes or doing unit tests. In Julia, essentially:
c_i = (a_i.-b_i)/maximum([abs.(a_i)...,1])
where a_i
and b_i
are vectors of the monomials for an order i
Input
a
– Source RTPSAa
b
– Source CTPSAb
Output
c
– Destination CTPSAc
GTPSA.mad_ctpsa_tdiv!
— Methodmad_ctpsa_tdiv!(a::Ptr{RTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets the destination CTPSA c = a / b
(internal real-to-complex conversion).
Input
a
– Source RTPSAa
b
– Source CTPSAb
Output
c
– Destination CTPSAc = a / b
GTPSA.mad_ctpsa_tpoisbra!
— Methodmad_ctpsa_tpoisbra!(a::Ptr{RTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA}, nv::Cint)
Sets TPSA c
to the poisson bracket of RTPSA a
and CTPSA b
(internal real-to-complex conversion).
Input
a
– Source RTPSAa
b
– Source CTPSAb
nv
– Number of variables in the TPSA
Output
c
– Destination CTPSAc
GTPSA.mad_ctpsa_tpow!
— Methodmad_ctpsa_tpow!(a::Ptr{RTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets the destination CTPSA c = a ^ b
(internal real-to-complex conversion).
Input
a
– Source RTPSAa
b
– Source CTPSAb
Output
c
– Destination TPSAc = a ^ b
GTPSA.mad_ctpsa_translate!
— Methodmad_ctpsa_translate!(na::Cint, ma::Vector{Ptr{CTPSA}}, nb::Cint, tb::Vector{ComplexF64}, mc::Vector{Ptr{CTPSA}})
Translates the expansion point of the map by the amount tb
.
Input
na
– Number of TPSAS in the mapma
– Mapma
nb
– Length oftb
tb
– Vector of amount to translate for each variable
Output
mc
– Map evaluated at the new point translatedtb
from the original evaluation point
GTPSA.mad_ctpsa_tsub!
— Methodmad_ctpsa_tsub!(a::Ptr{RTPSA}, b::Ptr{CTPSA}, c::Ptr{CTPSA})
Sets the destination CTPSA c = a - b
(internal real-to-complex conversion).
Input
a
– Source RTPSAa
b
– Source CTPSAb
Output
c
– Destination CTPSAc = a - b
GTPSA.mad_ctpsa_uid!
— Methodmad_ctpsa_uid!(t::Ptr{CTPSA}, uid_::Cint)::Cint
Sets the TPSA uid
if uid_ != 0
, and returns the current (previous if set) TPSA uid
.
Input
t
– Complex TPSAuid_
–uid
to set in the TPSA ifuid_ != 0
Output
ret
– Current (previous if set) TPSAuid
GTPSA.mad_ctpsa_unit!
— Methodmad_ctpsa_unit!(t::Ptr{CTPSA}, r::Ptr{CTPSA})
Interpreting TPSA a
vector, gets the "unit vector", e.g. r = t/norm(t)
. May be useful for checking for convergence.
Input
t
– Source TPSAx
Output
r
– Destination TPSAr
GTPSA.mad_ctpsa_vec2fld!
— Methodmad_ctpsa_vec2fld!(na::Cint, a::Ptr{CTPSA}, mc::Vector{Ptr{CTPSA}})
Assuming the variables in the TPSA are canonically-conjugate, and ordered so that the canonically- conjugate variables are consecutive (q1, p1, q2, p2, ...), calculates the vector field (Hamilton's equations) from the passed Hamiltonian, defined as [da/dp1, -da/dq1, ...]
Input
na
– Number of TPSA inmc
consistent with number of variables ina
a
– Hamiltonian as a TPSA
Output
mc
– Vector field derived froma
using Hamilton's equations
GTPSA.mad_desc_del!
— Methodmad_desc_del!(d_::Ptr{Desc})
Calls the destructor for the passed descriptor.
GTPSA.mad_desc_getnv!
— Methodmad_desc_getnv!(d::Ptr{Desc}, mo_::Ref{Cuchar}, np_::Ref{Cint}, po_::Ref{Cuchar}::Cint
Returns the number of variables in the descriptor, and sets the passed mo_
, np_
, and po_
to the maximum order, number of parameters, and parameter order respectively.
Input
d
– Descriptor
Output
mo_
– (Optional) Maximum order of the descriptornp_
– (Optional) Number of parameters of the descriptorpo_
– (Optional) Parameter order of the descriptorret
– Number of variables in TPSA
GTPSA.mad_desc_gtrunc!
— Methodmad_desc_gtrunc!(d::Ptr{Desc}, to::Cuchar)::Cuchar
Sets the global truncation order to
of the TPSA, and returns the old global truncation order.
Input
d
– Descriptorto
– New global truncation order
Output
oldto
– Old global truncation order
GTPSA.mad_desc_idxm
— Methodmad_desc_idxm(d::Ptr{Desc}, n::Cint, m::Vector{Cuchar})::Cint
Returns the index of the monomial as byte array m
in the descriptor, or -1 if the monomial is invalid.
Input
d
– Descriptorn
– Monomial lengthm
– Monomial as byte array
Output
ret
– Monomial index or -1 if invalid
GTPSA.mad_desc_idxs
— Methodmad_desc_idxs(d::Ptr{Desc}, n::Cint, s::Cstring)::Cint
Returns the index of the monomial as string s
in the descriptor, or -1 if the monomial is invalid.
Input
d
– Descriptorn
– String length or 0 if unknowns
– Monomial as string "[0-9]*"
Output
ret
– Monomial index or -1 if invalid monomial
GTPSA.mad_desc_idxsm
— Methodmad_desc_idxsm(d::Ptr{Desc}, n::Cint, m::Vector{Cint})::Cint
Returns the index of the monomial as sparse monomial m
, indexed as [(i,o)]
, in the descriptor, or -1 if the monomial is invalid.
Input
d
– Descriptorn
– Monomial lengthm
– Sparse monomial[(idx,ord)]
Output
ret
– Monomial index or -1 if invalid
GTPSA.mad_desc_info
— Methodmad_desc_info(d::Ptr{Desc}, fp::Ptr{Cvoid})
For debugging.
Input
d
– Descriptor to debugfp
– File to write to. If null, will write tostdout
GTPSA.mad_desc_isvalidm
— Methodmad_desc_isvalidm(d::Ptr{Desc}, n::Cint, m::Vector{Cuchar})::Cuchar
Checks if monomial as byte array m
is valid given maximum order of descriptor.
Input
d
– Descriptorn
– Length of monomialm
– Monomial as byte array
Output
ret
– True if valid, false if invalid
GTPSA.mad_desc_isvalids
— Methodmad_desc_isvalids(d::Ptr{Desc}, n::Cint, s::Cstring)::Cuchar
Checks if monomial as string s
is valid given maximum order of descriptor.
Input
d
– Descriptorn
– Monomial string lengths
– Monomial as string "[0-9]*"
Output
ret
– True if valid, false if invalid
GTPSA.mad_desc_isvalidsm
— Methodmad_desc_isvalidsm(d::Ptr{Desc}, n::Cint, m::Vector{Cint})::Cuchar
Checks the monomial as sparse monomial m
(monomial stored as sequence of integers with each pair [(i,o)]
such that i
= index, o
= order) is valid given the maximum order of the descriptor.
Input
d
– Descriptorn
– Length of monomialm
– Sparse monomial[(idx, ord)]
Output
ret
– True if valid, false if invalid
GTPSA.mad_desc_maxlen
— Methodmad_desc_maxlen(d::Ptr{Desc}, mo::Cuchar)::Cint
Gets the maximum length of the TPSA given an order.
Input
d
– Descriptormo
– Order (ordlen(maxord) == maxlen
)
Output
ret
– monomials in0..order
GTPSA.mad_desc_maxord
— Methodmad_desc_maxord(d::Ptr{Desc}, nn::Cint, no_::Vector{Cuchar})::Cuchar
Sets the order of the variables and parameters of the TPSA to those specified in no_
and returns the maximum order of the TPSA.
Input
d
– Descriptornn
– Number of variables + number of parameters,no_[1..nn]
no_
– (Optional) Orders of parameters to be filled if provided
Output
ret
– Maximum order of TPSA
GTPSA.mad_desc_mono!
— Methodmad_desc_mono!(d::Ptr{Desc}, i::Cint, n::Cint, m_::Vector{Cuchar}, p_::Vector{Cuchar})::Cuchar
Returns the order of the monomial at index i
, and if n
and m_
are provided, then will also fill m_
with the monomial at this index. Also will optionally return the order of the parameters in the monomial if p_
is provided
Input
d
– Descriptori
– Slot index (must be valid)n
– Monomial length (must be provided ifm_
is to be filled)
Output
ret
– Monomial order at slot indexm_
– (Optional) Monomial to fill if providedp_
– (Optional) Order of parameters in monomial if provided
GTPSA.mad_desc_newv
— Methodmad_desc_newv(nv::Cint, mo::Cuchar)::Ptr{Desc}
Creates a TPSA descriptor with the specified number of variables and maximum order. The number of parameters is set to 0.
Input
nv
– Number of variables in the TPSAmo
– Maximum order of TPSA,mo = max(1, mo)
Output
ret
– Descriptor with the specified number of variables and maximum order
GTPSA.mad_desc_newvp
— Methodmad_desc_newvp(nv::Cint, mo::Cuchar, np_::Cint, po_::Cuchar)::Ptr{Desc}
Creates a TPSA descriptor with the specifed number of variables, maximum order, number of parameters, and parameter order.
Input
nv
– Number of variablesmo
– Maximum order of TPSA INCLUDING PARAMETERS,mo = max(1, mo)
np_
– (Optional) Number of parameters, default is 0po_
– (Optional) Order of parameters,po = max(1, po_)
Output
ret
– Descriptor with the specifiednv
,mo
,np
, andpo
GTPSA.mad_desc_newvpo
— Methodmad_desc_newvpo(nv::Cint, mo::Cuchar, np_::Cint, po_::Cuchar, no_::Vector{Cuchar})::Ptr{Desc}
Creates a TPSA descriptor with the specifed number of variables, maximum order for both variables and parameters, number of parameters, parameter order, and individual variable/parameter orders specified in no
. The first nv
entries in no
correspond to the variables' orders and the next np
entries correspond the parameters' orders.
Input
nv
– Number of variablesmo
– Maximum order of TPSA (mo = max(mo , no[0 :nn-1])
,nn = nv+np
)np_
– (Optional) Number of parameters, default is 0po_
– (Optional) Order of parameters (po = max(po_, no[nv:nn-1])
,po <= mo
)no_
– (Optional) Array of orders of variables and parameters
Output
ret
– Descriptor with the specifiednv
,mo
,np
,po
,no
.
GTPSA.mad_desc_nxtbyord
— Methodmad_desc_nxtbyord(d::Ptr{Desc}, n::Cint, m::Vector{Cuchar})::Cint
Returns the next monomial after monomial m
in the TPSA when sorted by order.
Input
d
– Descriptorn
– Monomial lengthm
– Monomial as byte array
Output
idx
– Monomial index or -1 if no valid next monomial
GTPSA.mad_desc_nxtbyvar
— Methodmad_desc_nxtbyvar(d::Ptr{Desc}, n::Cint, m::Vector{Cuchar})::Cint
Returns the next monomial after monomial m
in the TPSA when sorted by variable.
Input
d
– Descriptorn
– Monomial lengthm
– Monomial as byte array
Output
idx
– Monomial index or -1 if no valid next monomial
GTPSA.mad_mono_add!
— Methodmad_mono_add!(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar}, r::Vector{Cuchar})
Sets monomial r = a + b
.
Input
n
– Length of monomialsa
– Source monomiala
b
– Source monomialb
Output
r
– Destination monomial,r = a + b
GTPSA.mad_mono_cat!
— Methodmad_mono_cat!(n::Cint, a::Vector{Cuchar}, m::Cint, b::Vector{Cuchar}, r::Vector{Cuchar})
Sets monomial r
equal to the concatenation of the monomials a
and b
Input
n
– Length of monomoniala
a
– Source monomiala
m
– Length of monomialb
b
– Source monomialb
Output
r
– Destination monomial of concatenation ofa
andb
(lengthn+m
)
GTPSA.mad_mono_cmp
— Methodmad_mono_cmp(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Cint
Compares monomial a
to monomial b
, and returns the first difference in the lowest order variables.
Input
n
– Length of monomialsa
– Monomiala
b
– Monomialb
Output
ret
– Firsta[i]-b[i] != 0
GTPSA.mad_mono_copy!
— Methodmad_mono_copy!(n::Cint, a::Vector{Cuchar}, r::Vector{Cuchar})
Copies monomial a
to monomial r
.
Input
n
– Length of monomialsa
– Source monomialr
– Destination monomial
GTPSA.mad_mono_eq
— Methodmad_mono_eq(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Cuchar
Checks if the monomial a
is equal to the monomial b
.
Input
n
– Length of monomialsa
– Monomiala
b
– Monomialb
Output
ret
– True if the monomials are equal, false if otherwise
GTPSA.mad_mono_fill!
— Methodmad_mono_fill!(n::Cint, a::Vector{Cuchar}, v::Cuchar)
Fills the monomial a
with the value v
.
Input
n
– Monomial lengtha
– Monomialv
– Value
GTPSA.mad_mono_le
— Methodmad_mono_le(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Cuchar
Checks if monomial a
is less than or equal to monomial b
.
Input
n
– Length of monomialsa
– Monomiala
b
– Monomialb
Output
ret
– True ifa <= mono_b
, false otherwise
GTPSA.mad_mono_lt
— Methodmad_mono_lt(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Cuchar
Checks if monomial a
is less than monomial b
.
Input
n
– Length of monomialsa
– Monomiala
b
– Monomialb
Output
ret
– True ifa < b
, false otherwise
GTPSA.mad_mono_max
— Methodmad_mono_max(n::Cint, a::Vector{Cuchar})::Cuchar
Returns the maximum order of the monomial.
Input
n
– Length of monomiala
– Monomial
Output
mo
– Maximum order of monomiala
GTPSA.mad_mono_min
— Methodmad_mono_min(n::Cint, a::Vector{Cuchar})::Cuchar
Returns the minimum order of the monomial.
Input
n
– Length of monomiala
– Monomial
Output
mo
– Mininum order of monomiala
GTPSA.mad_mono_ord
— Methodmad_mono_ord(n::Cint, a::Vector{Cuchar})::Cint
Returns the sum of the orders of the monomial a
.
Input
n
– Monomial lengtha
– Monomial
Output
s
– Sum of orders of monomial
GTPSA.mad_mono_ordp
— Methodmad_mono_ordp(n::Cint, a::Vector{Cuchar}, stp::Cint)::Cdouble
Returns the product of each stp
-th order in monomial a
. For example, stp = 2
collects every order in the monomial with a step of 2 between each. As a
is a pointer, the product can be started at any element in the monomial.
Input
n
– Monomial lengtha
– Monomial as byte arraystp
– Step over which orders to include in the product
Output
p
– Product of orders of monomial separated bystp
.
GTPSA.mad_mono_ordpf
— Methodmad_mono_ordpf(n::Cint, a::Vector{Cuchar}, stp::Cint)::Cdouble
Returns the product of factorials each stp
-th order in monomial a. For example, stp = 2
collects every order in the monomial with a step of 2 between each. As a
is a pointer, the product can be started at any element in the monomial.
Input
n
– Monomial lengtha
– Monomial as byte arraystp
– Step over which orders to include in the product of factorials
Output
p
– Product of factorials of orders of monomial separated bystp
GTPSA.mad_mono_print
— Methodmad_mono_print(n::Cint, a::Vector{Cuchar}, fp_::Ptr{Cvoid})
Prints the monomial to stdout
.
Input
n
– Length of monomiala
– Source monomial to print tostdout
fp_
– CFILE
pointer, if null will print tostdout
GTPSA.mad_mono_prt!
— Methodmad_mono_prt(n::Cint, a::Vector{Cuchar}, s::Ptr{Cuchar})::Cstring
Writes the monomial defined by the byte array a
(with orders stored as hexadecimal) into a null terminated string s
.
Input
n
– Monomial and string lengtha
– Monomial as byte array
Output
ret
– Monomial as string
GTPSA.mad_mono_rcmp
— Methodmad_mono_rcmp(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Cint
Compares monomial a
to monomial b
starting from the right (when the monomials are ordered by variable, which is almost never the case) and returns the first difference in the lowest order variables.
Input
n
– Length of monomialsa
– Monomiala
b
– Monomialb
Output
ret
– Firsta[i]-b[i] != 0
wherei
starts from the end.
GTPSA.mad_mono_rev!
— Methodmad_mono_rev!(n::Cint, a::Vector{Cuchar}, r::Vector{Cuchar})
Sets destination monomial r
equal to the reverse of source monomial a
.
Input
n
– Lengths of monomialsa
– Source monomiala
Output
r
– Destination monomial of reverse monomiala
GTPSA.mad_mono_str!
— Methodmad_mono_str!(n::Cint, a::Vector{Cuchar}, s::Cstring)::Cint
Writes the monomial defined in the string s
, which stores the orders in a human-readable format (e.g. 10 is 10, not 0xa), into the byte array a
with the orders specified in hexadecimal.
Input
n
– Monomial and string lengths
– Monomial as string "[0-9]*"
Output
a
– Monomial as a byte array converted from the input stringi
– Adjusted sizen
of byte array if '