I am using the TaylorSeries package for Taylor polynomial expansions.
There is a type TaylorN in this package, which describes a polynomial with N variable. The number of variables and orders can be set via
using TaylorSeries
x, y = set_variables("x y", order=2);
However, I would like to obtain a composite type, like TaylorN{TaylorN{Float64}}. The outer TaylorN has different orders and number of variables with inner TaylorN.
Let me give you an example
f(x,y)=a_{00}+a_{10}x+a_{01}y+a_{20}x^2+a_{11}xy+a_{02}y^2
The coefficients are controlled by 3 knobs,
a_{ij}(k_1,k_2,k_3)=c_{000}+c_{100}k_1+c_{010}k_2+c_{001}k_3
The following code doesn’t work,
using TaylorSeries
x1,x2=set_variables("x1 x2",numvars=2,order=5)
y1,y2,y3=set_variables("y1 y2 y3",numvars=3,order=4)
# x1 and x2 become invalid, because the above command
# changes the maximum order and number of variables
Therefore, I wonder if there is a way so that
import TaylorSeries as TS1
import TaylorSeries as TS2
x1,x2=TS1.set_variables("x1 x2",numvars=2,order=5)
y1,y2,y3=TS2.set_variables("y1 y2 y3",numvars=3,order=4)
# typeof(x1)=TS1.TaylorN{Float64}
# typeof(y1)=TS2.TaylorN{Float64}
# both x1 and y1 are valid, and their types--- TS1.TalorN and TS2.TaylorN---are different
I have a stupid method to solve this. But it seems weird.
module TS1
include("path to TaylorSeries.jl")
end
module TS2
include("path to TaylorSeries.jl")
end
# Now TaylorN in TS1 and TaylorN in TS2 are two different structs
# and they have their own method of set_variables