sgpykit.tools.converter_functions
Functions
|
Construct a reduced sparse grid structure from given points and weights. |
|
Convert a tensor grid into a sparse grid structure. |
- sgpykit.tools.converter_functions.asreduced(pts_list, wgs_list=None)[source]
Construct a reduced sparse grid structure from given points and weights.
- Parameters:
- pts_listarray_like
List of knot points. The “knots” field of the returned sparse grid structure is set to this list.
- wgs_listarray_like, optional
List of weights corresponding to the knot points. If provided, the “weights” field of the returned sparse grid structure is set to this list. The default is None.
- Returns:
- Sstruct
A reduced sparse grid structure with the following fields: - knots : array_like
The knot points.
- weightsarray_like
The weights corresponding to the knot points.
- sizeint
The number of knot points.
- nlist
Empty list.
- mlist
Empty list.
- Raises:
- ValueError
If the number of points and weights are different.
Notes
The knots in pts_list are assumed to be all different; the list is not checked for duplicates.
- sgpykit.tools.converter_functions.tensor_to_sparse(T, idx=None)[source]
Convert a tensor grid into a sparse grid structure.
This function converts a tensor grid into a sparse grid structure of the same type as CREATE_SPARSE_GRID, by adding the missing fields.
- Parameters:
- TStruct
The tensor grid to be converted.
- idxarray_like, optional
The index vector. If not provided, it will be computed based on the knots per dimension.
- Returns:
- SStruct or StructArray
The sparse grid structure with added fields.
Notes
- The function copies the fields of T into S and adds the following:
S.coeff = 1
S.idx = vector with idx(i) = length(T.knots_per_dim{i}) if idx is not provided
S.idx = idx if idx is provided