Doxygen 1.15.0
Toolkit for Adaptive Stochastic Modeling and Non-Intrusive ApproximatioN: Tasmanian v8.2
Loading...
Searching...
No Matches
tsgRuleWavelet.hpp
1/*
2 * Copyright (c) 2017, Miroslav Stoyanov
3 *
4 * This file is part of
5 * Toolkit for Adaptive Stochastic Modeling And Non-Intrusive ApproximatioN: TASMANIAN
6 *
7 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
12 * and the following disclaimer in the documentation and/or other materials provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
20 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * UT-BATTELLE, LLC AND THE UNITED STATES GOVERNMENT MAKE NO REPRESENTATIONS AND DISCLAIM ALL WARRANTIES, BOTH EXPRESSED AND IMPLIED.
25 * THERE ARE NO EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE ANY PATENT,
26 * COPYRIGHT, TRADEMARK, OR OTHER PROPRIETARY RIGHTS, OR THAT THE SOFTWARE WILL ACCOMPLISH THE INTENDED RESULTS OR THAT THE SOFTWARE OR ITS USE WILL NOT RESULT IN INJURY OR DAMAGE.
27 * THE USER ASSUMES RESPONSIBILITY FOR ALL LIABILITIES, PENALTIES, FINES, CLAIMS, CAUSES OF ACTION, AND COSTS AND EXPENSES, CAUSED BY, RESULTING FROM OR ARISING OUT OF,
28 * IN WHOLE OR IN PART THE USE, STORAGE OR DISPOSAL OF THE SOFTWARE.
29 */
30
31#ifndef __TASMANIAN_SPARSE_GRID_WAVELET_RULE_HPP
32#define __TASMANIAN_SPARSE_GRID_WAVELET_RULE_HPP
33
34#include "tsgGridCore.hpp"
35
36namespace TasGrid{
37// These macros are used in accessing coarse and fine level coefficients for the cascade algorithm.
38
39#ifndef __TASMANIAN_DOXYGEN_SKIP
40class RuleWavelet{
41public:
42 RuleWavelet(int corder, int iter_depth) : order(0), iteration_depth(iter_depth), num_data_points((1 << iteration_depth) + 1){
43 updateOrder(corder);
44 }
45 ~RuleWavelet() = default;
46
47 // Interface to Extend
48 int getNumPoints(int level) const; // get the number of points associated with level (also the index of the first point on the level+1)
49
50 const char* getDescription() const;
51
52 double getNode(int point) const; // returns the x-value of a point
53 int getOrder() const;
54 void updateOrder(int new_order); // Sets the order of the underlying wavelet rule. Involves recalculating approximations if order==3.
55
56 double getWeight(int point) const; // get the quadrature weight associated with the point
57
58 // mode 0: returns the value of point at location x;
59 // mode 1: returns the right derivative (or left derivative if not available) of point at location x;
60 // (there is assumed 1-1 correspondence between points and functions)
61 template<int mode> double eval(int point, double x) const;
62
63 int getLevel(int point) const; // returns the hierarchical level of a point
64 void getChildren(int point, int &first, int &second) const; // Given a point, return the children (if any)
65 int getParent(int point) const; // Returns the parent of the given node
66
67 void getShiftScale(int point, double &scale, double &shift) const; // encodes for GPU purposes
68
69 double getSupport(int point) const; // return the support of the point, for reporting purposes (not used in eval)
70protected:
71 template<int mode> inline double eval_linear(int pt, double x) const;
72 template<int mode> inline double eval_cubic(int pt, double x) const;
73 template<int mode> inline double linear_boundary_wavelet(double x, bool right) const;
74 template<int mode> inline double linear_central_wavelet(double x, bool right) const;
75 int order;
76 int iteration_depth;
77 int num_data_points;
78 static void cubic_cascade(double *y, int starting_level, int iteration_depth);
79
80 inline int find_index(double x) const;
81 template<int mode> inline double interpolate(const double y[], double x) const;
82
83 std::vector<std::vector<double>> data;
84 std::vector<double> cachexs;
85};
86#endif // __TASMANIAN_DOXYGEN_SKIP
87
88} // namespace TasGrid
89#endif // __TASMANIAN_SPARSE_GRID_WAVELET_RULE_HPP
Encapsulates the Tasmanian Sparse Grid module.
Definition TasmanianSparseGrid.hpp:68