TPS

Truncated Power Series struct TPS{T<:Union{Float64,ComplexF64},D} <: Number

T is the number type of the monomial coefficients in the TPS. Currently, GTPSA only supports TPSs with Float64 or ComplexF64 monomial coefficients.

D is either a Descriptor (for static Descriptor resolution) or GTPSA.Dynamic (for dynamic Descriptor resolution).

Aliases

const TPS64 = TPS{Float64}
const ComplexTPS64 = TPS{ComplexF64}

Note that TPS{Float64}{D} == TPS{Float64,D} == TPS64{D}. See the Julia documentation for UnionAll types for more details.

Syntax

t = TPS[{descriptor|numtype}]([number] [, use=(descriptor|tps)])

# Static Descriptor resolution:
t = TPS{descriptor}([number])
t = TPS{Float64|ComplexF64, descriptor}([number])

# Dynamic Descriptor resolution:
t = TPS([number] [, use=(descriptor|tps)]) 
t = TPS{Float64|ComplexF64 [, GTPSA.Dynamic]}([number] [, use=(descriptor|tps)]) 

Static Descriptor Resolution

t = TPS{descriptor}([number]) constructs a new TPS using descriptor, equal to number if provided. If number is a TPS and has the same Descriptor, then this is a copy constructor. If number is a TPS and has a different Descriptor, then this will change the Descriptor granted the number of variables + parameters are equivalent. The monomial coefficient number type is inferred from number, defaulting to Float64.

t = TPS{Float64|ComplexF64, descriptor}([number]) is the same as t = TPS{descriptor}([number]) but with the monomial coefficient number type explicitly specified.

Examples


julia> d1 = Descriptor(1, 1); # 1 variable to order 1
julia> t1_1 = TPS{d1}()TPS64{Descriptor(NV=1, MO=1)}: Coefficient Order Exponent 0.0000000000000000e+00 0 0
julia> t2_1 = TPS{d1}(5im)ComplexTPS64{Descriptor(NV=1, MO=1)}: Real Imag Order Exponent 0.0000000000000000e+00 5.0000000000000000e+00 0 0
julia> t3_1 = TPS{d1}(t2_1)ComplexTPS64{Descriptor(NV=1, MO=1)}: Real Imag Order Exponent 0.0000000000000000e+00 5.0000000000000000e+00 0 0
julia> d10 = Descriptor(1, 10); # New Descriptor to order 10
julia> t1_2 = TPS64{d10}() # Uses d10TPS64{Descriptor(NV=1, MO=10)}: Coefficient Order Exponent 0.0000000000000000e+00 0 0
julia> t2_2 = ComplexTPS64{d10}(6)ComplexTPS64{Descriptor(NV=1, MO=10)}: Real Imag Order Exponent 6.0000000000000000e+00 0.0000000000000000e+00 0 0
julia> t3_2 = ComplexTPS64{d10}(t3_1) # Promotes and changes DescriptorComplexTPS64{Descriptor(NV=1, MO=10)}: Real Imag Order Exponent 0.0000000000000000e+00 5.0000000000000000e+00 0 0

Dynamic Descriptor Resolution

t = TPS([number] [, use=(descriptor|tps)]) construct a new TPS, equal to number if provided, and inferring the Descriptor from the input arguments:

Ctor CallDescriptor
TPS()GTPSA.desc_current
TPS(use=descriptor)descriptor
TPS(use=tps1)That of tps1
TPS(tps)That of tps
TPS(number)GTPSA.desc_current
TPS(number, use=(descriptor or tps1) )descriptor or that of tps1
TPS(tps, use=(descriptor or tps1) )descriptor or that of tps1 (copies + changes Descriptor!)

t = TPS{Float64|ComplexF64 [, GTPSA.Dynamic]}([number] [, use=(descriptor|tps)]) is the same as TPS([number] [, use=(descriptor|tps)]) but with the monomial coefficient number type explicitly specified, and optionally the GTPSA.Dynamic dynamic mode identifier explicitly specified.

Optional Keyword Argument

use=(descriptor|tps) creates a new TPS having a Descriptor equal to that passed. If changing the Descriptor of a TPS, the number of variable + number of parameters must be equivalent, and invalid monomials in the new Descriptor will be removed.

Examples


julia> d1 = Descriptor(1, 1); # 1 variable to order 1
julia> t1_1 = TPS()TPS64{GTPSA.Dynamic}: Descriptor(NV=1, MO=1) Coefficient Order Exponent 0.0000000000000000e+00 0 0
julia> t2_1 = TPS(5im)ComplexTPS64{GTPSA.Dynamic}: Descriptor(NV=1, MO=1) Real Imag Order Exponent 0.0000000000000000e+00 5.0000000000000000e+00 0 0
julia> t3_1 = TPS(t2_1)ComplexTPS64{GTPSA.Dynamic}: Descriptor(NV=1, MO=1) Real Imag Order Exponent 0.0000000000000000e+00 5.0000000000000000e+00 0 0
julia> d10 = Descriptor(1, 10); # New Descriptor to order 10
julia> t1_2 = TPS64() # Uses d10TPS64{GTPSA.Dynamic}: Descriptor(NV=1, MO=10) Coefficient Order Exponent 0.0000000000000000e+00 0 0
julia> t2_2 = ComplexTPS64(6)ComplexTPS64{GTPSA.Dynamic}: Descriptor(NV=1, MO=10) Real Imag Order Exponent 6.0000000000000000e+00 0.0000000000000000e+00 0 0
julia> t3_2 = ComplexTPS64(t3_1, use=d10) # Promotes and changes DescriptorComplexTPS64{GTPSA.Dynamic}: Descriptor(NV=1, MO=10) Real Imag Order Exponent 0.0000000000000000e+00 5.0000000000000000e+00 0 0

Documentation

GTPSA.TPSType
TPS{D}([number]) where {D}
TPS{T,D}([number]) where {T<:Union{Float64,ComplexF64}}

TPS([number] [, use=(descriptor|tps)])
TPS{T}([number] [, use=(descriptor|tps)]) where {T<:Union{Float64,ComplexF64}}
TPS{T,GTPSA.Dynamic}([number] [, use=(descriptor|tps)]) where {T<:Union{Float64,ComplexF64}}

Constructor to create a new TPS, equal to number if provided.

A constructed TPS must correspond to some previously defined Descriptor. As such, two "modes" of the TPS type may be constructed to determine how the Descriptor to use is resolved:

  1. Dynamic Descriptor resolution – The Descriptor is inferred at runtime, based on the passed arguments:
Ctor CallDescriptor
TPS()GTPSA.desc_current
TPS(use=descriptor)descriptor
TPS(use=tps1)That of tps1
TPS(tps)That of tps
TPS(number)GTPSA.desc_current
TPS(number, use=(descriptor or tps1) )descriptor or that of tps1
TPS(tps, use=(descriptor or tps1) )descriptor or that of tps1 (copies + changes Descriptor!)

The same applies for all of the above constructor calls with the constructors TPS64(...) and ComplexTPS64(...). The created type will be a TPS{T,GTPSA.Dynamic} where {T<:Union{Float64,ComplexF64}}. Dynamic Descriptor resolution will always be type stable, as the Descriptor for each TPS is not stored in the type definition. E.g., one can have an array with elements of the concrete type TPS{T,GTPSA.Dynamic} even though the individual TPSs in the array may have differing Descriptors. Another example is typing the field of a struct as TPS{T,GTPSA.Dynamic}, so that field can contain TPSs of different Descriptors in a type-stable fashion. However, with dynamic Descriptor resolution the use kwarg must be specified if the Descriptor is both not inferrable nor GTPSA.desc_current is the desired Descriptor. For calls such as zeros(TPS64, N) or TPS64(5.0), only GTPSA.desc_current can be inferred.

  1. Static Descriptor resolution – The Descriptor is stored explicitly in the TPS type:
Ctor CallDescriptor
TPS{descriptor}([number])descriptor
TPS{descriptor2}(::TPS{T,descriptor1})descriptor2 (copies + changes Descriptor!)
TPS(::TPS{T,descriptor})descriptor

The same applies for all of the above constructor calls with the constructors TPS64{...}(...) and ComplexTPS64{...}(...). The created type will be a TPS{T,descriptor} where {T<:Union{Float64,ComplexF64}}. Care must be taken with static Descriptor resolution to ensure type-stability, and in some cases it may not be possible. However, static resolution has the benefit that the Descriptor is stored explicitly in the type. As such, GTPSA.desc_current is never used with this mode, nor is the use kwarg. Calls such as zeros(TPS64{descriptor}, N) can be made ensuring the Descriptor of the output is correct.

source