OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
SquarePolynomialVector.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Chris Rogers
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef SquarePolynomialVector_hh
29#define SquarePolynomialVector_hh 1
30
34
35#include <map>
36
37namespace interpolation {
38
72 public:
78
82
84
87 SquarePolynomialVector(int pointDimension, MMatrix<double> polynomialCoefficients);
88
96 SquarePolynomialVector(std::vector<PolynomialCoefficient> coefficients);
97
100
104 void SetCoefficients(int pointDim, MMatrix<double> coeff);
105
113 void SetCoefficients(std::vector<PolynomialCoefficient> coeff);
114
121
124
130 void F(const double* point, double* value) const;
131
138 void F(const MVector<double>& point, MVector<double>& value) const;
139
149 SquarePolynomialVector Deriv(const int* derivPower) const;
150
152 unsigned int PointDimension() const { return _pointDim; }
153
155 unsigned int ValueDimension() const { return _polyCoeffs.num_row(); }
156
159 unsigned int PolynomialOrder() const;
160
166
173 const MVector<double>& point, MVector<double>& polyVector) const;
174
181 double* MakePolyVector(const double* point, double* polyVector) const;
182
189 static std::vector<int> IndexByPower(int index, int nInputVariables);
190
197 static std::vector<int> IndexByVector(int index, int nInputVariables);
198
205 static unsigned int NumberOfPolynomialCoefficients(int pointDimension, int order);
206
208 friend std::ostream& operator<<(std::ostream&, const SquarePolynomialVector&);
209
215 static void PrintHeaders(bool willPrintHeaders) { _printHeaders = willPrintHeaders; }
216
218 void PrintHeader(
219 std::ostream& out, char int_separator = '.', char str_separator = ' ',
220 int length = 14, bool pad_at_start = true) const;
221
230 template <class Container>
231 static void PrintContainer(
232 std::ostream& out, const Container& container, char T_separator, char str_separator,
233 int length, bool pad_at_start);
234
235 private:
236 static void IndexByPowerRecursive(
237 std::vector<int> check, size_t check_index, size_t poly_power,
238 std::vector<std::vector<int> >& nearby_points);
239
242 static std::vector<std::vector<std::vector<int> > > _polyKeyByPower;
243 static std::vector<std::vector<std::vector<int> > > _polyKeyByVector;
244 static bool _printHeaders;
245 };
246
247 std::ostream& operator<<(std::ostream&, const SquarePolynomialVector&);
248
249} // namespace interpolation
250#endif // SquarePolynomialVector_hh
size_t num_row() const
returns number of rows in the matrix
SquarePolynomialVector describes a vector of multivariate polynomials.
static std::vector< std::vector< std::vector< int > > > _polyKeyByVector
static unsigned int NumberOfPolynomialCoefficients(int pointDimension, int order)
void SetCoefficients(int pointDim, MMatrix< double > coeff)
MVector< double > & MakePolyVector(const MVector< double > &point, MVector< double > &polyVector) const
static std::vector< std::vector< std::vector< int > > > _polyKeyByPower
SquarePolynomialVector * Clone() const
static std::vector< int > IndexByPower(int index, int nInputVariables)
static void PrintContainer(std::ostream &out, const Container &container, char T_separator, char str_separator, int length, bool pad_at_start)
MMatrix< double > GetCoefficientsAsMatrix() const
static void PrintHeaders(bool willPrintHeaders)
SquarePolynomialVector Deriv(const int *derivPower) const
SquarePolynomialVector & operator=(const SquarePolynomialVector &)=default
void PrintHeader(std::ostream &out, char int_separator='.', char str_separator=' ', int length=14, bool pad_at_start=true) const
void F(const double *point, double *value) const
static std::vector< int > IndexByVector(int index, int nInputVariables)
friend std::ostream & operator<<(std::ostream &, const SquarePolynomialVector &)
static void IndexByPowerRecursive(std::vector< int > check, size_t check_index, size_t poly_power, std::vector< std::vector< int > > &nearby_points)
std::ostream & operator<<(std::ostream &out, const Mesh::Iterator &it)
Definition Mesh.cpp:33