Slicing and par

Indexing a specific polynomial within the TPS

Slicing a TPS

A polynomial within the TPS with certain variable orders can be extracted by slicing the TPS. When indexing by order, a colon (:) can be used in place for a variable order to include all orders of that variable. If the last specified index is a colon, then the rest of the variable indices are assumed to be colons (else, they are assumed to be zero, following the convention of monomial coefficient indexing).


julia> d = Descriptor(5, 10, 2, 10);
julia> Δx = @vars(d);
julia> Δk = @params(d);
julia> f = 2*Δx[1]^2*Δx[3] + 3*Δx[1]^2*Δx[2]*Δx[3]*Δx[4]^2*Δx[5]*Δk[1] + 6*Δx[3] + 5TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 5.0000000000000000e+00 0 0 0 0 0 0 | 0 0 6.0000000000000000e+00 1 0 0 1 0 0 | 0 0 2.0000000000000000e+00 3 2 0 1 0 0 | 0 0 3.0000000000000000e+00 8 2 1 1 2 1 | 1 0
julia> g = f[[2,:,1]]TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 2.0000000000000000e+00 3 2 0 1 0 0 | 0 0
julia> h = f[[2,:,1,:]]TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 2.0000000000000000e+00 3 2 0 1 0 0 | 0 0 3.0000000000000000e+00 8 2 1 1 2 1 | 1 0

A TPS can also be sliced with indexing by sparse monomial. In this case, if a colon is included anywhere in the sparse monomial variable index, then all orders of all variables and parameters not explicity specified will be included (colon position does not matter in sparse monomial indexing):

julia> g = f[[1=>2, :, 3=>1, 4=>0, 5=>0], params=[1=>0, 2=>0]]TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  2.0000000000000000e+00      3      2   0   1   0   0   |   0   0
julia> h = f[(1=>2, 3=>1, :)] # Colon position is irrelevant in slicing with sparse monomial indexingTPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 2.0000000000000000e+00 3 2 0 1 0 0 | 0 0 3.0000000000000000e+00 8 2 1 1 2 1 | 1 0

When indexing by monomial index, a colon simply needs to be included after the variable index, or just a colon if a parameter is specified:

julia> fΔx3 = f[3,:]TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  6.0000000000000000e+00      1      0   0   1   0   0   |   0   0
  2.0000000000000000e+00      3      2   0   1   0   0   |   0   0
  3.0000000000000000e+00      8      2   1   1   2   1   |   1   0
julia> fΔk1 = f[:,param=1]TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 3.0000000000000000e+00 8 2 1 1 2 1 | 1 0

par

par is very similar to slicing a TPS, with two differences:

  1. The specified variables and parameters are removed from the resulting slice
  2. When indexing by order, a colon is always presumed for unincluded variables/parameters

Syntax

f = par(tps, monomialindex)

Description

Description

monomialindex can be any of kind monomial indexing: by index, by order, and by sparse monomial. See the monomial indexing for more details on each.

Examples


julia> d = Descriptor(5, 10, 2, 10);
julia> Δx = @vars(d);
julia> Δk = @params(d);
julia> f = 2*Δx[1]^2*Δx[3] + 3*Δx[1]^2*Δx[2]*Δx[3]*Δx[4]^2*Δx[5]*Δk[1] + 6*Δx[3] + 5TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 5.0000000000000000e+00 0 0 0 0 0 0 | 0 0 6.0000000000000000e+00 1 0 0 1 0 0 | 0 0 2.0000000000000000e+00 3 2 0 1 0 0 | 0 0 3.0000000000000000e+00 8 2 1 1 2 1 | 1 0
julia> par(f, 3)TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 6.0000000000000000e+00 0 0 0 0 0 0 | 0 0 2.0000000000000000e+00 2 2 0 0 0 0 | 0 0 3.0000000000000000e+00 7 2 1 0 2 1 | 1 0
julia> par(f, param=1)TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 3.0000000000000000e+00 7 2 1 1 2 1 | 0 0
julia> par(f, [2,:,1])TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 2.0000000000000000e+00 0 0 0 0 0 0 | 0 0 3.0000000000000000e+00 5 0 1 0 2 1 | 1 0
julia> par(f, [2,0,1])TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 2.0000000000000000e+00 0 0 0 0 0 0 | 0 0
julia> par(f, [1=>2, 3=>1])TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 2.0000000000000000e+00 0 0 0 0 0 0 | 0 0 3.0000000000000000e+00 5 0 1 0 2 1 | 1 0
julia> par(f, params=[1=>1])TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}: Coefficient Order Exponent 3.0000000000000000e+00 7 2 1 1 2 1 | 0 0

Documentation

GTPSA.parFunction
par(t::TPS, monomialindex)

Extracts a polynomial from the TPS containing the specified monomial, and removes the monomial. Any of the three monomial indexing schemes (by order, sparse monomial, or monomial index – see the Monomial Indexing section of the GTPSA manual for more details) may be used to specify the monomial.

Examples: Variable/Parameter Index:

julia> d = Descriptor(5, 10, 2, 10); Δx = @vars(d); Δk = @params(d);

julia> f = 2*Δx[1]^2*Δx[3] + 3*Δx[1]^2*Δx[2]*Δx[3]*Δx[4]^2*Δx[5]*Δk[1] + 6*Δx[3] + 5
TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  5.0000000000000000e+00      0      0   0   0   0   0   |   0   0
  6.0000000000000000e+00      1      0   0   1   0   0   |   0   0
  2.0000000000000000e+00      3      2   0   1   0   0   |   0   0
  3.0000000000000000e+00      8      2   1   1   2   1   |   1   0


julia> par(f, 3)
TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  6.0000000000000000e+00      0      0   0   0   0   0   |   0   0
  2.0000000000000000e+00      2      2   0   0   0   0   |   0   0
  3.0000000000000000e+00      7      2   1   0   2   1   |   1   0


julia> par(f, param=1)
TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  3.0000000000000000e+00      7      2   1   1   2   1   |   0   0

Examples: Monomial Index-by-Order

julia> par(f, [2,:,1])
TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  2.0000000000000000e+00      0      0   0   0   0   0   |   0   0
  3.0000000000000000e+00      5      0   1   0   2   1   |   1   0


julia> par(f, [2,0,1])
TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  2.0000000000000000e+00      0      0   0   0   0   0   |   0   0

Examples: Monomial Index-by-Sparse Monomial

julia> par(f, [1=>2, 3=>1])
TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  2.0000000000000000e+00      0      0   0   0   0   0   |   0   0
  3.0000000000000000e+00      5      0   1   0   2   1   |   1   0


julia> par(f, params=[1=>1])
TPS64{Descriptor(NV=5, MO=10, NP=2, PO=10)}:
 Coefficient                Order   Exponent
  3.0000000000000000e+00      7      2   1   1   2   1   |   0   0
source