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 GTPSA
julia> import GTPSA: Desc
julia> d = Descriptor(5,8)GTPSA Descriptor ----------------------- # Variables: 5 Maximum order: 8
julia> desc = unsafe_load(d.desc) # To access the low-level C structGTPSA.Desc(0, 5, 5, 0, 0x08, 0x00, Ptr{UInt8} @0x00000000020402b8, 0, 4, 0x00000507, 0x00000000, 0x00000000, Ptr{Int32} @0x00000000027b1e38, Ptr{UInt8} @0x00000000025df7c8, Ptr{UInt8} @0x0000000001b91538, Ptr{UInt8} @0x0000000002ee6438, Ptr{Ptr{UInt8}} @0x0000000002920c88, Ptr{Ptr{UInt8}} @0x0000000002b6ed98, Ptr{Ptr{UInt8}} @0x00000000025074e8, Ptr{Int32} @0x0000000001ffadb8, Ptr{Int32} @0x0000000001ed5308, Ptr{Int32} @0x000000000236b008, Ptr{Int32} @0x0000000002b18178, Ptr{Ptr{Int32}} @0x0000000001e213b8, Ptr{Ptr{Ptr{Int32}}} @0x000000000281dfb8, 0x0000000000022195, Ptr{Ptr{Nothing}} @0x00000000029fe458, Ptr{Ptr{Nothing}} @0x00000000027b4bd8, Ptr{Int32} @0x0000000002077d18, Ptr{Int32} @0x00000000027b0478)
julia> t_jl = unsafe_load(Base.unsafe_convert(Ptr{Ptr{TPS{Float64}}}, desc.t), 1) # 1 in Julia = 0 in CPtr{TPS64} @0x0000000002db6b68

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.TempTPSType
struct TempTPS{T<:Union{Float64,ComplexF64}}

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}} – Pointer to the TPS in the buffer in the Descriptor
source

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. sinGTPSA.__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 pointer-to-pointers

All of the GTPSA map functions required a vector of TPS as input, in C **tpsa. In Julia, this works automatically for Vector{<:Union{TPS64,ComplexTPS64}} by specifying the C argument type in the C call as ::Ptr{TPS64} or ::Ptr{ComplexTPS64}. However, in some cases, one might have only a single TPS64 and would like the call the corresponding map function without having to allocate an array. After some experimenting, I've found the following solution to have zero allocations, using compose! as an example:

mad_compose!(na, ma::TPS64, nb, mb::AbstractVector{TPS64}, mc::TPS64) = GC.@preserve ma mc @ccall MAD_TPSA.mad_tpsa_compose(Cint(na)::Cint, Ref(pointer_from_objref(ma))::Ptr{Cvoid}, Cint(nb)::Cint, mb::Ptr{TPS64}, Ref(pointer_from_objref(mc))::Ptr{Cvoid})::Cvoid

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::Vector{Cuchar}, b::Vector{Cuchar}, r::Vector{Cuchar})

Sets monomial r = a + b.

Input

  • n – Length of monomials
  • a – Source monomial a
  • b – Source monomial b

Output

  • r – Destination monomial, r = a + b
source
GTPSA.mad_mono_cat!Function
mad_mono_cat!(n::Cint, a::Vector{Cuchar}, m::Cint, b::Vector{Cuchar}, r::Vector{Cuchar})

Sets monomial r equal to the concatenation of the monomials a and b

Input

  • n – Length of monomonial a
  • a – Source monomial a
  • m – Length of monomial b
  • b – Source monomial b

Output

  • r – Destination monomial of concatenation of a and b (length n+m)
source
GTPSA.mad_mono_cmpFunction
mad_mono_cmp(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Cint

Compares monomial a to monomial b, and returns the first difference in the lowest order variables.

Input

  • n – Length of monomials
  • a – Monomial a
  • b – Monomial b

Output

  • ret – First a[i]-b[i] != 0
source
GTPSA.mad_mono_copy!Function
mad_mono_copy!(n::Cint, a::Vector{Cuchar}, r::Vector{Cuchar})

Copies monomial a to monomial r.

Input

  • n – Length of monomials
  • a – Source monomial
  • r – Destination monomial
source
GTPSA.mad_mono_eqFunction
mad_mono_eq(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Bool

Checks if the monomial a is equal to the monomial b.

Input

  • n – Length of monomials
  • a – Monomial a
  • b – Monomial b

Output

  • ret – True if the monomials are equal, false if otherwise
source
GTPSA.mad_mono_fill!Function
mad_mono_fill!(n::Cint, a::Vector{Cuchar}, v::Cuchar)

Fills the monomial a with the value v.

Input

  • n – Monomial length
  • a – Monomial
  • v – Value
source
GTPSA.mad_mono_leFunction
mad_mono_le(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Bool

Checks if monomial a is less than or equal to monomial b.

Input

  • n – Length of monomials
  • a – Monomial a
  • b – Monomial b

Output

  • ret – True if a <= mono_b, false otherwise
source
GTPSA.mad_mono_ltFunction
mad_mono_lt(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Bool

Checks if monomial a is less than monomial b.

Input

  • n – Length of monomials
  • a – Monomial a
  • b – Monomial b

Output

  • ret – True if a < b, false otherwise
source
GTPSA.mad_mono_maxFunction
mad_mono_max(n::Cint, a::Vector{Cuchar})::Cuchar

Returns the maximum order of the monomial.

Input

  • n – Length of monomial
  • a – Monomial

Output

  • mo – Maximum order of monomial a
source
GTPSA.mad_mono_minFunction
mad_mono_min(n::Cint, a::Vector{Cuchar})::Cuchar

Returns the minimum order of the monomial.

Input

  • n – Length of monomial
  • a – Monomial

Output

  • mo – Mininum order of monomial a
source
GTPSA.mad_mono_ordFunction
mad_mono_ord(n::Cint, a::Vector{Cuchar})::Cint

Returns the sum of the orders of the monomial a.

Input

  • n – Monomial length
  • a – Monomial

Output

  • s – Sum of orders of monomial
source
GTPSA.mad_mono_ordpFunction
mad_mono_ordp(n::Cint, a::Vector{Cuchar}, stp::Cint)::Cdouble

Returns the product of each stp-th order in monomial a. For example, stp = 2 collects every order in the monomial with a step of 2 between each. As a is a pointer, the product can be started at any element in the monomial.

Input

  • n – Monomial length
  • a – Monomial as byte array
  • stp – Step over which orders to include in the product

Output

  • p – Product of orders of monomial separated by stp.
source
GTPSA.mad_mono_ordpfFunction
mad_mono_ordpf(n::Cint, a::Vector{Cuchar}, stp::Cint)::Cdouble

Returns the product of factorials each stp-th order in monomial a. For example, stp = 2 collects every order in the monomial with a step of 2 between each. As a is a pointer, the product can be started at any element in the monomial.

Input

  • n – Monomial length
  • a – Monomial as byte array
  • stp – Step over which orders to include in the product of factorials

Output

  • p – Product of factorials of orders of monomial separated by stp
source
GTPSA.mad_mono_printFunction
mad_mono_print(n::Cint, a::Vector{Cuchar}, sep_::Cstring, fp_::Ptr{Cvoid})

Prints the monomial to stdout.

Input

  • n – Length of monomial
  • a – Source monomial to print to stdout
  • sep_ – Separator string
  • fp_ – C FILE pointer, if null will print to stdout
source
GTPSA.mad_mono_prt!Function
mad_mono_prt(n::Cint, a::Vector{Cuchar}, s::Ptr{Cuchar})::Cstring

Writes the monomial defined by the byte array a (with orders stored as hexadecimal) into a null terminated string s.

Input

  • n – Monomial and string length
  • a – Monomial as byte array

Output

  • ret – Monomial as string
source
GTPSA.mad_mono_rcmpFunction
mad_mono_rcmp(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar})::Cint

Compares monomial a to monomial b starting from the right (when the monomials are ordered by variable, which is almost never the case) and returns the first difference in the lowest order variables.

Input

  • n – Length of monomials
  • a – Monomial a
  • b – Monomial b

Output

  • ret – First a[i]-b[i] != 0 where i starts from the end.
source
GTPSA.mad_mono_rev!Function
mad_mono_rev!(n::Cint, a::Vector{Cuchar}, r::Vector{Cuchar})

Sets destination monomial r equal to the reverse of source monomial a.

Input

  • n – Lengths of monomials
  • a – Source monomial a

Output

  • r – Destination monomial of reverse monomial a
source
GTPSA.mad_mono_str!Function
mad_mono_str!(n::Cint, a::Vector{Cuchar}, s::Cstring)::Cint

Writes the monomial defined in the string s, which stores the orders in a human-readable format (e.g. 10 is 10, not 0xa), into the byte array a with the orders specified in hexadecimal.

Input

  • n – Monomial and string length
  • s – Monomial as string "[0-9]*"

Output

  • a – Monomial as a byte array converted from the input string
  • i – Adjusted size n of byte array if '' found
source
GTPSA.mad_mono_sub!Function
mad_mono_sub!(n::Cint, a::Vector{Cuchar}, b::Vector{Cuchar}, r::Vector{Cuchar})

Sets monomial r = a - b.

Input

  • n – Length of monomials
  • a – Source monomial a
  • b – Source monomial b

Output

  • r – Destination monomial, r = a - b
source

Desc

GTPSA.DescType
`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 descriptors

  • nn::Cint – Number of variables + number of parameters, nn = nv+np <= 100000

  • nv::Cint – Number of variables

  • np::Cint – Number of parameters

  • mo::Cuchar – Max order of both variables AND parameters

  • po::Cuchar – Max order of parameters

  • no::Ptr{Cuchar} – Array of orders of each variable (first nv entries) and parameters (last np entries), length nn. Note: In C this is const

  • uno::Cint – User provided array of orders of each variable/parameter (with mad_desc_newvpo)

  • nth::Cint – Max number of threads or 1

  • nc::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 of To

  • prms::Ptr{Cuchar} – Order of parameters in each monomial of To (zero = no parameters)

  • To::Ptr{Ptr{Cuchar}} – Table by orders - pointers to monomials, sorted by order

  • Tv::Ptr{Ptr{Cuchar}} – Table by vars - pointers to monomials, sorted by variable

  • ocs::Ptr{Ptr{Cuchar}}ocs[t,i] -> o in mul, compute o on thread t 3 <= o <= mo aterminated with 0

  • ord2idx::Ptr{Cint} – Order to polynomial start index in To (i.e. in TPSA coef)

  • tv2to::Ptr{Cint} – Lookup tv->to

  • to2tv::Ptr{Cint} – Lookup to->tv

  • H::Ptr{Cint} – Indexing matrix in Tv

  • L::Ptr{Ptr{Cint}} – Multiplication indexes L[oa,ob]->L_ord L_ord[ia,ib]->ic

  • L_idx::Ptr{Ptr{Ptr{Cint}}}L_idx[oa,ob]->[start] [split] [end] idxs in L

  • size::Culonglong – Bytes used by desc. Unsigned Long Int: In 32 bit system is Int32 but 64 bit is Int64. Using Culonglong assuming 64 bit

  • t::Ptr{Ptr{Cvoid}} – Temporary array contains 8 pointers to TPS{Float64}s already initialized

  • ct::Ptr{Ptr{Cvoid}} – Temporary array contains 8 pointers to TPS{ComplexF64}s already initialized

  • ti::Ptr{Cint} – idx of tmp used by each thread (length = # threads)

  • cti::Ptr{Cint} – idx of tmp used by each thread (length = # threads)

source
GTPSA.mad_desc_getnv!Function
mad_desc_getnv!(d::Ptr{Desc}, mo_::Ref{Cuchar}, np_::Ref{Cint}, po_::Ref{Cuchar}::Cint

Returns the number of variables in the descriptor, and sets the passed mo_, np_, and po_ to the maximum order, number of parameters, and parameter order respectively.

Input

  • d – Descriptor

Output

  • mo_ – (Optional) Maximum order of the descriptor
  • np_ – (Optional) Number of parameters of the descriptor
  • po_ – (Optional) Parameter order of the descriptor
  • ret – Number of variables in TPSA
source
GTPSA.mad_desc_idxmFunction
mad_desc_idxm(d::Ptr{Desc}, n::Cint, m::Vector{Cuchar})::Cint

Returns the index of the monomial as byte array m in the descriptor, or -1 if the monomial is invalid.

Input

  • d – Descriptor
  • n – Monomial length
  • m – Monomial as byte array

Output

  • ret – Monomial index or -1 if invalid
source
GTPSA.mad_desc_idxsFunction
mad_desc_idxs(d::Ptr{Desc}, n::Cint, s::Cstring)::Cint

Returns the index of the monomial as string s in the descriptor, or -1 if the monomial is invalid.

Input

  • d – Descriptor
  • n – String length or 0 if unknown
  • s – Monomial as string "[0-9]*"

Output

  • ret – Monomial index or -1 if invalid monomial
source
GTPSA.mad_desc_idxsmFunction
mad_desc_idxsm(d::Ptr{Desc}, n::Cint, m::Vector{Cint})::Cint

Returns the index of the monomial as sparse monomial m, indexed as [(i,o)], in the descriptor, or -1 if the monomial is invalid.

Input

  • d – Descriptor
  • n – Monomial length
  • m – Sparse monomial [(idx,ord)]

Output

  • ret – Monomial index or -1 if invalid
source
GTPSA.mad_desc_infoFunction
mad_desc_info(d::Ptr{Desc}, fp::Ptr{Cvoid})

For debugging.

Input

  • d – Descriptor to debug
  • fp – File to write to. If null, will write to stdout
source
GTPSA.mad_desc_isvalidmFunction
mad_desc_isvalidm(d::Ptr{Desc}, n::Cint, m::Vector{Cuchar})::Bool

Checks if monomial as byte array m is valid given maximum order of descriptor.

Input

  • d – Descriptor
  • n – Length of monomial
  • m – Monomial as byte array

Output

  • ret – True if valid, false if invalid
source
GTPSA.mad_desc_isvalidsFunction
mad_desc_isvalids(d::Ptr{Desc}, n::Cint, s::Cstring)::Bool

Checks if monomial as string s is valid given maximum order of descriptor.

Input

  • d – Descriptor
  • n – Monomial string length
  • s – Monomial as string "[0-9]*"

Output

  • ret – True if valid, false if invalid
source
GTPSA.mad_desc_isvalidsmFunction
mad_desc_isvalidsm(d::Ptr{Desc}, n::Cint, m::Vector{Cint})::Bool

Checks the monomial as sparse monomial m (monomial stored as sequence of integers with each pair [(i,o)] such that i = index, o = order) is valid given the maximum order of the descriptor.

Input

  • d – Descriptor
  • n – Length of monomial
  • m – Sparse monomial [(idx, ord)]

Output

  • ret – True if valid, false if invalid
source
GTPSA.mad_desc_maxlenFunction
mad_desc_maxlen(d::Ptr{Desc}, mo::Cuchar)::Cint

Gets the maximum length of the TPSA given an order.

Input

  • d – Descriptor
  • mo – Order (ordlen(maxord) == maxlen)

Output

  • ret – monomials in 0..order
source
GTPSA.mad_desc_maxordFunction
mad_desc_maxord(d::Ptr{Desc}, nn::Cint, no_::Vector{Cuchar})::Cuchar

Sets the order of the variables and parameters of the TPSA to those specified in no_ and returns the maximum order of the TPSA.

Input

  • d – Descriptor
  • nn – 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
source
GTPSA.mad_desc_mono!Function
mad_desc_mono!(d::Ptr{Desc}, i::Cint, n::Cint, m_::Vector{Cuchar}, p_::Vector{Cuchar})::Cuchar

Returns the order of the monomial at index i, and if n and m_ are provided, then will also fill m_ with the monomial at this index. Also will optionally return the order of the parameters in the monomial if p_ is provided

Input

  • d – Descriptor
  • i – Slot index (must be valid)
  • n – Monomial length (must be provided if m_ is to be filled)

Output

  • ret – Monomial order at slot index
  • m_ – (Optional) Monomial to fill if provided
  • p_ – (Optional) Order of parameters in monomial if provided
source
GTPSA.mad_desc_newvFunction
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 TPSA
  • mo – Maximum order of TPSA, mo = max(1, mo)

Output

  • ret – Descriptor with the specified number of variables and maximum order
source
GTPSA.mad_desc_newvpFunction
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 variables
  • mo – Maximum order of TPSA INCLUDING PARAMETERS, mo = max(1, mo)
  • np_ – (Optional) Number of parameters, default is 0
  • po_ – (Optional) Order of parameters, po = max(1, po_)

Output

  • ret – Descriptor with the specified nv, mo, np, and po
source
GTPSA.mad_desc_newvpoFunction
mad_desc_newvpo(nv::Cint, mo::Cuchar, np_::Cint, po_::Cuchar, no_::Vector{Cuchar})::Ptr{Desc}

Creates a TPSA descriptor with the specifed number of variables, maximum order for both variables and parameters, number of parameters, parameter order, and individual variable/parameter orders specified in no. The first nv entries in no correspond to the variables' orders and the next np entries correspond the parameters' orders.

Input

  • nv – Number of variables
  • mo – Maximum order of TPSA (mo = max(mo , no[0 :nn-1]), nn = nv+np)
  • np_ – (Optional) Number of parameters, default is 0
  • po_ – (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 specified nv, mo, np, po, no.
source
GTPSA.mad_desc_nxtbyordFunction
mad_desc_nxtbyord(d::Ptr{Desc}, n::Cint, m::Vector{Cuchar})::Cint

Returns the next monomial after monomial m in the TPSA when sorted by order.

Input

  • d – Descriptor
  • n – Monomial length
  • m – Monomial as byte array

Output

  • idx – Monomial index or -1 if no valid next monomial
source
GTPSA.mad_desc_nxtbyvarFunction
mad_desc_nxtbyvar(d::Ptr{Desc}, n::Cint, m::Vector{Cuchar})::Cint

Returns the next monomial after monomial m in the TPSA when sorted by variable.

Input

  • d – Descriptor
  • n – Monomial length
  • m – Monomial as byte array

Output

  • idx – Monomial index or -1 if no valid next monomial
source
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 threshold
  • comp_ – (Optional) Ptr{Cint} to new composition OMP parallelization threshold

Output

  • mult_ – (Optional) old multiplication parallelization threshold
  • comp_ – (Optional) old composition parallelization threshold
source

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 TPSA a

Output

  • c – Destination TPSA c = |a|
source
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 TPSA a
  • v – Scalar with double precision

Output

  • c – Destination TPSA c += v*a
source
GTPSA.mad_tpsa_acos!Function
mad_tpsa_acos!(a::RealTPS, c::RealTPS)

Sets TPSA c to the acos of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = acos(a)
source
GTPSA.mad_tpsa_acosh!Function
mad_tpsa_acosh!(a::RealTPS, c::RealTPS)

Sets TPSA c to the acosh of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA `c = acosh(a)'
source
GTPSA.mad_tpsa_acot!Function
mad_tpsa_acot!(a::RealTPS, c::RealTPS)

Sets TPSA c to the acot of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = acot(a)
source
GTPSA.mad_tpsa_acoth!Function
mad_tpsa_acoth!(a::RealTPS, c::RealTPS)

Sets TPSA c to the acoth of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA `c = acoth(a)'
source
GTPSA.mad_tpsa_add!Function
mad_tpsa_add!(a::RealTPS, b::RealTPS, c::RealTPS)

Sets the destination TPSA c = a + b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a + b
source
GTPSA.mad_tpsa_asin!Function
mad_tpsa_asin!(a::RealTPS, c::RealTPS)

Sets TPSA c to the asin of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = asin(a)
source
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 TPSA a

Output

  • c – Destination TPSA c = asinc(a) = asin(a)/a
source
GTPSA.mad_tpsa_asinh!Function
mad_tpsa_asinh!(a::RealTPS, c::RealTPS)

Sets TPSA c to the asinh of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA `c = asinh(a)'
source
GTPSA.mad_tpsa_asinhc!Function
mad_tpsa_asinhc!(a::RealTPS, c::RealTPS)

Sets TPSA c to the asinhc of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA `c = asinhc(a)'
source
GTPSA.mad_tpsa_atan!Function
mad_tpsa_atan!(a::RealTPS, c::RealTPS)

Sets TPSA c to the atan of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = atan(a)
source
GTPSA.mad_tpsa_atan2!Function
mad_tpsa_atan2!(y::RealTPS, x::RealTPS, r::RealTPS)

Sets TPSA r to atan2(y,x)

Input

  • y – Source TPSA y
  • x – Source TPSA x

Output

  • r – Destination TPSA r = atan2(y,x)
source
GTPSA.mad_tpsa_atanh!Function
mad_tpsa_atanh!(a::RealTPS, c::RealTPS)

Sets TPSA c to the atanh of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA `c = atanh(a)'
source
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 – Scalar a
  • x – TPSA x
  • b – Scalar b
  • y – TPSA y
  • c – Scalar c
  • z – TPSA z

Output

  • r – Destination TPSA r
source
GTPSA.mad_tpsa_axpb!Function
mad_tpsa_axpb!(a::Cdouble, x::RealTPS, b::Cdouble, r::RealTPS)

r = a*x + b

Input

  • a – Scalar a
  • x – TPSA x
  • b – Scalar b

Output

  • r – Destination TPSA r
source
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 – Scalar a
  • x – TPSA x
  • b – Scalar b
  • y – TPSA y
  • c – Scalar c

Output

  • r – Destination TPSA r
source
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 – TPSA x
  • a – Scalar a
  • b – Scalar b
  • c – Scalar c

Output

  • r – Destination TPSA r
source
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 – Scalar a
  • x – TPSA x
  • y – TPSA y
  • b – Scalar b

Output

  • r – Destination TPSA r
source
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 – Scalar a
  • x – TPSA x
  • y – TPSA y
  • b – Scalar b
  • v – TPSA v
  • w – TPSA w
  • c – Scalar c

Output

  • r – Destination TPSA r
source
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 – Scalar a
  • x – TPSA x
  • y – TPSA y
  • b – Scalar b
  • z – TPSA z
  • c – Scalar c

Output

  • r – Destination TPSA r
source
GTPSA.mad_tpsa_clrord!Function
mad_tpsa_clrord!(t::RealTPS, ord::Cuchar)

Clears all monomial coefficients of the TPSA at order ord

Input

  • t – TPSA
  • ord – Order to clear monomial coefficients
source
GTPSA.mad_tpsa_compose!Function
mad_tpsa_compose!(na::Cint, ma, nb::Cint, mb, mc)

Composes two maps.

Input

  • na – Number of TPSAs in map ma
  • ma – map ma
  • nb – Number of TPSAs in map mb
  • mb – map mb

Output

  • mc – Composition of maps ma and mb
source
GTPSA.mad_tpsa_convert!Function
mad_tpsa_convert!(t::RealTPS, r::RealTPS, n::Cint, t2r_::Vector{Cint}, pb::Cint)

General function to convert TPSAs to different orders and reshuffle canonical coordinates. The destination TPSA will be of order n, and optionally have the variable reshuffling defined by t2r_ and poisson bracket sign. e.g. if t2r_ = {1,2,3,4,6,5} and pb = -1, canonical coordinates 6 and 5 are swapped and the new 5th canonical coordinate will be negated. Useful for comparing with different differential algebra packages.

Input

  • t – Source TPSA
  • n – Length of vector
  • t2r_ – (Optional) Vector of index lookup
  • pb – Poisson bracket, 0, 1:fwd, -1:bwd

Output

  • r – Destination TPSA with specified order and canonical coordinate reshuffling.
source
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
source
GTPSA.mad_tpsa_cos!Function
mad_tpsa_cos!(a::RealTPS, c::RealTPS)

Sets TPSA c to the cos of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = cos(a)
source
GTPSA.mad_tpsa_cosh!Function
mad_tpsa_cosh!(a::RealTPS, c::RealTPS)

Sets TPSA c to the cosh of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = cosh(a)
source
GTPSA.mad_tpsa_cot!Function
mad_tpsa_cot!(a::RealTPS, c::RealTPS)

Sets TPSA c to the cot of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = cot(a)
source
GTPSA.mad_tpsa_coth!Function
mad_tpsa_coth!(a::RealTPS, c::RealTPS)

Sets TPSA c to the coth of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = coth(a)
source
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 TPSA
  • r – Destination TPSA
  • i – Index of monomial
source
GTPSA.mad_tpsa_cpym!Function
mad_tpsa_cpym!(t::RealTPS, r::RealTPS, n::Cint, m::Vector{Cuchar})

Copies the monomial coefficient at the monomial-as-vector-of-orders m in t into the same monomial coefficient in r

Input

  • t – Source TPSA
  • r – Destination TPSA
  • n – Length of monomial m
  • m – Monomial as vector of orders
source
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 TPSA
  • r – Destination TPSA
  • n – Length of string
  • s – Monomial as string
source
GTPSA.mad_tpsa_cpysm!Function
mad_tpsa_cpysm!(t::RealTPS, r::RealTPS, n::Cint, m::Vector{Cint})

Copies the monomial coefficient at the monomial-as-sparse-monomial m in t into the same monomial coefficient in r

Input

  • t – Source TPSA
  • r – Destination TPSA
  • n – Length of monomial m
  • m – Monomial as sparse-monomial
source
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 TPSA
  • ord – Cut order: 0..-ord or ord..mo

Output

  • r – Destination TPSA
source
GTPSA.mad_tpsa_cycle!Function
mad_tpsa_cycle!(t::RealTPS, i::Cint, n::Cint, m_, v_)::Cint

Used for scanning through each nonzero monomial in the TPSA. Given a starting index (-1 if starting at 0), will optionally fill monomial m_ with the monomial at index i and the value at v_ with the monomials coefficient, and return the next NONZERO monomial index in the TPSA. This is useful for building an iterator through the TPSA.

Input

  • t – TPSA to scan
  • i – Index to start from (-1 to start at 0)
  • n – Length of monomial
  • m_ – (Optional) Monomial to be filled if provided
  • v_ – (Optional) Pointer to value of coefficient

Output

  • i – Index of next nonzero monomial in the TPSA, or -1 if reached the end
source
GTPSA.mad_tpsa_debugFunction
mad_tpsa_debug(t::RealTPS, name_::Cstring, fnam_::Cstring, line_::Cint, stream_::Ptr{Cvoid})::Cint

Prints TPSA with all information of data structure.

Input

  • t – TPSA
  • name_ – (Optional) Name of TPSA
  • fnam_ – (Optional) File name to print to
  • line_ – (Optional) Line number in file to start at
  • stream_ – (Optional) I/O stream to print to, default is stdout

Output

  • retCint reflecting internal state of TPSA
source
GTPSA.mad_tpsa_del!Function
mad_tpsa_del!(t::Ptr{TPS{Float64}})

Calls the destructor for the TPSA.

Input

  • t – TPSA to destruct
source
GTPSA.mad_tpsa_densityFunction
mad_tpsa_density(t::RealTPS, stat_, reset::Bool)::Cdouble

Computes the ratio of nz/nc in [0] U [lo,hi] or stat_

source
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 differentiate
  • iv – Index of variable to take derivative wrt to (e.g. derivative wrt x, iv = 1).

Output

  • c – Destination TPSA
source
GTPSA.mad_tpsa_derivm!Function
mad_tpsa_derivm!(a::RealTPS, c::RealTPS, n::Cint, m::Vector{Cuchar})

Differentiates TPSA with respect to the monomial defined by byte array m.

Input

  • a – Source TPSA to differentiate
  • n – Length of monomial to differentiate wrt
  • m – Monomial to take derivative wrt

Output

  • c – Destination TPSA
source
GTPSA.mad_tpsa_descFunction
mad_tpsa_desc(t::RealTPS)::Ptr{Desc}

Gets the descriptor for the TPSA.

Input

  • t – TPSA

Output

  • ret – Descriptor for the TPS{Float64}
source
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 TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c
source
GTPSA.mad_tpsa_div!Function
mad_tpsa_div!(a::RealTPS, b::RealTPS, c::RealTPS)

Sets the destination TPSA c = a / b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a / b
source
GTPSA.mad_tpsa_equFunction
mad_tpsa_equ(a::RealTPS, b::RealTPS, tol_::Cdouble)::Bool

Checks if the TPSAs a and b are equal within the specified tolerance tol_. If tol_ is not specified, DBL_GTPSA.show_epsILON is used.

Input

  • a – TPSA a
  • b – TPSA b
  • tol_ – (Optional) Difference below which the TPSAs are considered equal

Output

  • ret - True if a == b within tol_
source
GTPSA.mad_tpsa_erf!Function
mad_tpsa_erf!(a::RealTPS, c::RealTPS)

Sets TPSA c to the erf of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA `c = erf(a)'
source
GTPSA.mad_tpsa_erfc!Function
mad_tpsa_erfc!(a::RealTPS, c::RealTPS)

Sets TPSA c to the erfc of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA `c = erfc(a)'
source
GTPSA.mad_tpsa_eval!Function
mad_tpsa_eval!(na::Cint, ma::Vector{TPS{Float64}}, nb::Cint, tb::Vector{Cdouble}, tc::Vector{Cdouble})

Evaluates the map at the point tb

Input

  • na – Number of TPSAs in the map
  • ma – map ma
  • nb – Length of tb
  • tb – Point at which to evaluate the map

Output

  • tc – Values for each TPSA in the map evaluated at the point tb
source
GTPSA.mad_tpsa_exp!Function
mad_tpsa_exp!(a::RealTPS, c::RealTPS)

Sets TPSA c to the exponential of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = exp(a)
source
GTPSA.mad_tpsa_exppb!Function
mad_tpsa_exppb!(na::Cint, ma::Vector{TPS{Float64}}, mb::Vector{TPS{Float64}}, mc::Vector{TPS{Float64}})

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 of ma and mb
  • ma – Vector of TPSA ma
  • mb – Vector of TPSA mb

Output

  • mc – Destination vector of TPSA mc
source
GTPSA.mad_tpsa_fgrad!Function
mad_tpsa_fgrad!(na::Cint, ma::Vector{TPS{Float64}}, b::RealTPS, c::RealTPS)

Calculates dot(ma, grad(b))

Input

  • na – Length of ma consistent with number of variables in b
  • ma – Vector of TPSA
  • b – TPSA

Output

  • cdot(ma, grad(b))
source
GTPSA.mad_tpsa_fld2vec!Function
mad_tpsa_fld2vec!(na::Cint, ma::Vector{TPS{Float64}}, 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 in ma consistent with number of variables in c
  • ma – Vector field

Output

  • c – Hamiltonian as a TPSA derived from the vector field ma
source
GTPSA.mad_tpsa_getiFunction
mad_tpsa_geti(t::RealTPS, i::Cint)::Cdouble

Gets the coefficient of the monomial at index i. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • i – Monomial index

Output

  • ret – Coefficient of monomial at index i
source
GTPSA.mad_tpsa_getmFunction
mad_tpsa_getm(t::RealTPS, n::Cint, m::Vector{Cuchar})::Cdouble

Gets the coefficient of the monomial m defined as a byte array. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as byte array

Output

  • ret – Coefficient of monomial m in TPSA
source
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 TPSA
  • ord – Order to retrieve

Output

  • r – Destination TPSA
source
GTPSA.mad_tpsa_getsFunction
mad_tpsa_gets(t::RealTPS, n::Cint, s::Cstring)::Cdouble

Gets the coefficient of the monomial s defined as a string. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Length of monomial
  • s – Monomial as string

Output

  • ret – Coefficient of monomial s in TPSA
source
GTPSA.mad_tpsa_getsmFunction
mad_tpsa_getsm(t::RealTPS, n::Cint, m::Vector{Cint})::Cdouble

Gets the coefficient of the monomial m defined as a sparse monomial. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as sparse monomial

Output

  • ret – Coefficient of monomial m in TPSA
source
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 – TPSA
  • i – Starting index of monomials to get coefficients
  • n – Number of monomials to get coefficients of starting at i

Output

  • v – Array of coefficients for monomials i..i+n
source
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 TPSA x
  • y – Source TPSA y

Output

  • r – Destination TPSA r = sqrt(x^2+y^2)
source
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 TPSA x
  • y – Source TPSA y
  • z – Source TPSA z

Output

  • r – Destination TPSA r = sqrt(x^2+y^2+z^2)
source
GTPSA.mad_tpsa_idxmFunction
mad_tpsa_idxm(t::RealTPS, n::Cint, m::Vector{Cuchar})::Cint

Returns index of monomial in the TPSA given the monomial as a byte array

Input

  • t – TPSA
  • n – Length of monomial
  • s – Monomial as byte array

Output

  • ret – Index of monomial in TPSA
source
GTPSA.mad_tpsa_idxsFunction
mad_tpsa_idxs(t::RealTPS, n::Cint, s::Cstring)::Cint

Returns index of monomial in the TPSA given the monomial as string. This generally should not be used, as there are no assumptions about which monomial is attached to which index.

Input

  • t – TPSA
  • n – Length of monomial
  • s – Monomial as string

Output

  • ret – Index of monomial in TPSA
source
GTPSA.mad_tpsa_idxsmFunction
mad_tpsa_idxsm(t::RealTPS, n::Cint, m::Vector{Cint})::Cint

Returns index of monomial in the TPSA given the monomial as a sparse monomial. This generally should not be used, as there are no assumptions about which monomial is attached to which index.

Input

  • t – TPSA
  • n – Length of monomial
  • s – Monomial as sparse monomial

Output

  • ret – Index of monomial in TPSA
source
GTPSA.mad_tpsa_init!Function
mad_tpsa_init(t::RealTPS, d::Ptr{Desc}, mo::Cuchar)::RealTPS

Unsafe initialization of an already existing TPSA t with maximum order mo to the descriptor d. mo must be less than the maximum order of the descriptor. t is modified in place and also returned.

Input

  • t – TPSA to initialize to descriptor d
  • d – Descriptor
  • mo – Maximum order of the TPSA (must be less than maximum order of the descriptor)

Output

  • t – TPSA initialized to descriptor d with maximum order mo
source
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 integrate
  • iv – Index of variable to integrate over (e.g. integrate over x, iv = 1).

Output

  • c – Destination TPSA
source
GTPSA.mad_tpsa_inv!Function
mad_tpsa_inv!(a::RealTPS,  v::Cdouble, c::RealTPS)

Sets TPSA c to v/a.

Input

  • a – Source TPSA a
  • v – Scalar with double precision

Output

  • c – Destination TPSA c = v/a
source
GTPSA.mad_tpsa_invsqrt!Function
mad_tpsa_invsqrt!(a::RealTPS, v::Cdouble, c::RealTPS)

Sets TPSA c to v/sqrt(a).

Input

  • a – Source TPSA a
  • v – Scalar with double precision

Output

  • c – Destination TPSA c = v/sqrt(a)
source
GTPSA.mad_tpsa_isnulFunction
mad_tpsa_isnul(t::RealTPS)::Bool

Checks if TPSA is 0 or not

Input

  • t – TPSA to check

Output

  • ret – True or false
source
GTPSA.mad_tpsa_isvalFunction
mad_tpsa_isval(t::RealTPS)::Bool

Sanity check of the TPSA integrity.

Input

  • t – TPSA to check if valid

Output

  • ret – True if valid TPSA, false otherwise
source
GTPSA.mad_tpsa_isvalidFunction
mad_tpsa_isvalid(t::RealTPS)::Bool

Sanity check of the TPSA integrity.

Input

  • t – TPSA to check if valid

Output

  • ret – True if valid TPSA, false otherwise
source
GTPSA.mad_tpsa_lenFunction
mad_tpsa_len(t::RealTPS, hi_::Bool)::Cint

Gets the length of the TPSA itself (e.g. the descriptor may be order 10 but TPSA may only be order 2)

Input

  • t – TPSA
  • hi_ – If true, returns the length up to the hi order in the TPSA, else up to mo. Default is false

Output

  • ret – Length of TPS{Float64}
source
GTPSA.mad_tpsa_liebra!Function
mad_tpsa_liebra!(na::Cint, ma::Vector{TPS{Float64}}, mb::Vector{TPS{Float64}}, mc::Vector{TPS{Float64}})

Computes the Lie bracket of the vector fields ma and mb, defined as sumi mai (dmb/dxi) - mbi (dma/dx_i).

Input

  • na – Length of ma and mb
  • ma – Vector of TPSA ma
  • mb – Vector of TPSA mb

Output

  • mc – Destination vector of TPSA mc
source
GTPSA.mad_tpsa_log!Function
mad_tpsa_log!(a::RealTPS, c::RealTPS)

Sets TPSA c to the log of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = log(a)
source
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 – TPSA x
  • a – Scalar a
  • b – Scalar b
  • c – Scalar c

Output

  • r – Destination TPSA r
source
GTPSA.mad_tpsa_logpb!Function
mad_tpsa_logpb!(na::Cint, ma::Vector{TPS{Float64}}, mb::Vector{TPS{Float64}}, mc::Vector{TPS{Float64}})

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 of ma and mb
  • ma – Vector of TPSA ma
  • mb – Vector of TPSA mb

Output

  • mc – Destination vector of TPSA mc
source
GTPSA.mad_tpsa_logxdy!Function
mad_tpsa_logxdy!(x::RealTPS, y::RealTPS, r::RealTPS)

r = log(x / y)

Input

  • x – TPSA x
  • y – TPSA y

Output

  • r – Destination TPSA r
source
GTPSA.mad_tpsa_maxord!Function
mad_tpsa_maxord!(t::RealTPS, n::Cint, idx_::Vector{Cint})::Cint

Returns the index to the monomial with maximum abs(coefficient) in the TPSA for all orders 0 to n. If idx_ is provided, it is filled with the indices for the maximum abs(coefficient) monomial for each order up to n.

Input

  • t – TPSA
  • n – Highest order to include in finding the maximum abs(coefficient) in the TPSA, length of idx_ if provided

Output

  • idx_ – (Optional) If provided, is filled with indices to the monomial for each order up to n with maximum abs(coefficient)
  • mi – Index to the monomial in the TPSA with maximum abs(coefficient)
source
GTPSA.mad_tpsa_mconv!Function
mad_tpsa_mconv!(na::Cint, ma::Vector{TPS{Float64}}, nc::Cint, mc::Vector{TPS{Float64}}, n::Cint, t2r_::Vector{Cint}, pb::Cint)

Equivalent to mad_tpsa_convert, but applies the conversion to all TPSAs in the map ma.

Input

  • na – Number of TPSAs in the map
  • ma – map ma
  • nc – Number of TPSAs in the output map mc
  • n – Length of vector (size of t2r_)
  • t2r_ – (Optional) Vector of index lookup
  • pb – Poisson bracket, 0, 1:fwd, -1:bwd

Output

  • mc – map mc with specified conversions
source
GTPSA.mad_tpsa_minv!Function
mad_tpsa_minv!(na::Cint, ma::Vector{TPS{Float64}}, nb::Cint, mc::Vector{TPS{Float64}})

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 be nn to include parameters)
  • ma – Map ma
  • nb – Output map length (generally = nv)

Output

  • mc – Inversion of map ma
source
GTPSA.mad_tpsa_mnrmFunction
mad_tpsa_mnrm(na::Cint, ma::Vector{TPS{Float64}})::Cdouble

Computes the norm of the map (sum of absolute value of coefficients of all TPSAs in the map).

Input

  • na – Number of TPSAs in the map
  • ma – map ma

Output

  • nrm – Norm of map (sum of absolute value of coefficients of all TPSAs in the map)
source
GTPSA.mad_tpsa_mo!Function
mad_tpsa_mo!(t::RealTPS, mo::Cuchar)::Cuchar

Sets 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 – TPSA
  • mo_ – Maximum order to set the TPSA

Output

  • ret – Original mo of the TPSA
source
GTPSA.mad_tpsa_mono!Function
mad_tpsa_mono!(t::RealTPS, i::Cint, n::Cint, m_::Vector{Cuchar}, p_::Vector{Cuchar})::Cuchar

Returns the order of the monomial at index i in the TPSA and optionally the monomial at that index is returned in m_ and the order of parameters in the monomial in p_

Input

  • t – TPSA
  • i – Index valid in TPSA
  • n – Length of monomial

Output

  • m_ – (Optional) Monomial at index i in TPSA
  • p_ – (Optional) Order of parameters in monomial
  • ret – Order of monomial in TPSA at index i
source
GTPSA.mad_tpsa_mordFunction
mad_tpsa_mord(na::Cint, ma::Vector{TPS{Float64}}, hi::Bool)::Cuchar

If 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 map ma
  • ma – Map (vector of TPSAs)
  • hi – If true, returns maximum hi, else returns maximum mo of the map

Output

  • ret – Maximum hi of the map if hi is true, else returns maximum mo of the map
source
GTPSA.mad_tpsa_mul!Function
mad_tpsa_mul!(a::RealTPS, b::RealTPS, c::RealTPS)

Sets the destination TPSA c = a * b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a * b
source
GTPSA.mad_tpsa_namFunction
mad_tpsa_nam(t::RealTPS, nam_)::Cstring

Get the name of the TPSA, and will optionally set if nam_ != null

Input

  • t – TPSA
  • nam_ – Name to set the TPSA

Output

  • ret – Name of TPS{Float64} (null terminated in C)
source
GTPSA.mad_tpsa_newFunction
mad_tpsa_new(t::Ptr{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 – TPSA
  • mo – Maximum order of new TPSA

Output

  • ret – New blank TPSA with maximum order mo
source
GTPSA.mad_tpsa_newdFunction
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 – Descriptor
  • mo – Maximum order

Output

  • t – New TPSA defined by the descriptor
source
GTPSA.mad_tpsa_nrmFunction
mad_tpsa_nrm(a::RealTPS)::Cdouble

Calculates the 1-norm of TPSA a (sum of abs of all coefficients)

Input

  • a – TPSA

Output

  • nrm – 1-Norm of TPSA
source
GTPSA.mad_tpsa_ordFunction
mad_tpsa_ord(t::RealTPS, hi_::Bool)::Cuchar

Gets the TPSA maximum order, or hi if hi_ is true.

Input

  • t – TPSA
  • hi_ – Set true if hi is returned, else mo is returned

Output

  • ret – Order of TPSA
source
GTPSA.mad_tpsa_ordvFunction
mad_tpsa_ordv(t::RealTPS, ts::RealTPS...)::Cuchar

Returns maximum order of all TPSAs provided.

Input

  • t – TPSA
  • ts – Variable number of TPSAs passed as parameters

Output

  • mo – Maximum order of all TPSAs provided
source
GTPSA.mad_tpsa_pminv!Function
mad_tpsa_pminv!(na::Cint, ma::Vector{TPS{Float64}}, nb::Cint, mc::Vector{TPS{Float64}}, select::Vector{Cint})

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 be nn to include parameters)
  • ma – Map ma
  • nb – 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
source
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 TPSA a
  • b – Source TPSA b
  • nv – Number of variables in the TPSA

Output

  • c – Destination TPSA c
source
GTPSA.mad_tpsa_pow!Function
mad_tpsa_pow!(a::RealTPS, b::RealTPS, c::RealTPS)

Sets the destination TPSA c = a ^ b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a ^ b
source
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 TPSA a
  • n – Integer power

Output

  • c – Destination TPSA c = a ^ n
source
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 TPSA a
  • v – "double" precision power

Output

  • c – Destination TPSA c = a ^ v
source
GTPSA.mad_tpsa_printFunction
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 print
  • name_ – (Optional) Name of TPSA
  • eps_ – (Optional) Precision to output
  • nohdr_ – (Optional) If True, no header is printed
  • stream_ – (Optional) FILE pointer of output stream. Default is stdout
source
GTPSA.mad_tpsa_scanFunction
mad_tpsa_scan(stream_::Ptr{Cvoid})::RealTPS

Scans in a TPSA from the stream_.

Input

  • stream_ – (Optional) I/O stream from which to read the TPSA, default is stdin

Output

  • t – TPSA scanned from I/O stream_
source
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 is stdin

Output

  • t – TPSA with coefficients scanned from stream_
source
GTPSA.mad_tpsa_scan_hdrFunction
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 TPSA
  • stream_ – (Optional) I/O stream to read TPSA from, default is stdin

Output

  • ret – Descriptor for the TPSA
source
GTPSA.mad_tpsa_scl!Function
mad_tpsa_scl!(a::RealTPS, v::Cdouble, c::RealTPS)

Sets TPSA c to v*a.

Input

  • a – Source TPSA a
  • v – Scalar with double precision

Output

  • c – Destination TPSA c = v*a
source
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 TPSA
  • inv – Put order up, divide, scale by inv of value of order
  • prm – 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
source
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 – TPSA
  • i – Index of monomial
  • a – Scaling of current coefficient
  • b – Constant added to current coefficient
source
GTPSA.mad_tpsa_setm!Function
mad_tpsa_setm!(t::RealTPS, n::Cint, m::Vector{Cuchar}, 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 – TPSA
  • n – Length of monomial
  • m – Monomial as byte array
  • a – Scaling of current coefficient
  • b – Constant added to current coefficient
source
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 – TPSA
  • v – 0th order value (coefficient)
  • ip – Parameter index (e.g. iv = 1 is nn-nv+1)
source
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 – TPSA
  • n – Length of monomial
  • s – Monomial as string
  • a – Scaling of current coefficient
  • b – Constant added to current coefficient
source
GTPSA.mad_tpsa_setsm!Function
mad_tpsa_setsm!(t::RealTPS, n::Cint, m::Vector{Cint}, 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 – TPSA
  • n – Length of monomial
  • m – Monomial as sparse monomial
  • a – Scaling of current coefficient
  • b – Constant added to current coefficient
source
GTPSA.mad_tpsa_setv!Function
mad_tpsa_setv!(t::RealTPS, i::Cint, n::Cint, v::Vector{Cdouble})

Vectorized setter of the coefficients for monomials with indices i..i+n. Useful for putting a matrix into a map.

Input

  • t – TPSA
  • i – Starting index of monomials to set coefficients
  • n – Number of monomials to set coefficients of starting at i
  • v – Array of coefficients for monomials i..i+n
source
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 scalar
  • v – Scalar value to set TPSA
source
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 – TPSA
  • v – 0th order value (coefficient)
  • iv – Variable index
  • scl_ – 1st order variable value (typically will be 1)
source
GTPSA.mad_tpsa_sin!Function
mad_tpsa_sin!(a::RealTPS, c::RealTPS)

Sets TPSA c to the sin of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sin(a)
source
GTPSA.mad_tpsa_sinc!Function
mad_tpsa_sinc!(a::RealTPS, c::RealTPS)

Sets TPSA c to the sinc of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sinc(a)
source
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 TPSA a

Output

  • s – Destination TPSA s = sin(a)
  • c – Destination TPSA c = cos(a)
source
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 TPSA a

Output

  • s – Destination TPSA s = sinh(a)
  • c – Destination TPSA c = cosh(a)
source
GTPSA.mad_tpsa_sinh!Function
mad_tpsa_sinh!(a::RealTPS, c::RealTPS)

Sets TPSA c to the sinh of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sinh(a)
source
GTPSA.mad_tpsa_sinhc!Function
mad_tpsa_sinhc!(a::RealTPS, c::RealTPS)

Sets TPSA c to the sinhc of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sinhc(a)
source
GTPSA.mad_tpsa_sqrt!Function
mad_tpsa_sqrt!(a::RealTPS, c::RealTPS)

Sets TPSA c to the sqrt of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sqrt(a)
source
GTPSA.mad_tpsa_sub!Function
mad_tpsa_sub!(a::RealTPS, b::RealTPS, c::RealTPS)

Sets the destination TPSA c = a - b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a - b
source
GTPSA.mad_tpsa_tan!Function
mad_tpsa_tan!(a::RealTPS, c::RealTPS)

Sets TPSA c to the tan of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = tan(a)
source
GTPSA.mad_tpsa_tanh!Function
mad_tpsa_tanh!(a::RealTPS, c::RealTPS)

Sets TPSA c to the tanh of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = tanh(a)
source
GTPSA.mad_tpsa_taylor!Function
mad_tpsa_taylor!(a::RealTPS, n::Cint, coef::Vector{Cdouble}, 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 – TPSA a
  • nOrder-1 of Taylor expansion, size of coef array
  • coef – Array of coefficients in Taylor s
  • c – Result
source
GTPSA.mad_tpsa_taylor_h!Function
mad_tpsa_taylor_h!(a::RealTPS, n::Cint, coef::Vector{Cdouble}, 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 – TPSA a
  • nOrder-1 of Taylor expansion, size of coef array
  • coef – Array of coefficients in Taylor s
  • c – Result
source
GTPSA.mad_tpsa_translate!Function
mad_tpsa_translate!(na::Cint, ma::Vector{TPS{Float64}}, nb::Cint, tb::Vector{Cdouble}, mc::Vector{TPS{Float64}})

Translates the expansion point of the map by the amount tb.

Input

  • na – Number of TPSAS in the map
  • ma – map ma
  • nb – Length of tb
  • tb – Vector of amount to translate for each variable

Output

  • mc – Map evaluated at the new point translated tb from the original evaluation point
source
GTPSA.mad_tpsa_uid!Function
mad_tpsa_uid!(t::RealTPS, uid_::Cint)::Cint

Sets the TPSA uid if uid_ != 0, and returns the current (previous if set) TPSA uid.

Input

  • t – TPSA
  • uid_uid to set in the TPSA if uid_ != 0

Output

  • ret – Current (previous if set) TPSA uid
source
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 TPSA a

Output

  • c – Destination TPSA c
source
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.

source
GTPSA.mad_tpsa_vec2fld!Function
mad_tpsa_vec2fld!(na::Cint, a::RealTPS, mc::Vector{TPS{Float64}})

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 in mc consistent with number of variables in a
  • a – Hamiltonian as a TPSA

Output

  • mc – Vector field derived from a using Hamilton's equations
source

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 TPSA a
  • v – Scalar with double precision

Output

  • c – Destination TPSA c += v*a
source
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 TPSA a
  • v_re – Real part of scalar with double precision
  • v_im – Imaginary part of scalar with double precision

Output

  • c – Destination TPSA c += v*a
source
GTPSA.mad_ctpsa_acos!Function
mad_ctpsa_acos!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the acos of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = acos(a)
source
GTPSA.mad_ctpsa_acosh!Function
mad_ctpsa_acosh!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the acosh of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = acosh(a)
source
GTPSA.mad_ctpsa_acot!Function
mad_ctpsa_acot!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the acot of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = acot(a)
source
GTPSA.mad_ctpsa_acoth!Function
mad_ctpsa_acoth!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the acoth of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = acoth(a)
source
GTPSA.mad_ctpsa_add!Function
mad_ctpsa_add!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)

Sets the destination TPSA c = a + b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a + b
source
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} a
  • b – Source TPS{Float64} b

Output

  • c – Destination TPS{ComplexF64} c = a + b
source
GTPSA.mad_ctpsa_asin!Function
mad_ctpsa_asin!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the asin of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = asin(a)
source
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 TPSA a

Output

  • c – Destination TPSA c = asinc(a) = asin(a)/a
source
GTPSA.mad_ctpsa_asinh!Function
mad_ctpsa_asinh!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the asinh of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = asinh(a)
source
GTPSA.mad_ctpsa_asinhc!Function
mad_ctpsa_asinhc!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the asinhc of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = asinhc(a)
source
GTPSA.mad_ctpsa_atan!Function
mad_ctpsa_atan!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the atan of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = atan(a)
source
GTPSA.mad_ctpsa_atanh!Function
mad_ctpsa_atanh!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the atanh of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = atanh(a)
source
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 – Scalar a
  • x – TPSA x
  • b – Scalar b
  • y – TPSA y
  • c – Scalar c
  • z – TPSA z

Output

  • r – Destination TPSA r
source
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 Scalar a
  • a_im – Imag part of Scalar a
  • x – TPSA x
  • b_re – Real part of Scalar b
  • b_im – Imag part of Scalar b
  • y – TPSA y
  • c_re – Real part of Scalar c
  • c_im – Imag part of Scalar c
  • z – TPSA z

Output

  • r – Destination TPSA r
source
GTPSA.mad_ctpsa_axpb!Function
mad_ctpsa_axpb!(a::ComplexF64, x::ComplexTPS, b::ComplexF64, r::ComplexTPS)

r = a*x + b

Input

  • a – Scalar a
  • x – TPSA x
  • b – Scalar b

Output

  • r – Destination TPSA r
source
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 Scalar a
  • a_im – Imag part of Scalar a
  • x – TPSA x
  • b_re – Real part of Scalar b
  • b_im – Imag part of Scalar b

Output

  • r – Destination TPSA r
source
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 – Scalar a
  • x – TPSA x
  • b – Scalar b
  • y – TPSA y
  • c – Scalar c

Output

  • r – Destination TPSA r
source
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 Scalar a
  • a_im – Imag part of Scalar a
  • x – TPSA x
  • b_re – Real part of Scalar b
  • b_im – Imag part of Scalar b
  • y – TPSA y
  • c_re – Real part of Scalar c
  • c_im – Imag part of Scalar c

Output

  • r – Destination TPSA r
source
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 – TPSA x
  • a – Scalar a
  • b – Scalar b
  • c – Scalar c

Output

  • r – Destination TPSA r
source
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 Scalar a
  • a_im – Imag part of Scalar a
  • b_re – Real part of Scalar b
  • b_im – Imag part of Scalar b
  • c_re – Real part of Scalar c
  • c_im – Imag part of Scalar c

Output

  • r – Destination TPSA r
source
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 – Scalar a
  • x – TPSA x
  • y – TPSA y
  • b – Scalar b

Output

  • r – Destination TPSA r
source
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 Scalar a
  • a_im – Imag part of Scalar a
  • x – TPSA x
  • y – TPSA y
  • b_re – Real part of Scalar b
  • b_im – Imag part of Scalar b

Output

  • r – Destination TPSA r
source
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 – Scalar a
  • x – TPSA x
  • y – TPSA y
  • b – Scalar b
  • v – TPSA v
  • w – TPSA w
  • c – Scalar c

Output

  • r – Destination TPSA r
source
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 Scalar a
  • a_im – Imag part of Scalar a
  • x – TPSA x
  • y – TPSA y
  • b_re – Real part of Scalar b
  • b_im – Imag part of Scalar b
  • v – TPSA v
  • w – TPSA w
  • c_re – Real part of Scalar c
  • c_im – Imag part of Scalar c

Output

  • r – Destination TPSA r
source
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 – Scalar a
  • x – TPSA x
  • y – TPSA y
  • b – Scalar b
  • z – TPSA z
  • c – Scalar c

Output

  • r – Destination TPSA r
source
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 Scalar a
  • a_im – Imag part of Scalar a
  • x – TPSA x
  • y – TPSA y
  • b_re – Real part of Scalar b
  • b_im – Imag part of Scalar b
  • z – TPSA z
  • c_re – Real part of Scalar c
  • c_im – Imag part of Scalar c

Output

  • r – Destination TPSA r
source
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} with r = |t|
source
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} with r = carg(t)
source
GTPSA.mad_ctpsa_clrord!Function
mad_ctpsa_clrord!(t::ComplexTPS, ord::Cuchar)

Clears all monomial coefficients of the TPSA at order ord

Input

  • t – TPSA
  • ord – Order to clear monomial coefficients
source
GTPSA.mad_ctpsa_compose!Function
mad_ctpsa_compose!(na::Cint, ma, nb::Cint, mb, mc)

Composes two maps.

Input

  • na – Number of TPSAs in Map ma
  • ma – Map ma
  • nb – Number of TPSAs in Map mb
  • mb – Map mb

Output

  • mc – Composition of maps ma and mb
source
GTPSA.mad_ctpsa_conj!Function
mad_ctpsa_conj(a::ComplexTPS, c::ComplexTPS)

Calculates the complex conjugate of of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = conj(a)
source
GTPSA.mad_ctpsa_convert!Function
mad_ctpsa_convert!(t::ComplexTPS, r::ComplexTPS, n::Cint, t2r_::Vector{Cint}, pb::Cint)

General function to convert TPSAs to different orders and reshuffle canonical coordinates. The destination TPSA will be of order n, and optionally have the variable reshuffling defined by t2r_ and poisson bracket sign. e.g. if t2r_ = {1,2,3,4,6,5} and pb = -1, canonical coordinates 6 and 5 are swapped and the new 5th canonical coordinate will be negated. Useful for comparing with different differential algebra packages.

Input

  • t – Source complex TPSA
  • n – Length of vector
  • t2r_ – (Optional) Vector of index lookup
  • pb – Poisson bracket, 0, 1:fwd, -1:bwd

Output

  • r – Destination complex TPSA with specified order and canonical coordinate reshuffling.
source
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
source
GTPSA.mad_ctpsa_cos!Function
mad_ctpsa_cos!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the cos of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = cos(a)
source
GTPSA.mad_ctpsa_cosh!Function
mad_ctpsa_cosh!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the cosh of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = cosh(a)
source
GTPSA.mad_ctpsa_cot!Function
mad_ctpsa_cot!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the cot of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = cot(a)
source
GTPSA.mad_ctpsa_coth!Function
mad_ctpsa_coth!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the coth of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = coth(a)
source
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 make
  • im_ – Imaginary part of TPS{ComplexF64} to make

Output

  • r – Destination TPS{ComplexF64} with r = re_ + im*im_
source
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 TPSA
  • r – Destination TPSA
  • i – Index of monomial
source
GTPSA.mad_ctpsa_cpym!Function
mad_ctpsa_cpym!(t::ComplexTPS, r::ComplexTPS, n::Cint, m::Vector{Cuchar})

Copies the monomial coefficient at the monomial-as-vector-of-orders m in t into the same monomial coefficient in r

Input

  • t – Source TPSA
  • r – Destination TPSA
  • n – Length of monomial m
  • m – Monomial as vector of orders
source
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 TPSA
  • r – Destination TPSA
  • n – Length of string
  • s – Monomial as string
source
GTPSA.mad_ctpsa_cpysm!Function
mad_ctpsa_cpysm!(t::ComplexTPS, r::ComplexTPS, n::Cint, m::Vector{Cint})

Copies the monomial coefficient at the monomial-as-sparse-monomial m in t into the same monomial coefficient in r

Input

  • t – Source TPSA
  • r – Destination TPSA
  • n – Length of sparse monomial m
  • m – Monomial as sparse-monomial
source
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 TPSA
  • ord – Cut order: 0..-ord or ord..mo

Output

  • r – Destination complex TPSA
source
GTPSA.mad_ctpsa_cycle!Function
mad_ctpsa_cycle!(t::ComplexTPS, i::Cint, n::Cint, m_, v_)::Cint

Used for scanning through each nonzero monomial in the TPSA. Given a starting index (-1 if starting at 0), will optionally fill monomial m_ with the monomial at index i and the value at v_ with the monomials coefficient, and return the next NONZERO monomial index in the TPSA. This is useful for building an iterator through the TPSA.

Input

  • t – TPSA to scan
  • i – Index to start from (-1 to start at 0)
  • n – Size of monomial
  • m_ – (Optional) Monomial to be filled if provided
  • v_ – (Optional) Pointer to value of coefficient

Output

  • i – Index of next nonzero monomial in the TPSA, or -1 if reached the end
source
GTPSA.mad_ctpsa_debugFunction
mad_ctpsa_debug(t::ComplexTPS, name_::Cstring, fnam_::Cstring, line_::Cint, stream_::Ptr{Cvoid})::Cint

Prints TPSA with all information of data structure.

Input

  • t – TPSA
  • name_ – (Optional) Name of TPSA
  • fnam_ – (Optional) File name to print to
  • line_ – (Optional) Line number in file to start at
  • stream_ – (Optional) I/O stream to print to, default is stdout

Output

  • retCint reflecting internal state of TPSA
source
GTPSA.mad_ctpsa_del!Function
mad_ctpsa_del!(t::Ptr{TPS{ComplexF64}})

Calls the destructor for the complex TPSA.

Input

  • t – Complex TPSA to destruct
source
GTPSA.mad_ctpsa_densityFunction
mad_ctpsa_density(t::ComplexTPS, stat_, reset::Bool)::Cdouble

Computes the ratio of nz/nc in [0] U [lo,hi] or stat_

source
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 differentiate
  • iv – Index of variable to take derivative wrt to (e.g. derivative wrt x, iv = 1).

Output

  • c – Destination TPSA
source
GTPSA.mad_ctpsa_derivm!Function
mad_ctpsa_derivm!(a::ComplexTPS, c::ComplexTPS, n::Cint, m::Vector{Cuchar})

Differentiates TPSA with respect to the monomial defined by byte array m.

Input

  • a – Source TPSA to differentiate
  • n – Length of monomial to differentiate wrt
  • m – Monomial to take derivative wrt

Output

  • c – Destination TPSA
source
GTPSA.mad_ctpsa_descFunction
mad_ctpsa_desc(t::ComplexTPS)::Ptr{Desc}

Gets the descriptor for the complex TPSA.

Input

  • t – Complex TPSA

Output

  • ret – Descriptor for the TPSA
source
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 TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c
source
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} a
  • b – Source TPS{Float64} b

Output

  • c – Destination TPS{ComplexF64} c
source
GTPSA.mad_ctpsa_div!Function
mad_ctpsa_div!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)

Sets the destination TPSA c = a / b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a / b
source
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} a
  • b – Source TPS{Float64} b

Output

  • c – Destination TPS{ComplexF64} c = a / b
source
GTPSA.mad_ctpsa_equFunction
mad_ctpsa_equ(a::ComplexTPS, b::ComplexTPS, tol_::Cdouble)::Bool

Checks if the TPSAs a and b are equal within the specified tolerance tol_. If tol_ is not specified, DBL_GTPSA.show_epsILON is used.

Input

  • a – TPSA a
  • b – TPSA b
  • tol_ – (Optional) Difference below which the TPSAs are considered equal

Output

  • ret - True if a == b within tol_
source
GTPSA.mad_ctpsa_equtFunction
mad_ctpsa_equt(a::ComplexTPS, b::RealTPS, tol::Cdouble)::Bool

Checks 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} a
  • b – TPS{Float64} b
  • tol_ – (Optional) Difference below which the TPSAs are considered equal

Output

  • ret - True if a == b within tol_
source
GTPSA.mad_ctpsa_erf!Function
mad_ctpsa_erf!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the erf of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = erf(a)
source
GTPSA.mad_ctpsa_erfc!Function
mad_ctpsa_erfc!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the erfc of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = erfc(a)
source
GTPSA.mad_ctpsa_eval!Function
mad_ctpsa_eval!(na::Cint, ma::Vector{TPS{ComplexF64}}, nb::Cint, tb::Vector{ComplexF64}, tc::Vector{ComplexF64})

Evaluates the map at the point tb

Input

  • na – Number of TPSAs in the map
  • ma – Map ma
  • nb – Length of tb
  • tb – Point at which to evaluate the map

Output

  • tc – Values for each TPSA in the map evaluated at the point tb
source
GTPSA.mad_ctpsa_exp!Function
mad_ctpsa_exp!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the exp of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = exp(a)
source
GTPSA.mad_ctpsa_exppb!Function
mad_ctpsa_exppb!(na::Cint, ma::Vector{TPS{ComplexF64}}, mb::Vector{TPS{ComplexF64}}, mc::Vector{TPS{ComplexF64}})

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 of ma and mb
  • ma – Vector of TPSA ma
  • mb – Vector of TPSA mb

Output

  • mc – Destination vector of TPSA mc
source
GTPSA.mad_ctpsa_fgrad!Function
mad_ctpsa_fgrad!(na::Cint, ma::Vector{TPS{ComplexF64}}, b::ComplexTPS, c::ComplexTPS)

Calculates dot(ma, grad(b))

Input

  • na – Length of ma consistent with number of variables in b
  • ma – Vector of TPSA
  • b – TPSA

Output

  • cdot(ma, grad(b))
source
GTPSA.mad_ctpsa_fld2vec!Function
mad_ctpsa_fld2vec!(na::Cint, ma::Vector{TPS{ComplexF64}}, 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 in ma consistent with number of variables in c
  • ma – Vector field

Output

  • c – Hamiltonian as a TPSA derived from the vector field ma
source
GTPSA.mad_ctpsa_getiFunction
mad_ctpsa_geti(t::ComplexTPS, i::Cint)::ComplexF64

Gets the coefficient of the monomial at index i. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • i – Monomial index

Output

  • ret – Coefficient of monomial at index i
source
GTPSA.mad_ctpsa_geti_r!Function
mad_ctpsa_geti_r!(t::ComplexTPS, i::Cint,  r::Ref{ComplexF64})

Gets the coefficient of the monomial at index i in place. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • i – Monomial index

Output

  • r – Coefficient of monomial at index i
source
GTPSA.mad_ctpsa_getmFunction
mad_ctpsa_getm(t::ComplexTPS, n::Cint, m::Vector{Cuchar})::ComplexF64

Gets the coefficient of the monomial m defined as a byte array. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as byte array

Output

  • ret – Coefficient of monomial m in TPSA
source
GTPSA.mad_ctpsa_getm_r!Function
mad_ctpsa_getm_r!(t::ComplexTPS, n::Cint, m::Vector{Cuchar}, r::Ref{ComplexF64})

Gets the coefficient of the monomial m defined as a byte array in place. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as byte array

Output

  • r – Coefficient of monomial m in TPSA
source
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 TPSA
  • ord – Order to retrieve

Output

  • r – Destination complex TPSA
source
GTPSA.mad_ctpsa_getsFunction
mad_ctpsa_gets(t::ComplexTPS, n::Cint, s::Cstring)::ComplexF64

Gets the coefficient of the monomial s defined as a string. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Size of monomial
  • s – Monomial as string

Output

  • ret – Coefficient of monomial s in TPSA
source
GTPSA.mad_ctpsa_gets_r!Function
mad_ctpsa_gets_r!(t::ComplexTPS, n::Cint, s::Cstring, r::Ref{ComplexF64})

Gets the coefficient of the monomial s defined as a string in place. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Length of monomial
  • s – Monomial as string

Output

  • r – Coefficient of monomial s in TPSA
source
GTPSA.mad_ctpsa_getsmFunction
mad_ctpsa_getsm(t::ComplexTPS, n::Cint, m::Vector{Cint})::ComplexF64

Gets the coefficient of the monomial m defined as a sparse monomial. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as sparse monomial

Output

  • ret – Coefficient of monomial m in TPSA
source
GTPSA.mad_ctpsa_getsm_r!Function
mad_ctpsa_getsm_r!(t::ComplexTPS, n::Cint, m::Vector{Cint}, r::Ref{ComplexF64})

Gets the coefficient of the monomial m defined as a sparse monomial in place. Generally should use mad_tpsa_cycle instead of this.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as sparse monomial

Output

  • r – Coefficient of monomial m in TPSA
source
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 – TPSA
  • i – Starting index of monomials to get coefficients
  • n – Number of monomials to get coefficients of starting at i

Output

  • v – Array of coefficients for monomials i..i+n
source
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 TPSA x
  • y – Source TPSA y

Output

  • r – Destination TPSA sqrt(real(x)^2+real(y)^2) + im*sqrt(imag(x)^2+imag(y)^2)
source
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 TPSA x
  • y – Source TPSA y
  • z – Source TPSA z

Output

  • r – Destination TPSA r = sqrt(x^2+y^2+z^2)
source
GTPSA.mad_ctpsa_idxmFunction
mad_ctpsa_idxm(t::ComplexTPS, n::Cint, m::Vector{Cuchar})::Cint

Returns index of monomial in the TPSA given the monomial as a byte array. This generally should not be used, as there are no assumptions about which monomial is attached to which index.

Input

  • t – TPSA
  • n – Length of monomial
  • s – Monomial as byte array

Output

  • ret – Index of monomial in TPSA
source
GTPSA.mad_ctpsa_idxsFunction
mad_ctpsa_idxs(t::ComplexTPS, n::Cint, s::Cstring)::Cint

Returns index of monomial in the TPSA given the monomial as string. This generally should not be used, as there are no assumptions about which monomial is attached to which index.

Input

  • t – TPSA
  • n – Length of monomial
  • s – Monomial as string

Output

  • ret – Index of monomial in TPSA
source
GTPSA.mad_ctpsa_idxsmFunction
mad_ctpsa_idxsm(t::ComplexTPS, n::Cint, m::Vector{Cint})::Cint

Returns index of monomial in the TPSA given the monomial as a sparse monomial. This generally should not be used, as there are no assumptions about which monomial is attached to which index.

Input

  • t – TPSA
  • n – Length of monomial
  • s – Monomial as sparse monomial

Output

  • ret – Index of monomial in TPSA
source
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} with r = Im(t)
source
GTPSA.mad_ctpsa_init!Function
mad_ctpsa_init(t::ComplexTPS, d::Ptr{Desc}, mo::Cuchar)::ComplexTPS

Unsafe initialization of an already existing TPSA t with maximum order mo to the descriptor d. mo must be less than the maximum order of the descriptor. t is modified in place and also returned.

Input

  • t – TPSA to initialize to descriptor d
  • d – Descriptor
  • mo – Maximum order of the TPSA (must be less than maximum order of the descriptor)

Output

  • t – TPSA initialized to descriptor d with maximum order mo
source
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 integrate
  • iv – Index of variable to integrate over (e.g. integrate over x, iv = 1).

Output

  • c – Destination TPSA
source
GTPSA.mad_ctpsa_inv!Function
mad_ctpsa_inv!(a::ComplexTPS,  v::ComplexF64, c::ComplexTPS)

Sets TPSA c to v/a.

Input

  • a – Source TPSA a
  • v – Scalar with double precision

Output

  • c – Destination TPSA c = v/a
source
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 TPSA a
  • v_re – Real part of scalar with double precision
  • v_im – Imaginary part of scalar with double precision

Output

  • c – Destination TPSA c = v*a
source
GTPSA.mad_ctpsa_invsqrt!Function
mad_ctpsa_invsqrt!(a::ComplexTPS, v::ComplexF64, c::ComplexTPS)

Sets TPSA c to v/sqrt(a).

Input

  • a – Source TPSA a
  • v – Scalar with double precision

Output

  • c – Destination TPSA c = v/sqrt(a)
source
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 TPSA a
  • v_re – Real part of scalar with double precision
  • v_im – Imaginary part of scalar with double precision

Output

  • c – Destination TPSA c = v*a
source
GTPSA.mad_ctpsa_isnulFunction
mad_ctpsa_isnul(t::ComplexTPS)::Bool

Checks if TPSA is 0 or not

Input

  • t – Complex TPSA to check

Output

  • ret – True or false
source
GTPSA.mad_ctpsa_isvalFunction
mad_ctpsa_isval(t::ComplexTPS)::Bool

Sanity check of the TPSA integrity.

Input

  • t – TPSA to check if valid

Output

  • ret – True if valid TPSA, false otherwise
source
GTPSA.mad_ctpsa_isvalidFunction
mad_ctpsa_isvalid(t::ComplexTPS)::Bool

Sanity check of the TPSA integrity.

Input

  • t – Complex TPSA to check if valid

Output

  • ret – True if valid TPSA, false otherwise
source
GTPSA.mad_ctpsa_lenFunction
mad_ctpsa_len(t::ComplexTPS, hi_::Bool)::Cint

Gets the length of the TPSA itself (e.g. the descriptor may be order 10 but TPSA may only be order 2)

Input

  • t – Complex TPSA
  • hi_ – If true, returns the length up to the hi order in the TPSA, else up to mo. Default is false

Output

  • ret – Length of TPS{ComplexF64}
source
GTPSA.mad_ctpsa_liebra!Function
mad_ctpsa_liebra!(na::Cint, ma::Vector{TPS{ComplexF64}}, mb::Vector{TPS{ComplexF64}}, mc::Vector{TPS{ComplexF64}})

Computes the Lie bracket of the vector fields ma and mb, defined as sumi mai (dmb/dxi) - mbi (dma/dx_i).

Input

  • na – Length of ma and mb
  • ma – Vector of TPSA ma
  • mb – Vector of TPSA mb

Output

  • mc – Destination vector of TPSA mc
source
GTPSA.mad_ctpsa_log!Function
mad_ctpsa_log!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the log of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = log(a)
source
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 – TPSA x
  • a – Scalar a
  • b – Scalar b
  • c – Scalar c

Output

  • r – Destination TPSA r
source
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 Scalar a
  • a_im – Imag part of Scalar a
  • b_re – Real part of Scalar b
  • b_im – Imag part of Scalar b
  • c_re – Real part of Scalar c
  • c_im – Imag part of Scalar c

Output

  • r – Destination TPSA r
source
GTPSA.mad_ctpsa_logpb!Function
mad_ctpsa_logpb!(na::Cint, ma::Vector{TPS{ComplexF64}}, mb::Vector{TPS{ComplexF64}}, mc::Vector{TPS{ComplexF64}})

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 of ma and mb
  • ma – Vector of TPSA ma
  • mb – Vector of TPSA mb

Output

  • mc – Destination vector of TPSA mc
source
GTPSA.mad_ctpsa_logxdy!Function
mad_ctpsa_logxdy!(x::ComplexTPS, y::ComplexTPS, r::ComplexTPS)

r = log(x / y)

Input

  • x – TPSA x
  • y – TPSA y

Output

  • r – Destination TPSA r
source
GTPSA.mad_ctpsa_maxordFunction
mad_ctpsa_maxord(t::ComplexTPS, n::Cint, idx_::Vector{Cint})::Cint

Returns the index to the monomial with maximum abs(coefficient) in the TPSA for all orders 0 to n. If idx_ is provided, it is filled with the indices for the maximum abs(coefficient) monomial for each order up to n.

Input

  • t – Complex TPSA
  • n – Highest order to include in finding the maximum abs(coefficient) in the TPSA, length of idx_ if provided

Output

  • idx_ – (Optional) If provided, is filled with indices to the monomial for each order up to n with maximum abs(coefficient)
  • mi – Index to the monomial in the TPSA with maximum abs(coefficient)
source
GTPSA.mad_ctpsa_mconv!Function
mad_ctpsa_mconv!(na::Cint, ma::Vector{TPS{ComplexF64}}, nc::Cint, mc::Vector{TPS{ComplexF64}}, n::Cint, t2r_::Vector{Cint}, pb::Cint)

Equivalent to mad_tpsa_convert, but applies the conversion to all TPSAs in the map ma.

Input

  • na – Number of TPSAs in the map
  • ma – Map ma
  • nc – Number of TPSAs in the output map mc
  • n – Length of vector (size of t2r_)
  • t2r_ – (Optional) Vector of index lookup
  • pb – Poisson bracket, 0, 1:fwd, -1:bwd

Output

  • mc – Map mc with specified conversions
source
GTPSA.mad_ctpsa_minv!Function
mad_ctpsa_minv!(na::Cint, ma::Vector{TPS{ComplexF64}}, nb::Cint, mc::Vector{TPS{ComplexF64}})

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 be nn to include parameters)
  • ma – Map ma
  • nb – Output map length (generally = nv)

Output

  • mc – Inversion of map ma
source
GTPSA.mad_ctpsa_mnrmFunction
mad_ctpsa_mnrm(na::Cint, ma::Vector{TPS{ComplexF64}})::Cdouble

Computes the norm of the map (sum of absolute value of coefficients of all TPSAs in the map).

Input

  • na – Number of TPSAs in the map
  • ma – Map ma

Output

  • nrm – Norm of map (sum of absolute value of coefficients of all TPSAs in the map)
source
GTPSA.mad_ctpsa_mo!Function
mad_ctpsa_mo!(t::ComplexTPS, mo::Cuchar)::Cuchar

Sets 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 – TPSA
  • mo_ – Maximum order to set the TPSA

Output

  • ret – Original mo of the TPSA
source
GTPSA.mad_ctpsa_mono!Function
mad_ctpsa_mono!(t::ComplexTPS, i::Cint, n::Cint, m_::Vector{Cuchar}, p_::Vector{Cuchar})::Cuchar

Returns the order of the monomial at index i in the TPSA and optionally the monomial at that index is returned in m_ and the order of parameters in the monomial in p_

Input

  • t – TPSA
  • i – Index valid in TPSA
  • n – Length of monomial

Output

  • m_ – (Optional) Monomial at index i in TPSA
  • p_ – (Optional) Order of parameters in monomial
  • ret – Order of monomial in TPSA a index i
source
GTPSA.mad_ctpsa_mordFunction
mad_ctpsa_mord(na::Cint, ma::Vector{TPS{ComplexF64}}, hi::Bool)::Cuchar

If 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 map ma
  • ma – Map (vector of TPSAs)
  • hi – If true, returns maximum hi, else returns maximum mo of the map

Output

  • ret – Maximum hi of the map if hi is true, else returns maximum mo of the map
source
GTPSA.mad_ctpsa_mul!Function
mad_ctpsa_mul!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)

Sets the destination TPSA c = a * b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a * b
source
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} a
  • b – Source TPS{Float64} b

Output

  • c – Destination TPS{ComplexF64} c = a * b
source
GTPSA.mad_ctpsa_namFunction
mad_ctpsa_nam(t::ComplexTPS, nam_::Cstring)::Cstring

Get the name of the TPSA, and will optionally set if nam_ != null

Input

  • t – TPSA
  • nam_ – Optional name to set the TPSA

Output

  • ret – Name of TPS{ComplexF64} (Null terminated in C)
source
GTPSA.mad_ctpsa_newFunction
mad_ctpsa_new(t::Ptr{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 – TPSA
  • mo – Maximum order of new TPSA

Output

  • ret – New blank TPSA with maximum order mo
source
GTPSA.mad_ctpsa_newdFunction
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 – Descriptor
  • mo – Maximum order

Output

  • t – New complex TPSA defined by the descriptor
source
GTPSA.mad_ctpsa_nrmFunction
mad_ctpsa_nrm(a::ComplexTPS)::Cdouble

Calculates the 1-norm of TPSA a (sum of abs of all coefficients)

Input

  • a – TPSA

Output

  • nrm – 1-Norm of TPSA a
source
GTPSA.mad_ctpsa_ordFunction
mad_ctpsa_ord(t::ComplexTPS, hi_::Bool)::Cuchar

Gets the TPSA maximum order, or hi if hi_ is true.

Input

  • t – TPSA
  • hi_ – Set true if hi is returned, else mo is returned

Output

  • ret – Order of TPSA
source
GTPSA.mad_ctpsa_ordvFunction
mad_ctpsa_ordv(t::ComplexTPS, ts::ComplexTPS...)::Cuchar

Returns maximum order of all TPSAs provided.

Input

  • t – TPSA
  • ts – Variable number of TPSAs passed as parameters

Output

  • mo – Maximum order of all TPSAs provided
source
GTPSA.mad_ctpsa_pminv!Function
mad_ctpsa_pminv!(na::Cint, ma::Vector{TPS{ComplexF64}}, nb::Cint, mc::Vector{TPS{ComplexF64}}, select::Vector{Cint})

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 be nn to include parameters)
  • ma – Map ma
  • nb – 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
source
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 TPSA a
  • b – Source TPSA b
  • nv – Number of variables in the TPSA

Output

  • c – Destination TPSA c
source
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} a
  • b – Source TPS{Float64} b
  • nv – Number of variables in the TPSA

Output

  • c – Destination TPS{ComplexF64} c
source
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}
source
GTPSA.mad_ctpsa_pow!Function
mad_ctpsa_pow!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)

Sets the destination TPSA c = a ^ b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a ^ b
source
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 TPSA a
  • n – Integer power

Output

  • c – Destination TPSA c = a ^ n
source
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 TPSA a
  • v – Power, ComplexF64

Output

  • c – Destination TPSA c = a ^ v
source
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 TPSA a
  • v_re – Real part of power
  • v_im – Imaginary part of power

Output

  • c – Destination TPSA c = a ^ v
source
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} a
  • b – Source TPS{Float64} b

Output

  • c – Destination TPS{ComplexF64} c = a ^ b
source
GTPSA.mad_ctpsa_printFunction
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 print
  • name_ – (Optional) Name of TPSA
  • eps_ – (Optional) Precision to output
  • nohdr_ – (Optional) If True, no header is printed
  • stream_ – (Optional) FILE pointer of output stream. Default is stdout
source
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} with r = Re(t)
source
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}
source
GTPSA.mad_ctpsa_scanFunction
mad_ctpsa_scan(stream_::Ptr{Cvoid})::ComplexTPS

Scans in a TPSA from the stream_.

Input

  • stream_ – (Optional) I/O stream from which to read the TPSA, default is stdin

Output

  • t – TPSA scanned from I/O stream_
source
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 is stdin

Output

  • t – TPSA with coefficients scanned from stream_
source
GTPSA.mad_ctpsa_scan_hdrFunction
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 TPSA
  • stream_ – (Optional) I/O stream to read TPSA from, default is stdin

Output

  • ret – Descriptor for the TPSA
source
GTPSA.mad_ctpsa_scl!Function
mad_ctpsa_scl!(a::ComplexTPS, v::ComplexF64, c::ComplexTPS)

Sets TPSA c to v*a.

Input

  • a – Source TPSA a
  • v – Scalar with double precision

Output

  • c – Destination TPSA c = v*a
source
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 TPSA a
  • v_re – Real part of scalar with double precision
  • v_im – Imaginary part of scalar with double precision

Output

  • c – Destination TPSA c = v*a
source
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 TPSA
  • inv – Put order up, divide, scale by inv of value of order
  • prm – 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
source
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 – TPSA
  • i – Index of monomial
  • a – Scaling of current coefficient
  • b – Constant added to current coefficient
source
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 – TPSA
  • i – Index of monomial
  • a_re – Real part of a
  • a_im – Imaginary part of a
  • b_re – Real part of b
  • b_im – Imaginary part of b
source
GTPSA.mad_ctpsa_setm!Function
mad_ctpsa_setm!(t::ComplexTPS, n::Cint, m::Vector{Cuchar}, a::ComplexF64, b::ComplexF64)

Sets the coefficient of monomial defined by byte array m to coef = a*coef + b. Does not modify other values in TPSA.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as byte array
  • a – Scaling of current coefficient
  • b – Constant added to current coefficient
source
GTPSA.mad_ctpsa_setm_r!Function
mad_ctpsa_setm_r!(t::ComplexTPS, n::Cint, m::Vector{Cuchar}, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble)

Sets the coefficient of monomial defined by byte array m to coef = a*coef + b. Does not modify other values in TPSA. Equivalent to mad_ctpsa_setm but without complex-by-value arguments.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as byte array
  • a_re – Real part of a
  • a_im – Imaginary part of a
  • b_re – Real part of b
  • b_im – Imaginary part of b
source
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 – TPSA
  • v – 0th order value (coefficient)
  • ip – Parameter index (e.g. iv = 1 is nn-nv+1)
source
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 TPSA
  • v_re – Real part of 0th order value
  • v_im – Imaginary part of 0th order value
  • ip – Parameter index
source
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 – TPSA
  • n – Length of monomial
  • s – Monomial as string
  • a – Scaling of current coefficient
  • b – Constant added to current coefficient
source
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 – TPSA
  • n – Length of monomial
  • s – Monomial as string
  • a_re – Real part of a
  • a_im – Imaginary part of a
  • b_re – Real part of b
  • b_im – Imaginary part of b
source
GTPSA.mad_ctpsa_setsm!Function
mad_ctpsa_setsm!(t::ComplexTPS, n::Cint, m::Vector{Cint}, a::ComplexF64, b::ComplexF64)

Sets the coefficient of monomial defined by sparse monomial m to coef = a*coef + b. Does not modify other values in TPSA.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as sparse monomial
  • a – Scaling of current coefficient
  • b – Constant added to current coefficient
source
GTPSA.mad_ctpsa_setsm_r!Function
mad_ctpsa_setsm_r!(t::ComplexTPS, n::Cint, m::Vector{Cint}, a_re::Cdouble, a_im::Cdouble, b_re::Cdouble, b_im::Cdouble)

Sets the coefficient of monomial defined by sparse monomial m to coef = a*coef + b. Does not modify other values in TPSA. Equivalent to mad_ctpsa_setsm but without complex-by-value arguments.

Input

  • t – TPSA
  • n – Length of monomial
  • m – Monomial as sparse monomial
  • a_re – Real part of a
  • a_im – Imaginary part of a
  • b_re – Real part of b
  • b_im – Imaginary part of b
source
GTPSA.mad_ctpsa_setv!Function
mad_ctpsa_setv!(t::ComplexTPS, i::Cint, n::Cint, v::Vector{ComplexF64})

Vectorized setter of the coefficients for monomials with indices i..i+n. Useful for putting a matrix into a map.

Input

  • t – TPSA
  • i – Starting index of monomials to set coefficients
  • n – Number of monomials to set coefficients of starting at i
  • v – Array of coefficients for monomials i..i+n
source
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 scalar
  • v – Scalar value to set TPSA
source
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 scalar
  • v_re – Real part of scalar value to set TPSA
  • v_im – Imaginary part of scalar value to set TPSA
source
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 – TPSA
  • v – 0th order value (coefficient)
  • iv – Variable index
  • scl_ – 1st order variable value (typically will be 1)
source
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 TPSA
  • v_re – Real part of 0th order value
  • v_im – Imaginary part of 0th order value
  • iv – Variable index
  • scl_re_ – (Optional) Real part of 1st order variable value
  • scl_im_ – (Optional)Imaginary part of 1st order variable value
source
GTPSA.mad_ctpsa_sin!Function
mad_ctpsa_sin!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the sin of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sin(a)
source
GTPSA.mad_ctpsa_sinc!Function
mad_ctpsa_sinc!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the sinc of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sinc(a)
source
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 TPSA a

Output

  • s – Destination TPSA s = sin(a)
  • c – Destination TPSA c = cos(a)
source
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 TPSA a

Output

  • s – Destination TPSA s = sinh(a)
  • c – Destination TPSA c = cosh(a)
source
GTPSA.mad_ctpsa_sinh!Function
mad_ctpsa_sinh!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the sinh of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sinh(a)
source
GTPSA.mad_ctpsa_sinhc!Function
mad_ctpsa_sinhc!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the sinhc of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sinhc(a)
source
GTPSA.mad_ctpsa_sqrt!Function
mad_ctpsa_sqrt!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the sqrt of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = sqrt(a)
source
GTPSA.mad_ctpsa_sub!Function
mad_ctpsa_sub!(a::ComplexTPS, b::ComplexTPS, c::ComplexTPS)

Sets the destination TPSA c = a - b

Input

  • a – Source TPSA a
  • b – Source TPSA b

Output

  • c – Destination TPSA c = a - b
source
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} a
  • b – Source TPS{Float64} b

Output

  • c – Destination TPS{ComplexF64} c = a - b
source
GTPSA.mad_ctpsa_tan!Function
mad_ctpsa_tan!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the tan of TPSA a.

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = tan(a)
source
GTPSA.mad_ctpsa_tanh!Function
mad_ctpsa_tanh!(a::ComplexTPS, c::ComplexTPS)

Sets TPSA c to the tanh of TPSA a

Input

  • a – Source TPSA a

Output

  • c – Destination TPSA c = tanh(a)
source
GTPSA.mad_ctpsa_taylor!Function
mad_ctpsa_taylor!(a::ComplexTPS, n::Cint, coef::Vector{ComplexF64}, 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 – TPSA a
  • nOrder-1 of Taylor expansion, size of coef array
  • coef – Array of coefficients in Taylor s
  • c – Result
source
GTPSA.mad_ctpsa_taylor_h!Function
mad_ctpsa_taylor_h!(a::ComplexTPS, n::Cint, coef::Vector{ComplexF64}, 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 – TPSA a
  • nOrder-1 of Taylor expansion, size of coef array
  • coef – Array of coefficients in Taylor s
  • c – Result
source
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} a
  • b – Source TPS{ComplexF64} b

Output

  • c – Destination TPS{ComplexF64} c
source
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} a
  • b – Source TPS{ComplexF64} b

Output

  • c – Destination TPS{ComplexF64} c = a / b
source
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} a
  • b – Source TPS{ComplexF64} b
  • nv – Number of variables in the TPSA

Output

  • c – Destination TPS{ComplexF64} c
source
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} a
  • b – Source TPS{ComplexF64} b

Output

  • c – Destination TPSA c = a ^ b
source
GTPSA.mad_ctpsa_translate!Function
mad_ctpsa_translate!(na::Cint, ma::Vector{TPS{ComplexF64}}, nb::Cint, tb::Vector{ComplexF64}, mc::Vector{TPS{ComplexF64}})

Translates the expansion point of the map by the amount tb.

Input

  • na – Number of TPSAS in the map
  • ma – Map ma
  • nb – Length of tb
  • tb – Vector of amount to translate for each variable

Output

  • mc – Map evaluated at the new point translated tb from the original evaluation point
source
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} a
  • b – Source TPS{ComplexF64} b

Output

  • c – Destination TPS{ComplexF64} c = a - b
source
GTPSA.mad_ctpsa_uid!Function
mad_ctpsa_uid!(t::ComplexTPS, uid_::Cint)::Cint

Sets the TPSA uid if uid_ != 0, and returns the current (previous if set) TPSA uid.

Input

  • t – Complex TPSA
  • uid_uid to set in the TPSA if uid_ != 0

Output

  • ret – Current (previous if set) TPSA uid
source
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 TPSA a

Output

  • c – Destination TPSA c
source
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.

source
GTPSA.mad_ctpsa_vec2fld!Function
mad_ctpsa_vec2fld!(na::Cint, a::ComplexTPS, mc::Vector{TPS{ComplexF64}})

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 in mc consistent with number of variables in a
  • a – Hamiltonian as a TPSA

Output

  • mc – Vector field derived from a using Hamilton's equations
source