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;
138namespace OneDimensionalMeta{
181 inline bool isExactLevel(
TypeDepth type){
186 inline bool isExactInterpolation(
TypeDepth type){
191 inline bool isExactQuadrature(
TypeDepth type){
215namespace OneDimensionalNodes{
218 void getGaussLegendre(
int m, std::vector<double> &w, std::vector<double> &x);
220 void getChebyshev(
int m, std::vector<double> &w, std::vector<double> &x);
222 void getGaussChebyshev1(
int m, std::vector<double> &w, std::vector<double> &x);
224 void getGaussChebyshev2(
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);
234 std::vector<double> getClenshawCurtisNodes(
int level);
236 double getClenshawCurtisWeight(
int level,
int point);
239 std::vector<double> getClenshawCurtisNodesZero(
int level);
241 double getClenshawCurtisWeightZero(
int level,
int point);
244 std::vector<double> getFejer2Nodes(
int level);
246 double getFejer2Weight(
int level,
int point);
249 std::vector<double> getRLeja(
int n);
251 std::vector<double> getRLejaCentered(
int n);
253 std::vector<double> getRLejaShifted(
int n);
256 std::vector<double> getFourierNodes(
int level);
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.
const char * getDescription() const
Returns the user provided human readable description string.
CustomTabulated()
Default constructor, create an empty table, need to read from file before any other data can be acces...
Definition tsgCoreOneDimensional.hpp:69
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::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
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...
Encapsulates the Tasmanian Sparse Grid module.
Definition TasmanianSparseGrid.hpp:68
Templates to simply file I/O.
Algorithms for computing greedy sequences.