Table of Contents

Class ChebyshevTT

Namespace
ChebyshevSharp
Assembly
ChebyshevSharp.dll

Chebyshev interpolation in Tensor Train (TT) format. For functions of 5+ dimensions where full tensor interpolation is infeasible. Uses TT-Cross to build from O(d * n * r^2) function evaluations instead of O(n^d), then evaluates via TT inner product with Chebyshev polynomial basis.

public class ChebyshevTT
Inheritance
ChebyshevTT
Inherited Members

Constructors

ChebyshevTT(Func<double[], double>, int, double[][], int[], int, double, int)

Create a new ChebyshevTT interpolant.

public ChebyshevTT(Func<double[], double> function, int numDimensions, double[][] domain, int[] nNodes, int maxRank = 10, double tolerance = 1E-06, int maxSweeps = 10)

Parameters

function Func<double[], double>

Function to approximate. Signature: f(point) -> double.

numDimensions int

Number of input dimensions.

domain double[][]

Bounds [lo, hi] for each dimension.

nNodes int[]

Number of Chebyshev nodes per dimension.

maxRank int

Maximum TT rank. Default is 10.

tolerance double

Convergence tolerance for TT-Cross. Default is 1e-6.

maxSweeps int

Maximum number of TT-Cross sweeps. Default is 10.

Properties

CompressionRatio

Ratio of full tensor elements to TT storage elements.

public double CompressionRatio { get; }

Property Value

double

Exceptions

InvalidOperationException

If Build(bool, int?, string) has not been called.

Domain

Bounds [(lo, hi), ...] for each dimension.

public double[][] Domain { get; }

Property Value

double[][]

LoadWarning

Warning message set when loading from a different library version.

public string? LoadWarning { get; }

Property Value

string

MaxRank

Maximum TT rank.

public int MaxRank { get; }

Property Value

int

NNodes

Number of Chebyshev nodes per dimension.

public int[] NNodes { get; }

Property Value

int[]

NumDimensions

Number of input dimensions.

public int NumDimensions { get; }

Property Value

int

TotalBuildEvals

Total number of function evaluations used during build.

public int TotalBuildEvals { get; }

Property Value

int

TtRanks

TT ranks [1, r_1, r_2, ..., r_{d-1}, 1]. Only available after Build(bool, int?, string).

public int[] TtRanks { get; }

Property Value

int[]

Exceptions

InvalidOperationException

If Build(bool, int?, string) has not been called.

Methods

Build(bool, int?, string)

Build TT approximation and convert to Chebyshev coefficient cores.

public void Build(bool verbose = true, int? seed = null, string method = "cross")

Parameters

verbose bool

If true, print build progress.

seed int?

Random seed for TT-Cross initialization. Ignored for method="svd".

method string

"cross" (default) or "svd".

Exceptions

ArgumentException

If method is not "cross" or "svd".

ErrorEstimate()

Estimate interpolation error from Chebyshev coefficient cores. Sum of max|core[:, -1, :]| per dimension.

public double ErrorEstimate()

Returns

double

Exceptions

InvalidOperationException

If Build(bool, int?, string) has not been called.

Eval(double[])

Evaluate at a single point via TT inner product with Chebyshev polynomial basis. Cost: O(d * n * r^2) per point.

public double Eval(double[] point)

Parameters

point double[]

Query point, one coordinate per dimension.

Returns

double

Interpolated value.

Exceptions

InvalidOperationException

If Build(bool, int?, string) has not been called.

EvalBatch(double[,])

Evaluate at multiple points simultaneously. Vectorized TT inner product: 15-20x speedup over calling Eval in a loop.

public double[] EvalBatch(double[,] points)

Parameters

points double[,]

Query points, shape (N, numDimensions).

Returns

double[]

Interpolated values, length N.

Exceptions

InvalidOperationException

If Build(bool, int?, string) has not been called.

EvalMulti(double[], int[][])

Evaluate with finite-difference derivatives at a single point.

public double[] EvalMulti(double[] point, int[][] derivativeOrders)

Parameters

point double[]

Evaluation point.

derivativeOrders int[][]

Each inner array specifies derivative order per dimension. Supports 0 (value), 1 (first), and 2 (second).

Returns

double[]

One result per derivative order specification.

Exceptions

InvalidOperationException

If Build(bool, int?, string) has not been called.

Load(string)

Load a previously saved TT interpolant from a JSON file. The loaded object can evaluate immediately; no rebuild is needed.

public static ChebyshevTT Load(string path)

Parameters

path string

Path to the saved file.

Returns

ChebyshevTT

The restored TT interpolant.

Exceptions

InvalidOperationException

If the file does not contain a valid ChebyshevTT.

Save(string)

Save the built TT interpolant to a JSON file. The original function is not saved — only numerical data needed for evaluation.

public void Save(string path)

Parameters

path string

Destination file path.

Exceptions

InvalidOperationException

If Build(bool, int?, string) has not been called.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.