For Developers
Developers may fork the GTPSA.jl repo and then dev their forked repo in the REPL. For example, if my Github username is githubuser, then after forking GTPSA.jl I would run in the REPL:
import Pkg
Pkg.develop(url="https://github.com/githubuser/GTPSA.jl")The package consists of two layers: a low-level layer written in Julia that is 1-to-1 with the GTPSA C code, and a high-level, user-friendly layer that cleans up the notation for manipulating TPSs, manages temporaries generated during evaluation, and properly manages the memory in C when variables go out of scope in Julia. The low-level functions are listed at the bottom of this page.
When it comes to managing memory in C via Julia, there are certain intricacies that have to be considered. First, let's consider the Descriptor, which is the simplest:
Descriptor
The Descriptor stores all information about the GTPSA, including the indexing table for indexing specific monomials. This is a static object, only created once for a GTPSA, which all TPSs refer to. In C, these structs must exist for the entirety of the program execution. In Julia, because they must not be destroyed when out-of-scope, we wrap these objects in immutable structs. In a single program, up to 250 Descriptors can exist simultanouesly, and they can be manually optionally destroyed using GTPSA.mad_desc_del!. At program termination all Descriptors are destroyed. Given the significantly large number allowed, as well as the danger of still-existing TPS and Descriptor structs after destruction, no front-facing interface to the user is given for destroying existing Descriptors.
The Descriptor struct simply wraps a C-pointer to a low-level struct called Desc: this struct is 1-to-1 equivalent to the C struct desc in GTPSA. See the documentation for GTPSA.Desc below. By having this struct in Julia, we can unsafe_load the struct and get values in the desc. For example, to access the first TPS{Float64} in the buffer of temporaries in the Descriptor, we can do
julia> using GTPSAjulia> import GTPSA: Descjulia> d = Descriptor(5,8)Descriptor(NV=5, MO=8)julia> desc = unsafe_load(d.desc) # To access the low-level C structGTPSA.Desc(2, 5, 5, 0, 0x08, 0x00, 0xff, Ptr{UInt8} @0x0000000007c0e750, 0, 4, 0x00000507, 0x00000000, 0x00000000, Ptr{Int32} @0x00000000080f6ce0, Ptr{UInt8} @0x00000000088ab3f0, Ptr{UInt8} @0x00000000080f3eb0, Ptr{UInt8} @0x00000000088e5b90, Ptr{Ptr{UInt8}} @0x0000000008ab4da0, Ptr{Ptr{UInt8}} @0x00000000087c8430, Ptr{Ptr{UInt8}} @0x00000000087b2230, Ptr{Int32} @0x0000000008ab7dd0, Ptr{Int32} @0x000000000833fbb0, Ptr{Int32} @0x00000000085b1950, Ptr{Int32} @0x0000000007f7bcb0, Ptr{Ptr{Int32}} @0x0000000007a96de0, Ptr{Ptr{Ptr{Int32}}} @0x0000000008737820, 0x0000000000022195, 0.0, 0.0, 0.0, Ptr{Ptr{Nothing}} @0x00000000082f9f20, Ptr{Ptr{Nothing}} @0x0000000008296b20, Ptr{Int32} @0x00000000085c0720, Ptr{Int32} @0x0000000007fa73a0)julia> t_jl = unsafe_load(Base.unsafe_convert(Ptr{Ptr{TPS{Float64}}}, desc.t), 1) # 1 in Julia = 0 in CPtr{TPS64} @0x00000000074ca820
In Julia, if we were to then unsafe_load(t_jl), there would in fact be allocations, as its internally creating a copy of the TPS{Float64} in Julia. This is not well documented in the documentation of unsafe_load (see the discussion here).
TPS
The TPS{Float64} struct in Julia corresponds exactly to the C struct tpsa and TPS{ComplexF64} struct in Julia corresponds exactly to ctpsa in C. To understand fully the TPS struct, some history is needed:
In early development versions of GTPSA.jl, the TPS struct was very similar to the Descriptor struct: it used to just wrap a C Ptr to a low-level struct, and instead be mutable so out-of-scope TPSs and temporaries are cleaned up. This at the time seemed like the simplest solution, since in Julia there is no way to tag C pointers for Julia garbage collection. This created some problems though: firstly, there is one indirection because Julia would tag that particular mutable wrapper struct for GC, but then the member Ptr of that struct pointed to a different place in memory that had to be cleaned up. Secondly, when calling GTPSA C functions that want a Vector of TPS (e.g. Ptr to TPS), you would need to do a map(t->t.tpsa, x) where x is a Vector{TPS64} and tpsa is the field member of the wrapper TPS struct. Thirdly, and perhaps most significantly, Julia is not aware of how much memory the C is using. Therefore, it will not call the garbage collector very often, even if actually >100GB of memory is being used. Sometimes the OS will just kill the Julia process.
In order to get around these problems, we must allocate the entire mutable TPS struct in Julia instead of in the C code (e.g. using GTPSA.mad_tpsa_newd). We then can use pointer_from_objref in Julia to get a pointer to that mutable, Julia-owned struct to pass to the C functions.
Sounds simple enough, right? If only! In the GTPSA C code, the coef member array is something called a flexible array member. This is great in C, because instead of the struct storing a pointer to an array (which would cause an indirection every time the coef array is accessed in a TPS), it actually stores the array right there in the struct, with variable size. This gives some performance gains. In Julia, there is no such analog. For those who know about StaticArrays.jl, you might think an SVector could work, but surprise, it doesn't because you cannot mutate the fields of an SVector and neither can the C code.
So the only solution it seems is to change the actual C struct in mad_tpsa_impl.h and mad_ctpsa_impl.h to use regular arrays for coef instead of flexible array members, and indeed this is what is done for GTPSA.jl. There is a tiny speed reduction due to the indirection of accessing coef, however the benefits of Julia's garbage collector knowing how much memory it's using, and keeping memory usage sane, is worth the very tiny cost.
On the Julia side, it turns out you cannot just use a regular Vector for the coef array in the TPS struct, because Julia's Vector structs are quite complex and play a lot of tricks. You might actually be able to use an MVector from StaticArrays, however using this struct might make GTPSA.jl significantly more complex because the size of the array has to be known at compile-time or else you suffer the drastic performance reductions caused by type-instabilities. The complexity of using this could be checked at some point in the future.
The decided solution was to, in the Julia, @ccall jl_malloc for the coef array, and in the finalizer for the mutable TPS struct call @ccall jl_free for the coef array. This gives us C-style arrays that Julia's garbage collector knows about, and so will make sure to keep the memory usage sane.
When @ccall is used, the arguments are Base.unsafe_converted to the corresponding specified argument types. Therefore, for TPS all we had to do then was define
Base.unsafe_convert(::Type{Ptr{TPS{T}}}, t::TPS{T}) where {T} = Base.unsafe_convert(Ptr{TPS{T}},pointer_from_objref(t))and now we can pass our TPS structs to C using @ccall.
TempTPS
Because unsafe_load of a Ptr{<:TPS} creates a copy and allocates, we cannot treat the constant buffer of pre-allocated temporaries in the Descriptor as bona-fide TPSs. Note that the memory addresses of the temporaries in the buffer are constant and do not need to be cleaned up; they are immutable!. The temporaries, which we give the type GTPSA.TempTPS, do not have any of the problems of just wrapping a pointer as do the TPSs, and so that's what they are. Also in Julia, in order to access the fields of a TempTPS (e.g. mo) via unsafe_load without allocating, we need an immutable struct having the same structure as TPS. This is the purpose of GTPSA.LowTempTPS. We need to use the mo field for @FastGTPSA to finally allocate the result TPS with the mo of the result TempTPS.
As with TPS, we also had to define Base.unsafe_convert for TempTPS so we can @ccall. In this case, the unsafe_convert returns the member Ptr of the TempTPS.
GTPSA.TempTPS — Type
struct TempTPS{T<:Union{Float64,ComplexF64},D}This is for internal use only. TempTPS is a temporary TPS, which has been pre-allocated in a buffer for each thread in the Descriptor C struct. When using the @FastGTPSA macro, all temporaries generated will be used from this buffer. "Constructors" of this type simply take a temporary from that particular thread's buffer in a stack-like manner and "Destructors" (which must be manually called because this is immutable) release it from the stack.
Fields
t::Ptr{TPS{T,D}}– Pointer to theTPSin the buffer in theDescriptor
Library Structure
All operators have an in-place, mutating version specified with a bang (!). These are the lowest-level pure Julia code, following the convention that the first argument is the one to contain the result. In the GTPSA C library, the last argument contains the result, so this is accounted for in the file inplace_operators.jl. All in-place functions can receive either a regular TPS , which the user will be using, as well as a GTPSA.TempTPS, which the user should not concern themselves with. The constants RealTPS and ComplexTPS are defined respectively in low_level/rtpsa.jl and low_level/ctpsa.jl to simplify the notation. These are just:
# Internal constants to aid multiple dispatch including temporaries
const RealTPS = Union{TempTPS{Float64}, TPS{Float64}}
const ComplexTPS = Union{TempTPS{ComplexF64}, TPS{ComplexF64}}All this does is enforce correct types for the in-place functions, while keeping the notation/code simple.
The in-place, mutating functions, defined in inplace_operators.jl must all use the RealTPS and ComplexTPS "types". Then, the higher level out-of-place functions for both TPS and TempTPS, which do different things with the result, will use these in-place functions.
The out-of-place functions for TPS are defined in operators.jl, and the out-of-place functions for TempTPS are defined in fastgtpsa/operators.jl.
Fast GTPSA Macros
The @FastGTPSA/@FastGTPSA! macros work by changes all arithmetic operators in different Julia arithmetic operators with the same operator precedence and unary operator capabilities. These special operators then dispatch on functions that use the temporaries when a TPS or TempTPS is passed, else default to their original operators, thereby making it completely transparent to non-TPS types. Both + and - must work as unary operators, and there is a very short list of allowed ones shown here. The other arithmetic operators were chosen somewhat randomly from the top of the same file, next to prec-plus, prec-times, and prec-power which defines the operator precedences. By taking this approach, we relieve ourselves of having to rewrite PEMDAS and instead let the Julia do it for us.
All arithmetic operators are changed to GTPSA.:<special symbols>, e.g. + → GTPSA.:±. All non-arithmetic operators that are supported by GTPSA are then changed to GTPSA.__t_<operator>, e.g. sin → GTPSA.__t_sin, where the prefix __t_ is also chosen somewhat arbitrarily. These operators are all defined in fastgtpsa/operators.jl, and when they encounter a TPS type, they use the temporaries, and when other number types are detected, they fallback to the regular, non-__t_ operator. This approach works extraordinarily well, and introduces no problems externally because none of these functions/symbols are exported.
Calling the C-library with pointers and pointer-to-pointers
All of the GTPSA map functions require a vector of TPS as input, in C **tpsa. In Julia, this works automatically for AbstractArray{<:Union{TPS64,ComplexTPS64}} by specifying the C argument type in the C call as ::Ptr{TPS64} or ::Ptr{ComplexTPS64}. However, this can be misleading to those C inputs which require *tpsa, e.g. also ::Ptr{TPS64}. For consistency in the low level library interface, all pointers are specified as ::Ref{TPS64} and ::Ref{ComplexTPS64}, and pointers-to-pointers are specified as Ptrs. For single TPSs, the cconvert to Ref in the ccall is handled automatically.
However, in some cases, one might have only a single TPS64 and would like the call the corresponding map functions without having to allocate an array. After some experimenting, I've found the following overrides to gives zero allocations:
Base.unsafe_convert(::Type{Ptr{TPS{T}}}, r::Base.RefValue{Ptr{Nothing}}) where {T} = Base.unsafe_convert(Ptr{TPS{T}}, Base.unsafe_convert(Ptr{Cvoid}, r))
Base.cconvert(::Type{Ptr{TPS{T}}}, t::TPS{T}) where {T} = Ref(pointer_from_objref(t))NOTE: We need to have a GC.@preserve before the cconvert to keep t valid! As such, you will see in all map functions a call to GC.@preserve.
This override is only necessary for the mutable TPS. The other array inputs of isbits types are ok and basically have the above defined for them. See this discussion for more details.
Low-Level
Below is documentation for every single 1-to-1 C function in the GTPSA library. If there is any function missing, please submit an issue to GTPSA.jl.
Monomial
GTPSA.mad_mono_add! — Function
mad_mono_add!(n::Cint, a, b, r)Sets monomial r = a + b.
Input
n– Length of monomialsa– Source monomialab– Source monomialb
Output
r– Destination monomial,r = a + b
GTPSA.mad_mono_cat! — Function
mad_mono_cat!(n::Cint, a, m::Cint, b, r)Sets monomial r equal to the concatenation of the monomials a and b
Input
n– Length of monomonialaa– Source monomialam– Length of monomialbb– Source monomialb
Output
r– Destination monomial of concatenation ofaandb(lengthn+m)
GTPSA.mad_mono_cmp — Function
mad_mono_cmp(n::Cint, a, b)::CintCompares monomial a to monomial b, and returns the first difference in the lowest order variables.
Input
n– Length of monomialsa– Monomialab– Monomialb
Output
ret– Firsta[i]-b[i] != 0
GTPSA.mad_mono_copy! — Function
mad_mono_copy!(n::Cint, a, r)Copies monomial a to monomial r.
Input
n– Length of monomialsa– Source monomialr– Destination monomial
GTPSA.mad_mono_eq — Function
mad_mono_eq(n::Cint, a, b)::BoolChecks if the monomial a is equal to the monomial b.
Input
n– Length of monomialsa– Monomialab– Monomialb
Output
ret– True if the monomials are equal, false if otherwise
GTPSA.mad_mono_eqn — Function
mad_mono_eqn(n::Cint, a, b::Cuchar)::Bool???
GTPSA.mad_mono_fill! — Function
mad_mono_fill!(n::Cint, a, v::Cuchar)Fills the monomial a with the value v.
Input
n– Monomial lengtha– Monomialv– Value
GTPSA.mad_mono_le — Function
mad_mono_le(n::Cint, a, b)::BoolChecks if monomial a is less than or equal to monomial b.
Input
n– Length of monomialsa– Monomialab– Monomialb
Output
ret– True ifa <= mono_b, false otherwise
GTPSA.mad_mono_lt — Function
mad_mono_lt(n::Cint, a, b)::BoolChecks if monomial a is less than monomial b.
Input
n– Length of monomialsa– Monomialab– Monomialb
Output
ret– True ifa < b, false otherwise
GTPSA.mad_mono_max — Function
mad_mono_max(n::Cint, a)::CucharReturns the maximum order of the monomial.
Input
n– Length of monomiala– Monomial
Output
mo– Maximum order of monomiala
GTPSA.mad_mono_min — Function
mad_mono_min(n::Cint, a)::CucharReturns the minimum order of the monomial.
Input
n– Length of monomiala– Monomial
Output
mo– Mininum order of monomiala
GTPSA.mad_mono_ord — Function
mad_mono_ord(n::Cint, a)::UInt32Returns 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 — Function
mad_mono_ordp(n::Cint, a, stp::Cint)::CdoubleReturns 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 — Function
mad_mono_ordpf(n::Cint, a, stp::Cint)::CdoubleReturns 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 — Function
mad_mono_print(n::Cint, a, sep_::Cstring, fp_::Ptr{Cvoid})Prints the monomial to stdout.
Input
n– Length of monomiala– Source monomial to print tostdoutsep_– Separator stringfp_– CFILEpointer, if null will print tostdout
GTPSA.mad_mono_prt! — Function
mad_mono_prt(n::Cint, a, s::Ptr{Cuchar})::CstringWrites 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 — Function
mad_mono_rcmp(n::Cint, a, b)::CintCompares 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– Monomialab– Monomialb
Output
ret– Firsta[i]-b[i] != 0whereistarts from the end.
GTPSA.mad_mono_rev! — Function
mad_mono_rev!(n::Cint, a, r)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! — Function
mad_mono_str!(n::Cint, a, s::Cstring)::CvoidWrites 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 string
GTPSA.mad_mono_sub! — Function
mad_mono_sub!(n::Cint, a, b, r)Sets monomial r = a - b.
Input
n– Length of monomialsa– Source monomialab– Source monomialb
Output
r– Destination monomial,r = a - b
Desc
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 <= 100000nv::Cint– Number of variablesnp::Cint– Number of parametersmo::Cuchar– Max order of both variables AND parameterspo::Cuchar– Max order of parameterssh::Cuchar– shared with id or -1no::Ptr{Cuchar}– Array of orders of each variable (firstnventries) and parameters (lastnpentries), lengthnn. Note: In C this isconstuno::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)pmul::Cuint– Threshold for parallel mult (0 = disable)pcomp::Cuint– Threshold for parallel compose (0 = disable)shared::Ptr{Cint}– counter of shared desc (all tables below except prms)monos::Ptr{Cuchar}– 'Matrix' storing the monomials (sorted by variable)ords::Ptr{Cuchar}– Order of each monomial ofToprms::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]->oin mul, computeoon threadt 3 <= o <= moaterminated with 0ord2idx::Ptr{Cint}– Order to polynomial start index inTo(i.e. in TPSAcoef)tv2to::Ptr{Cint}– Lookuptv->toto2tv::Ptr{Cint}– Lookupto->tvH::Ptr{Cint}– Indexing matrix inTvL::Ptr{Ptr{Cint}}– Multiplication indexesL[oa,ob]->L_ordL_ord[ia,ib]->icL_idx::Ptr{Ptr{Ptr{Cint}}}–L_idx[oa,ob]->[start] [split] [end]idxs inLsize::Culonglong– Bytes used bydesc.Unsigned Long Int: In 32 bit system isInt32but 64 bit isInt64. UsingCulonglongassuming 64 bitdst_n::Cdouble– density countdst_mu::Cdouble– density meandst_var::Cdouble– density variancet::Ptr{Ptr{Cvoid}}– Temporary array contains 8 pointers toTPS{Float64}s already initializedct::Ptr{Ptr{Cvoid}}– Temporary array contains 8 pointers toTPS{ComplexF64}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.mad_desc_del! — Function
mad_desc_del!(d_::Ptr{Desc})Calls the destructor for the passed descriptor.
GTPSA.mad_desc_getnv! — Function
mad_desc_getnv!(d::Ptr{Desc}, mo_::Ref{Cuchar}, np_::Ref{Cint}, po_::Ref{Cuchar}::CintReturns 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_idxm — Function
mad_desc_idxm(d::Ptr{Desc}, n::Cint, m)::CintReturns 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 — Function
mad_desc_idxs(d::Ptr{Desc}, n::Cint, s::Cstring)::CintReturns 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 — Function
mad_desc_idxsm(d::Ptr{Desc}, n::Cint, m)::CintReturns 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 — Function
mad_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 — Function
mad_desc_isvalidm(d::Ptr{Desc}, n::Cint, m)::BoolChecks 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 — Function
mad_desc_isvalids(d::Ptr{Desc}, n::Cint, s::Cstring)::BoolChecks 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 — Function
mad_desc_isvalidsm(d::Ptr{Desc}, n::Cint, m)::BoolChecks 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 — Function
mad_desc_maxlen(d::Ptr{Desc}, mo::Cuchar)::CintGets 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 — Function
mad_desc_maxord(d::Ptr{Desc}, nn::Cint, no_)::CucharSets 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! — Function
mad_desc_mono!(d::Ptr{Desc}, i::Cint, n::Cint, m_, p_)::CucharReturns 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 — Function
mad_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 — Function
mad_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 — Function
mad_desc_newvpo(nv::Cint, mo::Cuchar, np_::Cint, po_::Cuchar, no_)::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 — Function
mad_desc_nxtbyord(d::Ptr{Desc}, n::Cint, m)::CintReturns 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 — Function
mad_desc_nxtbyvar(d::Ptr{Desc}, n::Cint, m)::CintReturns 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_desc_paropsth! — Function
mad_desc_paropsth!(d::Ptr{Desc}, mult_, comp_)Sets the parallelised operations thresholds for multiplication (mult_) and/or composition (comp_). Will return in mult_ and/or comp_ the previous threshold.
Input
mult_– (Optional)Ptr{Cint}to new multiplication OMP parallelization thresholdcomp_– (Optional)Ptr{Cint}to new composition OMP parallelization threshold
Output
mult_– (Optional) old multiplication parallelization thresholdcomp_– (Optional) old composition parallelization threshold
TPS{Float64}
GTPSA.mad_tpsa_abs! — Function
mad_tpsa_abs!(a::RealTPS, c::RealTPS)Sets TPSA c to the absolute value of TPSA a. Specifically, the result contains a TPSA with the abs of all coefficients.
Input
a– Source TPSAa
Output
c– Destination TPSAc = |a|
GTPSA.mad_tpsa_acc! — Function
mad_tpsa_acc!(a::RealTPS, v::Cdouble, c::RealTPS)Adds a*v to TPSA c. Aliasing OK.
Input
a– Source TPSAav– Scalar with double precision
Output
c– Destination TPSAc += v*a
GTPSA.mad_tpsa_acos! — Function
mad_tpsa_acos!(a::RealTPS, c::RealTPS)Sets TPSA c to the acos of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = acos(a)
GTPSA.mad_tpsa_acosh! — Function
mad_tpsa_acosh!(a::RealTPS, c::RealTPS)Sets TPSA c to the acosh of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSA `c = acosh(a)'
GTPSA.mad_tpsa_acot! — Function
mad_tpsa_acot!(a::RealTPS, c::RealTPS)Sets TPSA c to the acot of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = acot(a)
GTPSA.mad_tpsa_acoth! — Function
mad_tpsa_acoth!(a::RealTPS, c::RealTPS)Sets TPSA c to the acoth of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSA `c = acoth(a)'
GTPSA.mad_tpsa_add! — Function
mad_tpsa_add!(a::RealTPS, b::RealTPS, c::RealTPS)Sets the destination TPSA c = a + b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a + b
GTPSA.mad_tpsa_asin! — Function
mad_tpsa_asin!(a::RealTPS, c::RealTPS)Sets TPSA c to the asin of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = asin(a)
GTPSA.mad_tpsa_asinc! — Function
mad_tpsa_asinc!(a::RealTPS, c::RealTPS)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_tpsa_asinh! — Function
mad_tpsa_asinh!(a::RealTPS, c::RealTPS)Sets TPSA c to the asinh of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSA `c = asinh(a)'
GTPSA.mad_tpsa_asinhc! — Function
mad_tpsa_asinhc!(a::RealTPS, c::RealTPS)Sets TPSA c to the asinhc of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSA `c = asinhc(a)'
GTPSA.mad_tpsa_atan! — Function
mad_tpsa_atan!(a::RealTPS, c::RealTPS)Sets TPSA c to the atan of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = atan(a)
GTPSA.mad_tpsa_atan2! — Function
mad_tpsa_atan2!(y::RealTPS, x::RealTPS, r::RealTPS)Sets TPSA r to atan2(y,x)
Input
y– Source TPSAyx– Source TPSAx
Output
r– Destination TPSA r = atan2(y,x)
GTPSA.mad_tpsa_atanh! — Function
mad_tpsa_atanh!(a::RealTPS, c::RealTPS)Sets TPSA c to the atanh of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSA `c = atanh(a)'
GTPSA.mad_tpsa_ax2pby2pcz2! — Function
mad_tpsa_ax2pby2pcz2!(a::Cdouble, x::RealTPS, b::Cdouble, y::RealTPS, c::Cdouble, z::RealTPS, r::RealTPS)r = a*x^2 + b*y^2 + c*z^2
Input
a– Scalarax– TPSAxb– Scalarby– TPSAyc– Scalarcz– TPSAz
Output
r– Destination TPSAr
GTPSA.mad_tpsa_axpb! — Function
mad_tpsa_axpb!(a::Cdouble, x::RealTPS, b::Cdouble, r::RealTPS)r = a*x + b
Input
a– Scalarax– TPSAxb– Scalarb
Output
r– Destination TPSAr
GTPSA.mad_tpsa_axpbypc! — Function
mad_tpsa_axpbypc!(a::Cdouble, x::RealTPS, b::Cdouble, y::RealTPS, c::Cdouble, r::RealTPS)r = a*x + b*y + c
Input
a– Scalarax– TPSAxb– Scalarby– TPSAyc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_tpsa_axpsqrtbpcx2! — Function
mad_tpsa_axpsqrtbpcx2!(x::RealTPS, a::Cdouble, b::Cdouble, c::Cdouble, r::RealTPS)r = a*x + sqrt(b + c*x^2)
Input
x– TPSAxa– Scalarab– Scalarbc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_tpsa_axypb! — Function
mad_tpsa_axypb!(a::Cdouble, x::RealTPS, y::RealTPS, b::Cdouble, r::RealTPS)r = a*x*y + b
Input
a– Scalarax– TPSAxy– TPSAyb– Scalarb
Output
r– Destination TPSAr
GTPSA.mad_tpsa_axypbvwpc! — Function
mad_tpsa_axypbvwpc!(a::Cdouble, x::RealTPS, y::RealTPS, b::Cdouble, v::RealTPS, w::RealTPS, c::Cdouble, r::RealTPS)r = a*x*y + b*v*w + c
Input
a– Scalarax– TPSAxy– TPSAyb– Scalarbv– TPSA vw– TPSA wc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_tpsa_axypbzpc! — Function
mad_tpsa_axypbzpc!(a::Cdouble, x::RealTPS, y::RealTPS, b::Cdouble, z::RealTPS, c::Cdouble, r::RealTPS)r = a*x*y + b*z + c
Input
a– Scalarax– TPSAxy– TPSAyb– Scalarbz– TPSAzc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_tpsa_clear! — Function
mad_tpsa_clear!(t::RealTPS)Clears the TPSA (reset to 0)
Input
t– TPSA
GTPSA.mad_tpsa_clrord! — Function
mad_tpsa_clrord!(t::RealTPS, ord::Cuchar)Clears all monomial coefficients of the TPSA at order ord
Input
t– TPSAord– Order to clear monomial coefficients
GTPSA.mad_tpsa_compose! — Function
mad_tpsa_compose!(na::Cint, ma, nb::Cint, mb, mc)Composes two maps.
Input
na– Number of TPSAs in mapmama– mapmanb– Number of TPSAs in mapmbmb– mapmb
Output
mc– Composition of mapsmaandmb
GTPSA.mad_tpsa_convert! — Function
mad_tpsa_convert!(t::RealTPS, r::RealTPS, n::Cint, t2r_, 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 TPSAn– Length of vectort2r_– (Optional) Vector of index lookuppb– Poisson bracket, 0, 1:fwd, -1:bwd
Output
r– Destination TPSA with specified order and canonical coordinate reshuffling.
GTPSA.mad_tpsa_copy! — Function
mad_tpsa_copy!(t::RealTPS, r::RealTPS)Makes a copy of the TPSA t to r.
Input
t– Source TPSA
Output
r– Destination TPSA
GTPSA.mad_tpsa_cos! — Function
mad_tpsa_cos!(a::RealTPS, c::RealTPS)Sets TPSA c to the cos of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = cos(a)
GTPSA.mad_tpsa_cosh! — Function
mad_tpsa_cosh!(a::RealTPS, c::RealTPS)Sets TPSA c to the cosh of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = cosh(a)
GTPSA.mad_tpsa_cot! — Function
mad_tpsa_cot!(a::RealTPS, c::RealTPS)Sets TPSA c to the cot of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = cot(a)
GTPSA.mad_tpsa_coth! — Function
mad_tpsa_coth!(a::RealTPS, c::RealTPS)Sets TPSA c to the coth of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = coth(a)
GTPSA.mad_tpsa_cpyi! — Function
mad_tpsa_cpyi!(t::RealTPS, r::RealTPS, i::Cint)Copies the monomial coefficient at index i in t into the same monomial coefficient in r
Input
t– Source TPSAr– Destination TPSAi– Index of monomial
GTPSA.mad_tpsa_cpym! — Function
mad_tpsa_cpym!(t::RealTPS, r::RealTPS, n::Cint, m)Copies the monomial coefficient at the monomial-as-vector-of-orders m in t into the same monomial coefficient in r
Input
t– Source TPSAr– Destination TPSAn– Length of monomialmm– Monomial as vector of orders
GTPSA.mad_tpsa_cpys! — Function
mad_tpsa_cpys!(t::RealTPS, r::RealTPS, n::Cint, s::Cstring)Copies the monomial coefficient at the monomial-as-string-of-order s in t into the same monomial coefficient in r
Input
t– Source TPSAr– Destination TPSAn– Length of strings– Monomial as string
GTPSA.mad_tpsa_cpysm! — Function
mad_tpsa_cpysm!(t::RealTPS, r::RealTPS, n::Cint, m)Copies the monomial coefficient at the monomial-as-sparse-monomial m in t into the same monomial coefficient in r
Input
t– Source TPSAr– Destination TPSAn– Length of monomialmm– Monomial as sparse-monomial
GTPSA.mad_tpsa_cutord! — Function
mad_tpsa_cutord!(t::RealTPS, r::RealTPS, 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 TPSAord– Cut order:0..-ordorord..mo
Output
r– Destination TPSA
GTPSA.mad_tpsa_cycle! — Function
mad_tpsa_cycle!(t::RealTPS, i::Cint, n::Cint, m_, v_)::CintUsed 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– 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.mad_tpsa_debug — Function
mad_tpsa_debug(t::RealTPS, name_::Cstring, fnam_::Cstring, line_::Cint, stream_::Ptr{Cvoid})::CintPrints 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
Output
ret–Cintreflecting internal state of TPSA
GTPSA.mad_tpsa_del! — Function
mad_tpsa_del!(t::Ref{TPS{Float64}})Calls the destructor for the TPSA.
Input
t– TPSA to destruct
GTPSA.mad_tpsa_density — Function
mad_tpsa_density(t::RealTPS, stat_, reset::Bool)::CdoubleComputes the ratio of nz/nc in [0] U [lo,hi] or stat_
GTPSA.mad_tpsa_deriv! — Function
mad_tpsa_deriv!(a::RealTPS, c::RealTPS, 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_tpsa_derivm! — Function
mad_tpsa_derivm!(a::RealTPS, c::RealTPS, n::Cint, m)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_tpsa_desc — Function
mad_tpsa_desc(t::RealTPS)::Ptr{Desc}Gets the descriptor for the TPSA.
Input
t– TPSA
Output
ret– Descriptor for the TPS{Float64}
GTPSA.mad_tpsa_dif! — Function
mad_tpsa_dif!(a::RealTPS, b::RealTPS, c::RealTPS)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 TPSAab– Source TPSAb
Output
c– Destination TPSAc
GTPSA.mad_tpsa_div! — Function
mad_tpsa_div!(a::RealTPS, b::RealTPS, c::RealTPS)Sets the destination TPSA c = a / b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a / b
GTPSA.mad_tpsa_equ — Function
mad_tpsa_equ(a::RealTPS, b::RealTPS, tol_::Cdouble)::BoolChecks if each coefficient in the TPSAs a and b are equal within the specified absolute tolerance tol_.
Input
a– TPSAab– TPSAbtol_– (Optional) Difference below which the TPSAs are considered equal
Output
ret– True ifa == bwithintol_
GTPSA.mad_tpsa_erf! — Function
mad_tpsa_erf!(a::RealTPS, c::RealTPS)Sets TPSA c to the erf of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSA `c = erf(a)'
GTPSA.mad_tpsa_erfc! — Function
mad_tpsa_erfc!(a::RealTPS, c::RealTPS)Sets TPSA c to the erfc of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSA `c = erfc(a)'
GTPSA.mad_tpsa_eval! — Function
mad_tpsa_eval!(na::Cint, ma, nb::Cint, tb, tc)Evaluates the map at the point tb
Input
na– Number of TPSAs in the mapma– mapmanb– Length oftbtb– Point at which to evaluate the map
Output
tc– Values for each TPSA in the map evaluated at the pointtb
GTPSA.mad_tpsa_exp! — Function
mad_tpsa_exp!(a::RealTPS, c::RealTPS)Sets TPSA c to the exponential of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = exp(a)
GTPSA.mad_tpsa_exppb! — Function
mad_tpsa_exppb!(na::Cint, ma, nb::Cint, mb, mc)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 ofmama– Vector of TPSAmanb– Length ofmbmb– Vector of TPSAmb
Output
mc– Destination vector of TPSAmc
GTPSA.mad_tpsa_fgrad! — Function
mad_tpsa_fgrad!(na::Cint, ma, b::RealTPS, c::RealTPS)Calculates dot(ma, grad(b))
Input
na– Length ofmaconsistent with number of variables inbma– Vector of TPSAb– TPSA
Output
c–dot(ma, grad(b))
GTPSA.mad_tpsa_fld2vec! — Function
mad_tpsa_fld2vec!(na::Cint, ma, c::RealTPS)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 inmaconsistent with number of variables incma– Vector field
Output
c– Hamiltonian as a TPSA derived from the vector fieldma
GTPSA.mad_tpsa_geti — Function
mad_tpsa_geti(t::RealTPS, i::Cint)::CdoubleGets 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_tpsa_getm — Function
mad_tpsa_getm(t::RealTPS, n::Cint, m)::CdoubleGets 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 monomialmin TPSA
GTPSA.mad_tpsa_getord! — Function
mad_tpsa_getord!(t::RealTPS, r::RealTPS, ord::Cuchar)Extract one homogeneous polynomial of the given order
Input
t– Source TPSAord– Order to retrieve
Output
r– Destination TPSA
GTPSA.mad_tpsa_gets — Function
mad_tpsa_gets(t::RealTPS, n::Cint, s::Cstring)::CdoubleGets the coefficient of the monomial s defined as a string. Generally should use mad_tpsa_cycle instead of this.
Input
t– TPSAn– Length of monomials– Monomial as string
Output
ret– Coefficient of monomialsin TPSA
GTPSA.mad_tpsa_getsm — Function
mad_tpsa_getsm(t::RealTPS, n::Cint, m)::CdoubleGets 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 monomialmin TPSA
GTPSA.mad_tpsa_getv! — Function
mad_tpsa_getv!(t::RealTPS, i::Cint, n::Cint, v)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_tpsa_hypot! — Function
mad_tpsa_hypot!(x::RealTPS, y::RealTPS, r::RealTPS)Sets TPSA r to sqrt(x^2+y^2). Used to oversimplify polymorphism in code but not optimized
Input
x– Source TPSAxy– Source TPSAy
Output
r– Destination TPSA r = sqrt(x^2+y^2)
GTPSA.mad_tpsa_hypot3! — Function
mad_tpsa_hypot3!(x::RealTPS, y::RealTPS, z::RealTPS, r::RealTPS)Sets TPSA r to sqrt(x^2+y^2+z^2). Does NOT allow for r = x, y, z !!!
Input
x– Source TPSAxy– Source TPSAyz– Source TPSAz
Output
r– Destination TPSAr = sqrt(x^2+y^2+z^2)
GTPSA.mad_tpsa_idxm — Function
mad_tpsa_idxm(t::RealTPS, n::Cint, m)::CintReturns index of monomial in the TPSA given the monomial as a byte array
Input
t– TPSAn– Length of monomials– Monomial as byte array
Output
ret– Index of monomial in TPSA
GTPSA.mad_tpsa_idxs — Function
mad_tpsa_idxs(t::RealTPS, n::Cint, s::Cstring)::CintReturns 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_tpsa_idxsm — Function
mad_tpsa_idxsm(t::RealTPS, n::Cint, m)::CintReturns 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_tpsa_init! — Function
mad_tpsa_init(t::RealTPS, d::Ptr{Desc}, mo::Cuchar)::RealTPSUnsafe 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 descriptordd– Descriptormo– Maximum order of the TPSA (must be less than maximum order of the descriptor)
Output
t– TPSA initialized to descriptordwith maximum ordermo
GTPSA.mad_tpsa_integ! — Function
mad_tpsa_integ!(a::RealTPS, c::RealTPS, 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_tpsa_inv! — Function
mad_tpsa_inv!(a::RealTPS, v::Cdouble, c::RealTPS)Sets TPSA c to v/a.
Input
a– Source TPSAav– Scalar with double precision
Output
c– Destination TPSAc = v/a
GTPSA.mad_tpsa_invsqrt! — Function
mad_tpsa_invsqrt!(a::RealTPS, v::Cdouble, c::RealTPS)Sets TPSA c to v/sqrt(a).
Input
a– Source TPSAav– Scalar with double precision
Output
c– Destination TPSAc = v/sqrt(a)
GTPSA.mad_tpsa_isnul — Function
mad_tpsa_isnul(t::RealTPS)::BoolChecks if TPSA is 0 or not
Input
t– TPSA to check
Output
ret– True or false
GTPSA.mad_tpsa_isval — Function
mad_tpsa_isval(t::RealTPS)::BoolSanity check of the TPSA integrity.
Input
t– TPSA to check if valid
Output
ret– True if valid TPSA, false otherwise
GTPSA.mad_tpsa_isvalid — Function
mad_tpsa_isvalid(t::RealTPS)::BoolSanity check of the TPSA integrity.
Input
t– TPSA to check if valid
Output
ret– True if valid TPSA, false otherwise
GTPSA.mad_tpsa_len — Function
mad_tpsa_len(t::RealTPS, hi_::Bool)::CintGets the length of the TPSA itself (e.g. the descriptor may be order 10 but TPSA may only be order 2)
Input
t– TPSAhi_– Iftrue, returns the length up to thehiorder in the TPSA, else up tomo. Default is false
Output
ret– Length of TPS{Float64}
GTPSA.mad_tpsa_liebra! — Function
mad_tpsa_liebra!(na::Cint, ma, mb, mc)Computes the Lie bracket of the vector fields ma and mb, defined as sumi mai (dmb/dxi) - mbi (dma/dx_i).
Input
na– Length ofmaandmbma– Vector of TPSAmamb– Vector of TPSAmb
Output
mc– Destination vector of TPSAmc
GTPSA.mad_tpsa_log! — Function
mad_tpsa_log!(a::RealTPS, c::RealTPS)Sets TPSA c to the log of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = log(a)
GTPSA.mad_tpsa_logaxpsqrtbpcx2! — Function
mad_tpsa_logaxpsqrtbpcx2!(x::RealTPS, a::Cdouble, b::Cdouble, c::Cdouble, r::RealTPS)r = log(a*x + sqrt(b + c*x^2))
Input
x– TPSAxa– Scalarab– Scalarbc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_tpsa_logpb! — Function
mad_tpsa_logpb!(na::Cint, ma, mb, mc)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 ofmaandmbma– Vector of TPSAmamb– Vector of TPSAmb
Output
mc– Destination vector of TPSAmc
GTPSA.mad_tpsa_logxdy! — Function
mad_tpsa_logxdy!(x::RealTPS, y::RealTPS, r::RealTPS)r = log(x / y)
Input
x– TPSAxy– TPSAy
Output
r– Destination TPSAr
GTPSA.mad_tpsa_maxord! — Function
mad_tpsa_maxord!(t::RealTPS, n::Cint, idx_)::CintReturns 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– 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 tonwith maximum abs(coefficient)mi– Index to the monomial in the TPSA with maximum abs(coefficient)
GTPSA.mad_tpsa_mconv! — Function
mad_tpsa_mconv!(na::Cint, ma, nc::Cint, mc, n::Cint, t2r_, 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– mapmanc– Number of TPSAs in the output mapmcn– Length of vector (size oft2r_)t2r_– (Optional) Vector of index lookuppb– Poisson bracket, 0, 1:fwd, -1:bwd
Output
mc– mapmcwith specified conversions
GTPSA.mad_tpsa_minv! — Function
mad_tpsa_minv!(na::Cint, ma, nb::Cint, mc)Inverts the map. To include the parameters in the inversion, na = nn and the output map length only need be nb = nv.
Input
na– Input map length (should bennto include parameters)ma– Mapmanb– Output map length (generally =nv)
Output
mc– Inversion of mapma
GTPSA.mad_tpsa_mnrm — Function
mad_tpsa_mnrm(na::Cint, ma)::CdoubleComputes 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_tpsa_mo! — Function
mad_tpsa_mo!(t::RealTPS, mo::Cuchar)::CucharSets the maximum order mo of the TPSA t, and returns the original mo. mo should be less than or equal to the allocated order ao.
Input
t– TPSAmo– Maximum order to set the TPSA
Output
ret– Originalmoof the TPSA
GTPSA.mad_tpsa_mono! — Function
mad_tpsa_mono!(t::RealTPS, i::Cint, n::Cint, m_, p_)::CucharReturns 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 indexiin TPSAp_– (Optional) Order of parameters in monomialret– Order of monomial in TPSAat indexi
GTPSA.mad_tpsa_mord — Function
mad_tpsa_mord(na::Cint, ma, hi::Bool)::CucharIf hi is false, getting the maximum mo among all TPSAs in ma. If hi is true, gets the maximum hi of the map instead of mo
Input
na– Length of mapmama– Map (vector of TPSAs)hi– Iftrue, returns maximumhi, else returns maximummoof the map
Output
ret– Maximumhiof the map ifhiistrue, else returns maximummoof the map
GTPSA.mad_tpsa_mul! — Function
mad_tpsa_mul!(a::RealTPS, b::RealTPS, c::RealTPS)Sets the destination TPSA c = a * b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a * b
GTPSA.mad_tpsa_nam — Function
mad_tpsa_nam(t::RealTPS, nam_)::CstringGet the name of the TPSA, and will optionally set if nam_ != null
Input
t– TPSAnam_– Name to set the TPSA
Output
ret– Name of TPS{Float64} (null terminated in C)
GTPSA.mad_tpsa_new — Function
mad_tpsa_new(t::Ref{TPS{Float64}}, mo::Cuchar)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_tpsa_newd — Function
mad_tpsa_newd(d::Ptr{Desc}, mo::Cuchar)Creates a TPSA defined by the specified descriptor and maximum order. If MAD_TPSA_DEFAULT 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 TPSA defined by the descriptor
GTPSA.mad_tpsa_nrm — Function
mad_tpsa_nrm(a::RealTPS)::CdoubleCalculates the 1-norm of TPSA a (sum of abs of all coefficients)
Input
a– TPSA
Output
nrm– 1-Norm of TPSA
GTPSA.mad_tpsa_ord — Function
mad_tpsa_ord(t::RealTPS, hi_::Bool)::CucharGets the TPSA maximum order, or hi if hi_ is true.
Input
t– TPSAhi_– Settrueifhiis returned, elsemois returned
Output
ret– Order of TPSA
GTPSA.mad_tpsa_ordv — Function
mad_tpsa_ordv(t::RealTPS, ts::RealTPS...)::CucharReturns 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_tpsa_pminv! — Function
mad_tpsa_pminv!(na::Cint, ma, nb::Cint, mc, select)Computes the partial inverse of the map with only the selected variables, specified by 0s or 1s in select. To include the parameters in the inversion, na = nn and the output map length only need be nb = nv.
Input
na– Input map length (should bennto include parameters)ma– Mapmanb– Output map length (generally =nv)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_tpsa_poisbra! — Function
mad_tpsa_poisbra!(a::RealTPS, b::RealTPS, c::RealTPS, nv::Cint)Sets TPSA c to the poisson bracket of TPSAs a and b.
Input
a– Source TPSAab– Source TPSAbnv– Number of variables in the TPSA
Output
c– Destination TPSAc
GTPSA.mad_tpsa_pow! — Function
mad_tpsa_pow!(a::RealTPS, b::RealTPS, c::RealTPS)Sets the destination TPSA c = a ^ b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a ^ b
GTPSA.mad_tpsa_powi! — Function
mad_tpsa_powi!(a::RealTPS, n::Cint, c::RealTPS)Sets the destination TPSA c = a ^ n where n is an integer.
Input
a– Source TPSAan– Integer power
Output
c– Destination TPSAc = a ^ n
GTPSA.mad_tpsa_pown! — Function
mad_tpsa_pown!(a::RealTPS, v::Cdouble, c::RealTPS)Sets the destination TPSA c = a ^ v where v is of double precision.
Input
a– Source TPSAav– "double" precision power
Output
c– Destination TPSAc = a ^ v
GTPSA.mad_tpsa_print — Function
mad_tpsa_print(t::RealTPS, 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)FILEpointer of output stream. Default isstdout
GTPSA.mad_tpsa_scan — Function
mad_tpsa_scan(stream_::Ptr{Cvoid})::RealTPSScans 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_tpsa_scan_coef! — Function
mad_tpsa_scan_coef!(t::RealTPS, 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_tpsa_scan_hdr — Function
mad_tpsa_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_tpsa_scl! — Function
mad_tpsa_scl!(a::RealTPS, v::Cdouble, c::RealTPS)Sets TPSA c to v*a.
Input
a– Source TPSAav– Scalar with double precision
Output
c– Destination TPSAc = v*a
GTPSA.mad_tpsa_sclord! — Function
mad_tpsa_sclord!(t::RealTPS, r::RealTPS, inv::Bool, prm::Bool)Scales all coefficients by order. If inv == 0, scales coefficients by order (derivation), else scales coefficients by 1/order (integration).
Input
t– Source TPSAinv– Put order up, divide, scale byinvof 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 TPSA
GTPSA.mad_tpsa_seti! — Function
mad_tpsa_seti!(t::RealTPS, i::Cint, a::Cdouble, b::Cdouble)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_tpsa_setm! — Function
mad_tpsa_setm!(t::RealTPS, n::Cint, m, a::Cdouble, b::Cdouble)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_tpsa_setprm! — Function
mad_tpsa_setprm!(t::RealTPS, v::Cdouble, ip::Cint)Sets the 0th and 1st order values for the specified parameter, and sets the rest of the variables/parameters to 0. The 1st order value scl_ of a parameter is always 1.
Input
t– TPSAv– 0th order value (coefficient)ip– Parameter index (e.g. iv = 1 is nn-nv+1)
GTPSA.mad_tpsa_sets! — Function
mad_tpsa_sets!(t::RealTPS, n::Cint, s::Cstring, a::Cdouble, b::Cdouble)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_tpsa_setsm! — Function
mad_tpsa_setsm!(t::RealTPS, n::Cint, m, a::Cdouble, b::Cdouble)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_tpsa_setv! — Function
mad_tpsa_setv!(t::RealTPS, i::Cint, n::Cint, v)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 ativ– Array of coefficients for monomialsi..i+n
GTPSA.mad_tpsa_setval! — Function
mad_tpsa_setval!(t::RealTPS, v::Cdouble)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_tpsa_setvar! — Function
mad_tpsa_setvar!(t::RealTPS, v::Cdouble, iv::Cint, scl_::Cdouble)Sets the 0th and 1st order values for the specified variable, and sets the rest of the variables/parameters to 0
Input
t– TPSAv– 0th order value (coefficient)iv– Variable indexscl_– 1st order variable value (typically will be 1)
GTPSA.mad_tpsa_sin! — Function
mad_tpsa_sin!(a::RealTPS, c::RealTPS)Sets TPSA c to the sin of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = sin(a)
GTPSA.mad_tpsa_sinc! — Function
mad_tpsa_sinc!(a::RealTPS, c::RealTPS)Sets TPSA c to the sinc of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = sinc(a)
GTPSA.mad_tpsa_sincos! — Function
mad_tpsa_sincos!(a::RealTPS, s::RealTPS, c::RealTPS)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_tpsa_sincosh! — Function
mad_tpsa_sincosh!(a::RealTPS, s::RealTPS, c::RealTPS)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_tpsa_sinh! — Function
mad_tpsa_sinh!(a::RealTPS, c::RealTPS)Sets TPSA c to the sinh of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = sinh(a)
GTPSA.mad_tpsa_sinhc! — Function
mad_tpsa_sinhc!(a::RealTPS, c::RealTPS)Sets TPSA c to the sinhc of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = sinhc(a)
GTPSA.mad_tpsa_sqrt! — Function
mad_tpsa_sqrt!(a::RealTPS, c::RealTPS)Sets TPSA c to the sqrt of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = sqrt(a)
GTPSA.mad_tpsa_sub! — Function
mad_tpsa_sub!(a::RealTPS, b::RealTPS, c::RealTPS)Sets the destination TPSA c = a - b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a - b
GTPSA.mad_tpsa_tan! — Function
mad_tpsa_tan!(a::RealTPS, c::RealTPS)Sets TPSA c to the tan of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = tan(a)
GTPSA.mad_tpsa_tanh! — Function
mad_tpsa_tanh!(a::RealTPS, c::RealTPS)Sets TPSA c to the tanh of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = tanh(a)
GTPSA.mad_tpsa_taylor! — Function
mad_tpsa_taylor!(a::RealTPS, n::Cint, coef, c::RealTPS)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– TPSAan–Order-1of Taylor expansion, size ofcoefarraycoef– Array of coefficients in Taylorsc– Result
GTPSA.mad_tpsa_taylor_h! — Function
mad_tpsa_taylor_h!(a::RealTPS, n::Cint, coef, c::RealTPS)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.
Same as mad_tpsa_taylor, but uses Horner's method (which is 50%-100% slower because mul is always full order).
Input
a– TPSAan–Order-1of Taylor expansion, size ofcoefarraycoef– Array of coefficients in Taylorsc– Result
GTPSA.mad_tpsa_translate! — Function
mad_tpsa_translate!(na::Cint, ma, nb::Cint, tb, mc)Translates the expansion point of the map by the amount tb.
Input
na– Number of TPSAS in the mapma– mapmanb– Length oftbtb– Vector of amount to translate for each variable
Output
mc– Map evaluated at the new point translatedtbfrom the original evaluation point
GTPSA.mad_tpsa_uid! — Function
mad_tpsa_uid!(t::RealTPS, uid_::Cint)::CintSets the TPSA uid if uid_ != 0, and returns the current (previous if set) TPSA uid.
Input
t– TPSAuid_–uidto set in the TPSA ifuid_ != 0
Output
ret– Current (previous if set) TPSA uid
GTPSA.mad_tpsa_unit! — Function
mad_tpsa_unit!(a::RealTPS, c::RealTPS)Interpreting TPSA as a vector, gets the "unit vector", e.g. c = a/norm(a). May be useful for checking for convergence.
Input
a– Source TPSAa
Output
c– Destination TPSAc
GTPSA.mad_tpsa_update! — Function
mad_tpsa_update!(t::RealTPS)Updates the lo and hi fields of the TPSA to reflect the current state given the lowest/highest nonzero monomial coefficients.
GTPSA.mad_tpsa_vec2fld! — Function
mad_tpsa_vec2fld!(na::Cint, a::RealTPS, mc)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 inmcconsistent with number of variables inaa– Hamiltonian as a TPSA
Output
mc– Vector field derived fromausing Hamilton's equations
TPS{ComplexF64}
GTPSA.mad_ctpsa_acc! — Function
mad_ctpsa_acc!(a::ComplexTPS, v::ComplexF64, c::ComplexTPS)Adds a*v to TPSA c. Aliasing OK.
Input
a– Source TPSAav– Scalar with double precision
Output
c– Destination TPSAc += v*a
GTPSA.mad_ctpsa_acc_r! — Function
mad_ctpsa_acc_r!(a::ComplexTPS, v_re::Cdouble, v_im::Cdouble, c::ComplexTPS)Adds a*v to TPSA c. Aliasing OK. Without complex-by-value arguments.
Input
a– Source TPSAav_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! — Function
mad_ctpsa_acos!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the acos of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = acos(a)
GTPSA.mad_ctpsa_acosh! — Function
mad_ctpsa_acosh!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the acosh of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = acosh(a)
GTPSA.mad_ctpsa_acot! — Function
mad_ctpsa_acot!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the acot of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = acot(a)
GTPSA.mad_ctpsa_acoth! — Function
mad_ctpsa_acoth!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the acoth of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = acoth(a)
GTPSA.mad_ctpsa_add! — Function
mad_ctpsa_add!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)Sets the destination TPSA c = a + b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a + b
GTPSA.mad_ctpsa_addt! — Function
mad_ctpsa_addt!(a::ComplexTPS, b::RealTPS, c::ComplexTPS)Sets the destination TPS{ComplexF64} c = a + b (internal real-to-complex conversion).
Input
a– Source TPS{ComplexF64}ab– Source TPS{Float64}b
Output
c– Destination TPS{ComplexF64}c = a + b
GTPSA.mad_ctpsa_asin! — Function
mad_ctpsa_asin!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the asin of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = asin(a)
GTPSA.mad_ctpsa_asinc! — Function
mad_ctpsa_asinc!(a::ComplexTPS, c::ComplexTPS)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! — Function
mad_ctpsa_asinh!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the asinh of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = asinh(a)
GTPSA.mad_ctpsa_asinhc! — Function
mad_ctpsa_asinhc!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the asinhc of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = asinhc(a)
GTPSA.mad_ctpsa_atan! — Function
mad_ctpsa_atan!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the atan of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = atan(a)
GTPSA.mad_ctpsa_atanh! — Function
mad_ctpsa_atanh!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the atanh of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = atanh(a)
GTPSA.mad_ctpsa_ax2pby2pcz2! — Function
mad_ctpsa_ax2pby2pcz2!(a::ComplexF64, x::ComplexTPS, b::ComplexF64, y::ComplexTPS, c::ComplexF64, z::ComplexTPS, r::ComplexTPS)r = a*x^2 + b*y^2 + c*z^2
Input
a– Scalarax– TPSAxb– Scalarby– TPSAyc– Scalarcz– TPSAz
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_ax2pby2pcz2_r! — Function
mad_ctpsa_ax2pby2pcz2_r!(a_re::Cdouble, a_im::Cdouble, x::ComplexTPS, b_re::Cdouble, b_im::Cdouble, y::ComplexTPS, c_re::Cdouble, c_im::Cdouble, z::ComplexTPS, r::ComplexTPS)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 Scalaraa_im– Imag part of Scalarax– TPSAxb_re– Real part of Scalarbb_im– Imag part of Scalarby– TPSAyc_re– Real part of Scalarcc_im– Imag part of Scalarcz– TPSAz
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axpb! — Function
mad_ctpsa_axpb!(a::ComplexF64, x::ComplexTPS, b::ComplexF64, r::ComplexTPS)r = a*x + b
Input
a– Scalarax– TPSAxb– Scalarb
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axpb_r! — Function
mad_ctpsa_axpb_r!(a_re::Cdouble, a_im::Cdouble, x::ComplexTPS, b_re::Cdouble, b_im::Cdouble, r::ComplexTPS)r = a*x + b. Same as mad_ctpsa_axpb without complex-by-value arguments.
Input
a_re– Real part of Scalaraa_im– Imag part of Scalarax– TPSAxb_re– Real part of Scalarbb_im– Imag part of Scalarb
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axpbypc! — Function
mad_ctpsa_axpbypc!(a::ComplexF64, x::ComplexTPS, b::ComplexF64, y::ComplexTPS, c::ComplexF64, r::ComplexTPS)r = a*x+b*y+c
Input
a– Scalarax– TPSAxb– Scalarby– TPSAyc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axpbypc_r! — Function
mad_ctpsa_axpbypc_r!(a_re::Cdouble, a_im::Cdouble, x::ComplexTPS, b_re::Cdouble, b_im::Cdouble, y::ComplexTPS, c_re::Cdouble, c_im::Cdouble, r::ComplexTPS)r = a*x + b*y + c. Same as mad_ctpsa_axpbypc without complex-by-value arguments.
Input
a_re– Real part of Scalaraa_im– Imag part of Scalarax– TPSAxb_re– Real part of Scalarbb_im– Imag part of Scalarby– TPSAyc_re– Real part of Scalarcc_im– Imag part of Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axpsqrtbpcx2! — Function
mad_ctpsa_axpsqrtbpcx2!(x::ComplexTPS, a::ComplexF64, b::ComplexF64, c::ComplexF64, r::ComplexTPS)r = a*x + sqrt(b + c*x^2)
Input
x– TPSAxa– Scalarab– Scalarbc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axpsqrtbpcx2_r! — Function
mad_ctpsa_axpsqrtbpcx2_r!(x::ComplexTPS, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble, c_re::Cdouble, c_im::Cdouble, r::ComplexTPS)r = a*x + sqrt(b + c*x^2). Same as mad_ctpsa_axpsqrtbpcx2 without complex-by-value arguments.
Input
a_re– Real part of Scalaraa_im– Imag part of Scalarab_re– Real part of Scalarbb_im– Imag part of Scalarbc_re– Real part of Scalarcc_im– Imag part of Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axypb! — Function
mad_ctpsa_axypb!(a::ComplexF64, x::ComplexTPS, y::ComplexTPS, b::ComplexF64, r::ComplexTPS)r = a*x*y + b
Input
a– Scalarax– TPSAxy– TPSAyb– Scalarb
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axypb_r! — Function
mad_ctpsa_axypb_r!(a_re::Cdouble, a_im::Cdouble, x::ComplexTPS, y::ComplexTPS, b_re::Cdouble, b_im::Cdouble, r::ComplexTPS)r = a*x*y + b. Same as mad_ctpsa_axypb without complex-by-value arguments.
Input
a_re– Real part of Scalaraa_im– Imag part of Scalarax– TPSAxy– TPSAyb_re– Real part of Scalarbb_im– Imag part of Scalarb
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axypbvwpc! — Function
mad_ctpsa_axypbvwpc!(a::ComplexF64, x::ComplexTPS, y::ComplexTPS, b::ComplexF64, v::ComplexTPS, w::ComplexTPS, c::ComplexF64, r::ComplexTPS)r = a*x*y + b*v*w + c
Input
a– Scalarax– TPSAxy– TPSAyb– Scalarbv– TPSA vw– TPSA wc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axypbvwpc_r! — Function
mad_ctpsa_axypbvwpc_r!(a_re::Cdouble, a_im::Cdouble, x::ComplexTPS, y::ComplexTPS, b_re::Cdouble, b_im::Cdouble, v::ComplexTPS, w::ComplexTPS, c_re::Cdouble, c_im::Cdouble, r::ComplexTPS)r = a*x*y + b*v*w + c. Same as mad_ctpsa_axypbvwpc without complex-by-value arguments.
Input
a_re– Real part of Scalaraa_im– Imag part of Scalarax– TPSAxy– TPSAyb_re– Real part of Scalarbb_im– Imag part of Scalarbv– TPSA vw– TPSA wc_re– Real part of Scalarcc_im– Imag part of Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axypbzpc! — Function
mad_ctpsa_axypbzpc!(a::ComplexF64, x::ComplexTPS, y::ComplexTPS, b::ComplexF64, z::ComplexTPS, c::ComplexF64, r::ComplexTPS)r = a*x*y + b*z + c
Input
a– Scalarax– TPSAxy– TPSAyb– Scalarbz– TPSAzc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_axypbzpc_r! — Function
mad_ctpsa_axypbzpc_r!(a_re::Cdouble, a_im::Cdouble, x::ComplexTPS, y::ComplexTPS, b_re::Cdouble, b_im::Cdouble, z::ComplexTPS, c_re::Cdouble, c_im::Cdouble, r::ComplexTPS)r = a*x*y + b*z + c. Same as mad_ctpsa_axypbzpc without complex-by-value arguments.
Input
a_re– Real part of Scalaraa_im– Imag part of Scalarax– TPSAxy– TPSAyb_re– Real part of Scalarbb_im– Imag part of Scalarbz– TPSAzc_re– Real part of Scalarcc_im– Imag part of Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_cabs! — Function
mad_ctpsa_cabs!(t::ComplexTPS, r::RealTPS)Sets the TPS{Float64} r equal to the aboslute value of TPS{ComplexF64} t. Specifically, the result contains a TPSA with the abs of all coefficients.
Input
t– Source TPS{ComplexF64}
Output
r– Destination TPS{Float64} withr = |t|
GTPSA.mad_ctpsa_carg! — Function
mad_ctpsa_carg!(t::ComplexTPS, r::RealTPS)Sets the TPS{Float64} r equal to the argument (phase) of TPS{ComplexF64} t
Input
t– Source TPS{ComplexF64}
Output
r– Destination TPS{Float64} withr = carg(t)
GTPSA.mad_ctpsa_clear! — Function
mad_ctpsa_clear!(t::ComplexTPS)Clears the TPSA (reset to 0)
Input
t– Complex TPSA
GTPSA.mad_ctpsa_clrord! — Function
mad_ctpsa_clrord!(t::ComplexTPS, ord::Cuchar)Clears all monomial coefficients of the TPSA at order ord
Input
t– TPSAord– Order to clear monomial coefficients
GTPSA.mad_ctpsa_compose! — Function
mad_ctpsa_compose!(na::Cint, ma, nb::Cint, mb, mc)Composes two maps.
Input
na– Number of TPSAs in Mapmama– Mapmanb– Number of TPSAs in Mapmbmb– Mapmb
Output
mc– Composition of mapsmaandmb
GTPSA.mad_ctpsa_conj! — Function
mad_ctpsa_conj(a::ComplexTPS, c::ComplexTPS)Calculates the complex conjugate of of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = conj(a)
GTPSA.mad_ctpsa_convert! — Function
mad_ctpsa_convert!(t::ComplexTPS, r::ComplexTPS, n::Cint, t2r_, 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! — Function
mad_ctpsa_copy!(t::ComplexTPS, r::ComplexTPS)Makes a copy of the complex TPSA t to r.
Input
t– Source complex TPSA
Output
r– Destination complex TPSA
GTPSA.mad_ctpsa_cos! — Function
mad_ctpsa_cos!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the cos of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = cos(a)
GTPSA.mad_ctpsa_cosh! — Function
mad_ctpsa_cosh!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the cosh of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = cosh(a)
GTPSA.mad_ctpsa_cot! — Function
mad_ctpsa_cot!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the cot of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = cot(a)
GTPSA.mad_ctpsa_coth! — Function
mad_ctpsa_coth!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the coth of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = coth(a)
GTPSA.mad_ctpsa_cplx! — Function
mad_ctpsa_cplx!(re_, im_, r::ComplexTPS)Creates a TPS{ComplexF64} with real and imaginary parts from the TPS{Float64}s re_ and im_ respectively.
Input
re_– Real part of TPS{ComplexF64} to makeim_– Imaginary part of TPS{ComplexF64} to make
Output
r– Destination TPS{ComplexF64} withr = re_ + im*im_
GTPSA.mad_ctpsa_cpyi! — Function
mad_ctpsa_cpyi!(t::ComplexTPS, r::ComplexTPS, i::Cint)Copies the monomial coefficient at index i in t into the same monomial coefficient in r
Input
t– Source TPSAr– Destination TPSAi– Index of monomial
GTPSA.mad_ctpsa_cpym! — Function
mad_ctpsa_cpym!(t::ComplexTPS, r::ComplexTPS, n::Cint, m)Copies the monomial coefficient at the monomial-as-vector-of-orders m in t into the same monomial coefficient in r
Input
t– Source TPSAr– Destination TPSAn– Length of monomialmm– Monomial as vector of orders
GTPSA.mad_ctpsa_cpys! — Function
mad_ctpsa_cpys!(t::ComplexTPS, r::ComplexTPS, n::Cint, s::Cstring)Copies the monomial coefficient at the monomial-as-string-of-order s in t into the same monomial coefficient in r
Input
t– Source TPSAr– Destination TPSAn– Length of strings– Monomial as string
GTPSA.mad_ctpsa_cpysm! — Function
mad_ctpsa_cpysm!(t::ComplexTPS, r::ComplexTPS, n::Cint, m)Copies the monomial coefficient at the monomial-as-sparse-monomial m in t into the same monomial coefficient in r
Input
t– Source TPSAr– Destination TPSAn– Length of sparse monomialmm– Monomial as sparse-monomial
GTPSA.mad_ctpsa_cutord! — Function
mad_ctpsa_cutord!(t::ComplexTPS, r::ComplexTPS, 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..-ordorord..mo
Output
r– Destination complex TPSA
GTPSA.mad_ctpsa_cycle! — Function
mad_ctpsa_cycle!(t::ComplexTPS, i::Cint, n::Cint, m_, v_)::CintUsed 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 — Function
mad_ctpsa_debug(t::ComplexTPS, name_::Cstring, fnam_::Cstring, line_::Cint, stream_::Ptr{Cvoid})::CintPrints 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
Output
ret–Cintreflecting internal state of TPSA
GTPSA.mad_ctpsa_del! — Function
mad_ctpsa_del!(t::Ref{TPS{ComplexF64}})Calls the destructor for the complex TPSA.
Input
t– Complex TPSA to destruct
GTPSA.mad_ctpsa_density — Function
mad_ctpsa_density(t::ComplexTPS, stat_, reset::Bool)::CdoubleComputes the ratio of nz/nc in [0] U [lo,hi] or stat_
GTPSA.mad_ctpsa_deriv! — Function
mad_ctpsa_deriv!(a::ComplexTPS, c::ComplexTPS, 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! — Function
mad_ctpsa_derivm!(a::ComplexTPS, c::ComplexTPS, n::Cint, m)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 — Function
mad_ctpsa_desc(t::ComplexTPS)::Ptr{Desc}Gets the descriptor for the complex TPSA.
Input
t– Complex TPSA
Output
ret– Descriptor for the TPSA
GTPSA.mad_ctpsa_dif! — Function
mad_ctpsa_dif!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)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 TPSAab– Source TPSAb
Output
c– Destination TPSAc
GTPSA.mad_ctpsa_dift! — Function
mad_ctpsa_dift!(a::ComplexTPS, b::RealTPS, c::ComplexTPS)For each homogeneous polynomial in TPS{ComplexF64} a and TPS{Float64} 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 TPS{ComplexF64}ab– Source TPS{Float64}b
Output
c– Destination TPS{ComplexF64}c
GTPSA.mad_ctpsa_div! — Function
mad_ctpsa_div!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)Sets the destination TPSA c = a / b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a / b
GTPSA.mad_ctpsa_divt! — Function
mad_ctpsa_divt!(a::ComplexTPS, b::RealTPS, c::ComplexTPS)Sets the destination TPS{ComplexF64} c = a / b (internal real-to-complex conversion).
Input
a– Source TPS{ComplexF64}ab– Source TPS{Float64}b
Output
c– Destination TPS{ComplexF64}c = a / b
GTPSA.mad_ctpsa_equ — Function
mad_ctpsa_equ(a::ComplexTPS, b::ComplexTPS, tol_::Cdouble)::BoolChecks if each coefficient in the TPSAs a and b are equal within the specified absolute tolerance tol_.
Input
a– TPSAab– TPSAbtol_– (Optional) Difference below which the TPSAs are considered equal
Output
ret– True ifa == bwithintol_
GTPSA.mad_ctpsa_equt — Function
mad_ctpsa_equt(a::ComplexTPS, b::RealTPS, tol::Cdouble)::BoolChecks if the TPS{ComplexF64} a is equal to the TPS{Float64} b within the specified tolerance tol_ (internal real-to-complex conversion).
Input
a– TPS{ComplexF64}ab– TPS{Float64}btol_– (Optional) Difference below which the TPSAs are considered equal
Output
ret- True ifa == bwithintol_
GTPSA.mad_ctpsa_erf! — Function
mad_ctpsa_erf!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the erf of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = erf(a)
GTPSA.mad_ctpsa_erfc! — Function
mad_ctpsa_erfc!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the erfc of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = erfc(a)
GTPSA.mad_ctpsa_eval! — Function
mad_ctpsa_eval!(na::Cint, ma, nb::Cint, tb, tc)Evaluates the map at the point tb
Input
na– Number of TPSAs in the mapma– Mapmanb– Length oftbtb– Point at which to evaluate the map
Output
tc– Values for each TPSA in the map evaluated at the pointtb
GTPSA.mad_ctpsa_exp! — Function
mad_ctpsa_exp!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the exp of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = exp(a)
GTPSA.mad_ctpsa_exppb! — Function
mad_ctpsa_exppb!(na::Cint, ma, nb, mb, mc)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 ofmama– Vector of TPSAmanb– Length ofmbmb– Vector of TPSAmb
Output
mc– Destination vector of TPSAmc
GTPSA.mad_ctpsa_fgrad! — Function
mad_ctpsa_fgrad!(na::Cint, ma, b::ComplexTPS, c::ComplexTPS)Calculates dot(ma, grad(b))
Input
na– Length ofmaconsistent with number of variables inbma– Vector of TPSAb– TPSA
Output
c–dot(ma, grad(b))
GTPSA.mad_ctpsa_fld2vec! — Function
mad_ctpsa_fld2vec!(na::Cint, ma, c::ComplexTPS)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 inmaconsistent with number of variables incma– Vector field
Output
c– Hamiltonian as a TPSA derived from the vector fieldma
GTPSA.mad_ctpsa_geti — Function
mad_ctpsa_geti(t::ComplexTPS, i::Cint)::ComplexF64Gets 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! — Function
mad_ctpsa_geti_r!(t::ComplexTPS, i::Cint, r)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 — Function
mad_ctpsa_getm(t::ComplexTPS, n::Cint, m)::ComplexF64Gets 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 monomialmin TPSA
GTPSA.mad_ctpsa_getm_r! — Function
mad_ctpsa_getm_r!(t::ComplexTPS, n::Cint, m, r)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 monomialmin TPSA
GTPSA.mad_ctpsa_getord! — Function
mad_ctpsa_getord!(t::ComplexTPS, r::ComplexTPS, 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 — Function
mad_ctpsa_gets(t::ComplexTPS, n::Cint, s::Cstring)::ComplexF64Gets 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 monomialsin TPSA
GTPSA.mad_ctpsa_gets_r! — Function
mad_ctpsa_gets_r!(t::ComplexTPS, n::Cint, s::Cstring, r)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 monomialsin TPSA
GTPSA.mad_ctpsa_getsm — Function
mad_ctpsa_getsm(t::ComplexTPS, n::Cint, m)::ComplexF64Gets 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 monomialmin TPSA
GTPSA.mad_ctpsa_getsm_r! — Function
mad_ctpsa_getsm_r!(t::ComplexTPS, n::Cint, m, r)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 monomialmin TPSA
GTPSA.mad_ctpsa_getv! — Function
mad_ctpsa_getv!(t::ComplexTPS, i::Cint, n::Cint, v)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! — Function
mad_ctpsa_hypot!(x::ComplexTPS, y::ComplexTPS, r::ComplexTPS)Sets TPSA r to sqrt(real(x)^2+real(y)^2) + im*sqrt(imag(x)^2+imag(y)^2)
Input
x– Source TPSAxy– Source TPSAy
Output
r– Destination TPSAsqrt(real(x)^2+real(y)^2) + im*sqrt(imag(x)^2+imag(y)^2)
GTPSA.mad_ctpsa_hypot3! — Function
mad_ctpsa_hypot3!(x::ComplexTPS, y::ComplexTPS, z::ComplexTPS, r::ComplexTPS)Sets TPSA r to sqrt(x^2+y^2+z^2). Does NOT allow for r = x, y, z !!!
Input
x– Source TPSAxy– Source TPSAyz– Source TPSAz
Output
r– Destination TPSAr = sqrt(x^2+y^2+z^2)
GTPSA.mad_ctpsa_idxm — Function
mad_ctpsa_idxm(t::ComplexTPS, n::Cint, m)::CintReturns 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 — Function
mad_ctpsa_idxs(t::ComplexTPS, n::Cint, s::Cstring)::CintReturns 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 — Function
mad_ctpsa_idxsm(t::ComplexTPS, n::Cint, m)::CintReturns 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! — Function
mad_ctpsa_imag!(t::ComplexTPS, r::RealTPS)Sets the TPS{Float64} r equal to the imaginary part of TPS{ComplexF64} t.
Input
t– Source TPS{ComplexF64}
Output
r– Destination TPS{Float64} withr = Im(t)
GTPSA.mad_ctpsa_init! — Function
mad_ctpsa_init(t::ComplexTPS, d::Ptr{Desc}, mo::Cuchar)::ComplexTPSUnsafe 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 descriptordd– Descriptormo– Maximum order of the TPSA (must be less than maximum order of the descriptor)
Output
t– TPSA initialized to descriptordwith maximum ordermo
GTPSA.mad_ctpsa_integ! — Function
mad_ctpsa_integ!(a::ComplexTPS, c::ComplexTPS, 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! — Function
mad_ctpsa_inv!(a::ComplexTPS, v::ComplexF64, c::ComplexTPS)Sets TPSA c to v/a.
Input
a– Source TPSAav– Scalar with double precision
Output
c– Destination TPSAc = v/a
GTPSA.mad_ctpsa_inv_r! — Function
mad_ctpsa_inv_r!(a::ComplexTPS, v_re::Cdouble, v_im::Cdouble, c::ComplexTPS)Sets TPSA c to v/a. Without complex-by-value arguments.
Input
a– Source TPSAav_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! — Function
mad_ctpsa_invsqrt!(a::ComplexTPS, v::ComplexF64, c::ComplexTPS)Sets TPSA c to v/sqrt(a).
Input
a– Source TPSAav– Scalar with double precision
Output
c– Destination TPSAc = v/sqrt(a)
GTPSA.mad_ctpsa_invsqrt_r! — Function
mad_ctpsa_invsqrt_r!(a::ComplexTPS, v_re::Cdouble, v_im::Cdouble, c::ComplexTPS)Sets TPSA c to v/sqrt(a). Without complex-by-value arguments.
Input
a– Source TPSAav_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 — Function
mad_ctpsa_isnul(t::ComplexTPS)::BoolChecks if TPSA is 0 or not
Input
t– Complex TPSA to check
Output
ret– True or false
GTPSA.mad_ctpsa_isval — Function
mad_ctpsa_isval(t::ComplexTPS)::BoolSanity check of the TPSA integrity.
Input
t– TPSA to check if valid
Output
ret– True if valid TPSA, false otherwise
GTPSA.mad_ctpsa_isvalid — Function
mad_ctpsa_isvalid(t::ComplexTPS)::BoolSanity 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 — Function
mad_ctpsa_len(t::ComplexTPS, hi_::Bool)::CintGets the length of the TPSA itself (e.g. the descriptor may be order 10 but TPSA may only be order 2)
Input
t– Complex TPSAhi_– Iftrue, returns the length up to thehiorder in the TPSA, else up tomo. Default is false
Output
ret– Length of TPS{ComplexF64}
GTPSA.mad_ctpsa_liebra! — Function
mad_ctpsa_liebra!(na::Cint, ma, mb, mc)Computes the Lie bracket of the vector fields ma and mb, defined as sumi mai (dmb/dxi) - mbi (dma/dx_i).
Input
na– Length ofmaandmbma– Vector of TPSAmamb– Vector of TPSAmb
Output
mc– Destination vector of TPSAmc
GTPSA.mad_ctpsa_log! — Function
mad_ctpsa_log!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the log of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = log(a)
GTPSA.mad_ctpsa_logaxpsqrtbpcx2! — Function
mad_ctpsa_logaxpsqrtbpcx2!(x::ComplexTPS, a::ComplexF64, b::ComplexF64, c::ComplexF64, r::ComplexTPS)r = log(a*x + sqrt(b + c*x^2))
Input
x– TPSAxa– Scalarab– Scalarbc– Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_logaxpsqrtbpcx2_r! — Function
mad_ctpsa_logaxpsqrtbpcx2_r!(x::ComplexTPS, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble, c_re::Cdouble, c_im::Cdouble, r::ComplexTPS)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 Scalaraa_im– Imag part of Scalarab_re– Real part of Scalarbb_im– Imag part of Scalarbc_re– Real part of Scalarcc_im– Imag part of Scalarc
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_logpb! — Function
mad_ctpsa_logpb!(na::Cint, ma, mb, mc)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 ofmaandmbma– Vector of TPSAmamb– Vector of TPSAmb
Output
mc– Destination vector of TPSAmc
GTPSA.mad_ctpsa_logxdy! — Function
mad_ctpsa_logxdy!(x::ComplexTPS, y::ComplexTPS, r::ComplexTPS)r = log(x / y)
Input
x– TPSAxy– TPSAy
Output
r– Destination TPSAr
GTPSA.mad_ctpsa_maxord — Function
mad_ctpsa_maxord(t::ComplexTPS, n::Cint, idx_)::CintReturns 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 tonwith maximum abs(coefficient)mi– Index to the monomial in the TPSA with maximum abs(coefficient)
GTPSA.mad_ctpsa_mconv! — Function
mad_ctpsa_mconv!(na::Cint, ma, nc::Cint, mc, n::Cint, t2r_, 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– Mapmanc– Number of TPSAs in the output mapmcn– Length of vector (size oft2r_)t2r_– (Optional) Vector of index lookuppb– Poisson bracket, 0, 1:fwd, -1:bwd
Output
mc– Mapmcwith specified conversions
GTPSA.mad_ctpsa_minv! — Function
mad_ctpsa_minv!(na::Cint, ma, nb::Cint, mc)Inverts the map. To include the parameters in the inversion, na = nn and the output map length only need be nb = nv.
Input
na– Input map length (should bennto include parameters)ma– Mapmanb– Output map length (generally =nv)
Output
mc– Inversion of mapma
GTPSA.mad_ctpsa_mnrm — Function
mad_ctpsa_mnrm(na::Cint, ma)::CdoubleComputes 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_mo! — Function
mad_ctpsa_mo!(t::ComplexTPS, mo::Cuchar)::CucharSets the maximum order mo of the TPSA t, and returns the original mo. mo should be less than or equal to the allocated order ao.
Input
t– TPSAmo– Maximum order to set the TPSA
Output
ret– Originalmoof the TPSA
GTPSA.mad_ctpsa_mono! — Function
mad_ctpsa_mono!(t::ComplexTPS, i::Cint, n::Cint, m_, p_)::CucharReturns 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 indexiin TPSAp_– (Optional) Order of parameters in monomialret– Order of monomial in TPSAaindexi
GTPSA.mad_ctpsa_mord — Function
mad_ctpsa_mord(na::Cint, ma, hi::Bool)::CucharIf hi is false, getting the maximum mo among all TPSAs in ma. If hi is true, gets the maximum hi of the map instead of mo
Input
na– Length of mapmama– Map (vector of TPSAs)hi– Iftrue, returns maximumhi, else returns maximummoof the map
Output
ret– Maximumhiof the map ifhiistrue, else returns maximummoof the map
GTPSA.mad_ctpsa_mul! — Function
mad_ctpsa_mul!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)Sets the destination TPSA c = a * b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a * b
GTPSA.mad_ctpsa_mult! — Function
mad_ctpsa_mult!(a::ComplexTPS, b::RealTPS, c::ComplexTPS)Sets the destination TPS{ComplexF64} c = a * b (internal real-to-complex conversion).
Input
a– Source TPS{ComplexF64}ab– Source TPS{Float64}b
Output
c– Destination TPS{ComplexF64}c = a * b
GTPSA.mad_ctpsa_nam — Function
mad_ctpsa_nam(t::ComplexTPS, nam_::Cstring)::CstringGet the name of the TPSA, and will optionally set if nam_ != null
Input
t– TPSAnam_– Optional name to set the TPSA
Output
ret– Name of TPS{ComplexF64} (Null terminated in C)
GTPSA.mad_ctpsa_new — Function
mad_ctpsa_new(t::Ref{TPS{ComplexF64}}, mo::Cuchar)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 — Function
mad_ctpsa_newd(d::Ptr{Desc}, mo::Cuchar)Creates a complex TPSA defined by the specified descriptor and maximum order. If MADTPS{ComplexF64}DEFAULT 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 — Function
mad_ctpsa_nrm(a::ComplexTPS)::CdoubleCalculates 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 — Function
mad_ctpsa_ord(t::ComplexTPS, hi_::Bool)::CucharGets the TPSA maximum order, or hi if hi_ is true.
Input
t– TPSAhi_– Settrueifhiis returned, elsemois returned
Output
ret– Order of TPSA
GTPSA.mad_ctpsa_ordv — Function
mad_ctpsa_ordv(t::ComplexTPS, ts::ComplexTPS...)::CucharReturns 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! — Function
mad_ctpsa_pminv!(na::Cint, ma, nb::Cint, mc, select)Computes the partial inverse of the map with only the selected variables, specified by 0s or 1s in select. To include the parameters in the inversion, na = nn and the output map length only need be nb = nv.
Input
na– Input map length (should bennto include parameters)ma– Mapmanb– Output map length (generally =nv)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! — Function
mad_ctpsa_poisbra!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS, nv::Cint)Sets TPSA c to the poisson bracket of TPSAs a and b.
Input
a– Source TPSAab– Source TPSAbnv– Number of variables in the TPSA
Output
c– Destination TPSAc
GTPSA.mad_ctpsa_poisbrat! — Function
mad_ctpsa_poisbrat!(a::ComplexTPS, b::RealTPS, c::ComplexTPS, nv::Cint)Sets TPSA c to the poisson bracket of TPS{ComplexF64} aand TPS{Float64} b (internal real-to-complex conversion).
Input
a– Source TPS{ComplexF64}ab– Source TPS{Float64}bnv– Number of variables in the TPSA
Output
c– Destination TPS{ComplexF64}c
GTPSA.mad_ctpsa_polar! — Function
mad_ctpsa_polar!(t::ComplexTPS, r::ComplexTPS)Sets r = |t| + im*atan2(Im(t), Re(t))
Input
t– Source TPS{ComplexF64}r– Destination TPS{ComplexF64}
GTPSA.mad_ctpsa_pow! — Function
mad_ctpsa_pow!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)Sets the destination TPSA c = a ^ b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a ^ b
GTPSA.mad_ctpsa_powi! — Function
mad_ctpsa_powi!(a::ComplexTPS, n::Cint, c::ComplexTPS)Sets the destination TPSA c = a ^ n where n is an integer.
Input
a– Source TPSAan– Integer power
Output
c– Destination TPSAc = a ^ n
GTPSA.mad_ctpsa_pown! — Function
mad_ctpsa_pown!(a::ComplexTPS, v::ComplexF64, c::ComplexTPS)Sets the destination TPSA c = a ^ v where v is of double precision.
Input
a– Source TPSAav– Power, ComplexF64
Output
c– Destination TPSAc = a ^ v
GTPSA.mad_ctpsa_pown_r! — Function
mad_ctpsa_pown_r!(a::ComplexTPS, v_re::Cdouble, v_im::Cdouble, c::ComplexTPS)Sets the destination TPSA c = a ^ v where v is of double precision. Without complex-by-value arguments.
Input
a– Source TPSAav_re– Real part of powerv_im– Imaginary part of power
Output
c– Destination TPSAc = a ^ v
GTPSA.mad_ctpsa_powt! — Function
mad_ctpsa_powt!(a::ComplexTPS, b::RealTPS, c::ComplexTPS)Sets the destination TPS{ComplexF64} c = a ^ b (internal real-to-complex conversion).
Input
a– Source TPS{ComplexF64}ab– Source TPS{Float64}b
Output
c– Destination TPS{ComplexF64}c = a ^ b
GTPSA.mad_ctpsa_print — Function
mad_ctpsa_print(t::ComplexTPS, name_ 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)FILEpointer of output stream. Default isstdout
GTPSA.mad_ctpsa_real! — Function
mad_ctpsa_real!(t::ComplexTPS, r::RealTPS)Sets the TPS{Float64} r equal to the real part of TPS{ComplexF64} t.
Input
t– Source TPS{ComplexF64}
Output
r– Destination TPS{Float64} withr = Re(t)
GTPSA.mad_ctpsa_rect! — Function
mad_ctpsa_rect!(t::ComplexTPS, r::ComplexTPS)Sets r = Re(t)*cos(Im(t)) + im*Re(t)*sin(Im(t))
Input
t– Source TPS{ComplexF64}r– Destination TPS{ComplexF64}
GTPSA.mad_ctpsa_scan — Function
mad_ctpsa_scan(stream_::Ptr{Cvoid})::ComplexTPSScans 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! — Function
mad_ctpsa_scan_coef!(t::ComplexTPS, 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 — Function
mad_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! — Function
mad_ctpsa_scl!(a::ComplexTPS, v::ComplexF64, c::ComplexTPS)Sets TPSA c to v*a.
Input
a– Source TPSAav– Scalar with double precision
Output
c– Destination TPSAc = v*a
GTPSA.mad_ctpsa_scl_r! — Function
mad_ctpsa_scl_r!(a::ComplexTPS, v_re::Cdouble, v_im::Cdouble,, c::ComplexTPS)Sets TPSA c to v*a. Without complex-by-value arguments.
Input
a– Source TPSAav_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! — Function
mad_ctpsa_sclord!(t::ComplexTPS, r::ComplexTPS, inv::Bool, prm::Bool)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 byinvof 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_seti! — Function
mad_ctpsa_seti!(t::ComplexTPS, 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! — Function
mad_ctpsa_seti_r!(t::ComplexTPS, 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 ofaa_im– Imaginary part ofab_re– Real part ofbb_im– Imaginary part ofb
GTPSA.mad_ctpsa_setm! — Function
mad_ctpsa_setm!(t::ComplexTPS, n::Cint, m, 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! — Function
mad_ctpsa_setm_r!(t::ComplexTPS, n::Cint, m, 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 ofaa_im– Imaginary part ofab_re– Real part ofbb_im– Imaginary part ofb
GTPSA.mad_ctpsa_setprm! — Function
mad_ctpsa_setprm!(t::ComplexTPS, v::ComplexF64, ip::Cint)Sets the 0th and 1st order values for the specified parameter, and sets the rest of the variables/parameters to 0. The 1st order value scl_ of a parameter is always 1.
Input
t– TPSAv– 0th order value (coefficient)ip– Parameter index (e.g. iv = 1 is nn-nv+1)
GTPSA.mad_ctpsa_setprm_r! — Function
mad_ctpsa_setprm_r!(t::ComplexTPS, v_re::Cdouble, v_im::Cdouble, ip::Cint)Sets the 0th and 1st order values for the specified parameter. Equivalent to mad_ctpsa_setprm but without complex-by-value arguments. The 1st order value scl_ of a parameter is always 1.
Input
t– Complex TPSAv_re– Real part of 0th order valuev_im– Imaginary part of 0th order valueip– Parameter index
GTPSA.mad_ctpsa_sets! — Function
mad_ctpsa_sets!(t::ComplexTPS, 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! — Function
mad_ctpsa_sets_r!(t::ComplexTPS, 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 ofaa_im– Imaginary part ofab_re– Real part ofbb_im– Imaginary part ofb
GTPSA.mad_ctpsa_setsm! — Function
mad_ctpsa_setsm!(t::ComplexTPS, n::Cint, m, 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! — Function
mad_ctpsa_setsm_r!(t::ComplexTPS, n::Cint, m, 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 ofaa_im– Imaginary part ofab_re– Real part ofbb_im– Imaginary part ofb
GTPSA.mad_ctpsa_setv! — Function
mad_ctpsa_setv!(t::ComplexTPS, i::Cint, n::Cint, v)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 ativ– Array of coefficients for monomialsi..i+n
GTPSA.mad_ctpsa_setval! — Function
mad_ctpsa_setval!(t::ComplexTPS, 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! — Function
mad_ctpsa_setval_r!(t::ComplexTPS, 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! — Function
madctpsasetvar!(t::ComplexTPS, v::ComplexF64, iv::Cint, scl_::ComplexF64)
Sets the 0th and 1st order values for the specified variable, and sets the rest of the variables to 0
Input
t– TPSAv– 0th order value (coefficient)iv– Variable indexscl_– 1st order variable value (typically will be 1)
GTPSA.mad_ctpsa_setvar_r! — Function
mad_ctpsa_setvar_r!(t::ComplexTPS, v_re::Cdouble, v_im::Cdouble, iv::Cint, scl_re_::Cdouble, scl_im_::Cdouble)Sets the 0th and 1st order values for the specified variable. 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– Variable indexscl_re_– (Optional) Real part of 1st order variable valuescl_im_– (Optional)Imaginary part of 1st order variable value
GTPSA.mad_ctpsa_sin! — Function
mad_ctpsa_sin!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the sin of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = sin(a)
GTPSA.mad_ctpsa_sinc! — Function
mad_ctpsa_sinc!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the sinc of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = sinc(a)
GTPSA.mad_ctpsa_sincos! — Function
mad_ctpsa_sincos!(a::ComplexTPS, s::ComplexTPS, c::ComplexTPS)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! — Function
mad_ctpsa_sincosh!(a::ComplexTPS, s::ComplexTPS, c::ComplexTPS)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! — Function
mad_ctpsa_sinh!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the sinh of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = sinh(a)
GTPSA.mad_ctpsa_sinhc! — Function
mad_ctpsa_sinhc!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the sinhc of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = sinhc(a)
GTPSA.mad_ctpsa_sqrt! — Function
mad_ctpsa_sqrt!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the sqrt of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = sqrt(a)
GTPSA.mad_ctpsa_sub! — Function
mad_ctpsa_sub!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)Sets the destination TPSA c = a - b
Input
a– Source TPSAab– Source TPSAb
Output
c– Destination TPSAc = a - b
GTPSA.mad_ctpsa_subt! — Function
mad_ctpsa_subt!(a::ComplexTPS, b::RealTPS, c::ComplexTPS)Sets the destination TPS{ComplexF64} c = a - b (internal real-to-complex conversion).
Input
a– Source TPS{ComplexF64}ab– Source TPS{Float64}b
Output
c– Destination TPS{ComplexF64}c = a - b
GTPSA.mad_ctpsa_tan! — Function
mad_ctpsa_tan!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the tan of TPSA a.
Input
a– Source TPSAa
Output
c– Destination TPSAc = tan(a)
GTPSA.mad_ctpsa_tanh! — Function
mad_ctpsa_tanh!(a::ComplexTPS, c::ComplexTPS)Sets TPSA c to the tanh of TPSA a
Input
a– Source TPSAa
Output
c– Destination TPSAc = tanh(a)
GTPSA.mad_ctpsa_taylor! — Function
mad_ctpsa_taylor!(a::ComplexTPS, n::Cint, coef, c::ComplexTPS)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– TPSAan–Order-1of Taylor expansion, size ofcoefarraycoef– Array of coefficients in Taylorsc– Result
GTPSA.mad_ctpsa_taylor_h! — Function
mad_ctpsa_taylor_h!(a::ComplexTPS, n::Cint, coef, c::ComplexTPS)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.
Same as mad_ctpsa_taylor, but uses Horner's method (which is 50%-100% slower because mul is always full order).
Input
a– TPSAan–Order-1of Taylor expansion, size ofcoefarraycoef– Array of coefficients in Taylorsc– Result
GTPSA.mad_ctpsa_tdif! — Function
mad_ctpsa_tdif!(a::RealTPS, b::ComplexTPS, c::ComplexTPS)For each homogeneous polynomial in TPS{Float64} a and TPS{ComplexF64} 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 TPS{Float64}ab– Source TPS{ComplexF64}b
Output
c– Destination TPS{ComplexF64}c
GTPSA.mad_ctpsa_tdiv! — Function
mad_ctpsa_tdiv!(a::RealTPS, b::ComplexTPS, c::ComplexTPS)Sets the destination TPS{ComplexF64} c = a / b (internal real-to-complex conversion).
Input
a– Source TPS{Float64}ab– Source TPS{ComplexF64}b
Output
c– Destination TPS{ComplexF64}c = a / b
GTPSA.mad_ctpsa_tpoisbra! — Function
mad_ctpsa_tpoisbra!(a::RealTPS, b::ComplexTPS, c::ComplexTPS, nv::Cint)Sets TPSA c to the poisson bracket of TPS{Float64} a and TPS{ComplexF64} b (internal real-to-complex conversion).
Input
a– Source TPS{Float64}ab– Source TPS{ComplexF64}bnv– Number of variables in the TPSA
Output
c– Destination TPS{ComplexF64}c
GTPSA.mad_ctpsa_tpow! — Function
mad_ctpsa_tpow!(a::RealTPS, b::ComplexTPS, c::ComplexTPS)Sets the destination TPS{ComplexF64} c = a ^ b (internal real-to-complex conversion).
Input
a– Source TPS{Float64}ab– Source TPS{ComplexF64}b
Output
c– Destination TPSAc = a ^ b
GTPSA.mad_ctpsa_translate! — Function
mad_ctpsa_translate!(na::Cint, ma, nb::Cint, tb, mc)Translates the expansion point of the map by the amount tb.
Input
na– Number of TPSAS in the mapma– Mapmanb– Length oftbtb– Vector of amount to translate for each variable
Output
mc– Map evaluated at the new point translatedtbfrom the original evaluation point
GTPSA.mad_ctpsa_tsub! — Function
mad_ctpsa_tsub!(a::RealTPS, b::ComplexTPS, c::ComplexTPS)Sets the destination TPS{ComplexF64} c = a - b (internal real-to-complex conversion).
Input
a– Source TPS{Float64}ab– Source TPS{ComplexF64}b
Output
c– Destination TPS{ComplexF64}c = a - b
GTPSA.mad_ctpsa_uid! — Function
mad_ctpsa_uid!(t::ComplexTPS, uid_::Cint)::CintSets the TPSA uid if uid_ != 0, and returns the current (previous if set) TPSA uid.
Input
t– Complex TPSAuid_–uidto set in the TPSA ifuid_ != 0
Output
ret– Current (previous if set) TPSAuid
GTPSA.mad_ctpsa_unit! — Function
mad_ctpsa_unit!(a::ComplexTPS, c::ComplexTPS)Interpreting TPSA as a vector, gets the "unit vector", e.g. c = a/norm(a). May be useful for checking for convergence.
Input
a– Source TPSAa
Output
c– Destination TPSAc
GTPSA.mad_ctpsa_update! — Function
mad_ctpsa_update!(t::ComplexTPS)Updates the lo and hi fields of the TPSA to reflect the current state given the lowest/highest nonzero monomial coefficients.
GTPSA.mad_ctpsa_vec2fld! — Function
mad_ctpsa_vec2fld!(na::Cint, a::ComplexTPS, mc)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 inmcconsistent with number of variables inaa– Hamiltonian as a TPSA
Output
mc– Vector field derived fromausing Hamilton's equations