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
functionFunc<double[], double>Function to approximate. Signature: f(point) -> double.
numDimensionsintNumber of input dimensions.
domaindouble[][]Bounds [lo, hi] for each dimension.
nNodesint[]Number of Chebyshev nodes per dimension.
maxRankintMaximum TT rank. Default is 10.
tolerancedoubleConvergence tolerance for TT-Cross. Default is 1e-6.
maxSweepsintMaximum 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
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
MaxRank
Maximum TT rank.
public int MaxRank { get; }
Property Value
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
TotalBuildEvals
Total number of function evaluations used during build.
public int TotalBuildEvals { get; }
Property Value
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
verboseboolIf true, print build progress.
seedint?Random seed for TT-Cross initialization. Ignored for method="svd".
methodstring"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
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
pointdouble[]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
pointsdouble[,]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
pointdouble[]Evaluation point.
derivativeOrdersint[][]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
pathstringPath 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
pathstringDestination 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.