31 #ifndef __TSG_CORE_ONE_DIMENSIONAL_HPP
32 #define __TSG_CORE_ONE_DIMENSIONAL_HPP
72 if (std::is_same<iomode, IO::mode_ascii_type>::value)
73 read<mode_ascii>(is);
else read<mode_binary>(is);
77 std::vector<std::vector<double>> &&cnodes, std::vector<std::vector<double>> &&cweights,
78 std::string &&cdescription) :
79 num_levels(cnum_nodes.size()), num_nodes(std::move(cnum_nodes)), precision(std::move(cprecision)),
80 nodes(std::move(cnodes)), weights(std::move(cweights)), description(std::move(cdescription))
84 template<
bool useAscii>
void write(std::ostream &os)
const;
86 template<
bool useAscii>
void read(std::istream &is);
89 void read(
const char* filename);
101 void getWeightsNodes(
int level, std::vector<double> &w, std::vector<double> &x)
const;
111 if (level >= num_levels)
112 throw std::runtime_error(std::string(
"ERROR: needed custom rule ") + op +
" with level " + std::to_string(level) +
" but the table ends at " + std::to_string(num_levels - 1));
117 std::vector<int> num_nodes;
118 std::vector<int> precision;
120 std::vector<std::vector<double>> nodes;
121 std::vector<std::vector<double>> weights;
122 std::string description;
138 namespace OneDimensionalMeta{
215 namespace OneDimensionalNodes{
220 void getChebyshev(
int m, std::vector<double> &w, std::vector<double> &x);
226 void getGaussJacobi(
int m, std::vector<double> &w, std::vector<double> &x,
double alpha,
double beta);
228 void getGaussHermite(
int m, std::vector<double> &w, std::vector<double> &x,
double alpha);
230 void getGaussLaguerre(
int m, std::vector<double> &w, std::vector<double> &x,
double alpha);
Class providing manipulation of custom tabulated rules, file I/O and structured access to the points,...
Definition: tsgCoreOneDimensional.hpp:66
void read(const char *filename)
Read from a custom user provided ASCII file, see the file-format section.
int getNumPoints(int level) const
Returns the number of points associated with the selected level.
Definition: tsgCoreOneDimensional.hpp:94
int getQExact(int level) const
Return the exactness of the integration/quadrature rule at level, provided by the user in the custom ...
Definition: tsgCoreOneDimensional.hpp:98
int getNumLevels() const
Returns the number of loaded levels.
Definition: tsgCoreOneDimensional.hpp:92
void write(std::ostream &os) const
Write to an already open ASCII/binary file, used in conjunction with GlobalGrid::write()
void read(std::istream &is)
Read from an already open ASCII/binary file, used in conjunction with GlobalGrid::read()
int getIExact(int level) const
Return the exactness of the interpolation rule at level, usually one less than the number of points.
Definition: tsgCoreOneDimensional.hpp:96
void getWeightsNodes(int level, std::vector< double > &w, std::vector< double > &x) const
Get the points x and quadrature weights w associated with the rule at the level.
CustomTabulated()
Default constructor, create an empty table, need to read from file before any other data can be acces...
Definition: tsgCoreOneDimensional.hpp:69
CustomTabulated(std::vector< int > &&cnum_nodes, std::vector< int > &&cprecision, std::vector< std::vector< double >> &&cnodes, std::vector< std::vector< double >> &&cweights, std::string &&cdescription)
Assume ownership of existing data instead of reading from a file.
Definition: tsgCoreOneDimensional.hpp:76
const char * getDescription() const
Returns the user provided human readable description string.
void getWeightsNodes(int level, double w[], double x[]) const
Overload that writes to an array directly rather than a container. For interface purposes mostly,...
CustomTabulated(std::istream &is, iomode)
Read-constructor.
Definition: tsgCoreOneDimensional.hpp:71
void checkLevel(int level, std::string const &op) const
Throws a std::rumtime_error() if the given level is more than the stored levels, op is used to report...
Definition: tsgCoreOneDimensional.hpp:110
TypeOneDRule
Used to specify the one dimensional family of rules that induces the sparse grid.
Definition: tsgEnumerates.hpp:285
TypeDepth
Used by Global Sequence and Fourier grids, indicates the selection criteria.
Definition: tsgEnumerates.hpp:203
@ type_curved
Ignoring the polynomial space, use rules with index .
Definition: tsgEnumerates.hpp:213
@ type_iptensor
Make a dense tensor grid with interpolation range that includes .
Definition: tsgEnumerates.hpp:245
@ type_qptotal
Total degree polynomial space for quadrature/integration.
Definition: tsgEnumerates.hpp:224
@ type_qpcurved
Curved polynomial space for quadrature/integration.
Definition: tsgEnumerates.hpp:231
@ type_level
Ignoring the polynomial space, use rules with index .
Definition: tsgEnumerates.hpp:209
@ type_qphyperbolic
Hyperbolic cross section polynomial space for quadrature/integration.
Definition: tsgEnumerates.hpp:238
@ type_iptotal
Total degree polynomial space for interpolation, i.e., the span of .
Definition: tsgEnumerates.hpp:221
@ type_qptensor
Make a dense tensor grid with quadrature/integration range that includes .
Definition: tsgEnumerates.hpp:249
@ type_hyperbolic
Ignoring the polynomial space, use rules with index .
Definition: tsgEnumerates.hpp:217
@ type_iphyperbolic
Hyperbolic cross section polynomial space for interpolation, i.e., the span of .
Definition: tsgEnumerates.hpp:235
@ type_tensor
Make a dense tensor grid with rules indexed by .
Definition: tsgEnumerates.hpp:241
@ type_ipcurved
Curved polynomial space for interpolation, i.e., the span of .
Definition: tsgEnumerates.hpp:228
CustomTabulated getSubrules(CustomTabulated &ct, int start_index, int stride, std::string description)
Generates a subset of rules as a CustomTabulated object. The subset has a short description string gi...
void getGaussHermite(int m, std::vector< double > &w, std::vector< double > &x, double alpha)
Generate Gauss-Hermite weights w and points x for (input) number of points m, using parameters alpha.
void getChebyshev(int m, std::vector< double > &w, std::vector< double > &x)
Generate Chebyshev weights w and points x for (input) number of points m.
std::vector< double > getRLejaCentered(int n)
Generate the first n R-Leja nodes, starting with 0, 1, -1, ...
void getGaussChebyshev1(int m, std::vector< double > &w, std::vector< double > &x)
Generate Gauss-Chebyshev type 1 weights w and points x for (input) number of points m.
double getClenshawCurtisWeightZero(int level, int point)
Return the Clenshaw-Curtis zero-boundary condition weight for the level and node indexed by point.
std::vector< double > getClenshawCurtisNodes(int level)
Generate Clenshaw-Curtis nodes for the level.
std::vector< double > getFourierNodes(int level)
Generate the Fourier nodes for the given level, uniformly distributed points with right-most point om...
double getFejer2Weight(int level, int point)
Return the Fejer type 2 weight for the level and node indexed by point.
std::vector< double > getRLejaShifted(int n)
Generate the first n R-Leja nodes, starting with -0.5, 0.5, ...
void getGaussChebyshev2(int m, std::vector< double > &w, std::vector< double > &x)
Generate Gauss-Chebyshev type 2 weights w and points x for (input) number of points m.
void getGaussLegendre(int m, std::vector< double > &w, std::vector< double > &x)
Generate Gauss-Legendre weights w and points x for (input) number of points m.
std::vector< double > getClenshawCurtisNodesZero(int level)
Generate Clenshaw-Curtis zero-boundary condition nodes for the level.
std::vector< double > getFejer2Nodes(int level)
Generate Fejer type 2 nodes for the level.
std::vector< double > getRLeja(int n)
Generate the first n R-Leja nodes, starting with 1, -1, 0, ...
double getClenshawCurtisWeight(int level, int point)
Return the Clenshaw-Curtis weight for the level and node indexed by point.
void getGaussLaguerre(int m, std::vector< double > &w, std::vector< double > &x, double alpha)
Generate Gauss-Laguerre weights w and points x for (input) number of points m, using parameters alpha...
void getGaussJacobi(int m, std::vector< double > &w, std::vector< double > &x, double alpha, double beta)
Generate Gauss-Jacobi weights w and points x for (input) number of points m, using parameters alpha a...
Encapsulates the Tasmanian Sparse Grid module.
Definition: TasmanianSparseGrid.hpp:68
Templates to simply file I/O.
Algorithms for computing greedy sequences.