Heterogeneous Sparse Grids¶
-
class
SpectralToolbox.HeterogeneousSparseGrids.
HSparseGrid
(polys, Ns, tol=None, sdout=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>)[source]¶ Bases:
object
Heterogeneous Sparse Grid class
Constructor of Heterogeneous Sparse Grid object (this does not allocate the sparse grid)
Parameters: - polys (list of
Spectral1D.Poly1D
) – orthogonal polynomials to be used as basis functions - Ns (list of integers) – accuracy for each dimension. It can be a list of accuracies or a single accuracy, in which case uniform accuracy is assumed
- tol (float) – tolerance to be used when comparing points of the grid (optional, default=:py:func:Misc.machineEpsilon())
- sdout (stream) – default output stream for the class (optional,default=``sys.stderr``)
Note
one of the following must hold: len(polys)==len(Ns) or len(Ns)==1, in which case the same order is used for all the directions.
Example
>>> from SpectralToolbox import HeterogeneousSparseGrids as HSG >>> pH = Spectral1D.Poly1D(Spectral1D.HERMITEP_PROB,None) >>> pL = Spectral1D.Poly1D(Spectral1D.JACOBI,[0.0,0.0]) >>> polys = [pH,pL] >>> Ns = [2,4] >>> sg = HSG.HSparseGrid(polys,Ns)
-
Ns
= []¶
-
polys
= []¶
-
sdout
= []¶
-
sparseGrid
(heter=False)[source]¶ Generates the full and partial sparse grids
Parameters: heter (bool) – if Ns
is homogeneous, this parameter will force the output of the partial sparse grid as wellReturns: tuple (XF,WF,X)
containing:XF
: full grid pointsWF
: full grid weightsX
: partial grid points
Example
>>> (XF,W,X) = sg.sparseGrid() [SG] Sparse Grid Generation [============================================] 100% [SG] Sparse Grid Generation: 0.01s
-
sparseGridInterp
(X, fX, XF)[source]¶ Interpolate values of the Sparse Grid using 1D Polynomial interpolation along cuts.
Parameters: - X (2d-array of floats) – partial grid on which a function has been evaluated
- fX (1d-array of floats) – values for the points in the partial grid
- XF (2d-array of floats) – full grid on which to interpolate
Returns: fXF
the interpolated values on the full gridReturn type: 1d-array of floats
..note:: The partial and full grid must be overlapping
Example
>>> fXF = sg.sparseGridInterp(X,fX,XF) [SG] Sparse Grid Interpolation [=========================================] 100% [SG] Sparse Grid Interpolation: 0.00s
-
tol
= []¶
- polys (list of