OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
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,
88 MMatrix<double> polynomialCoefficients);
89
97 SquarePolynomialVector (std::vector<PolynomialCoefficient> coefficients);
98
101
105 void SetCoefficients(int pointDim, MMatrix<double> coeff);
106
114 void SetCoefficients(std::vector<PolynomialCoefficient> coeff);
115
122
125 {return _polyCoeffs;}
126
132 void F(const double* point, double* value) const;
133
140 void F(const MVector<double>& point, MVector<double>& value) const;
141
151 SquarePolynomialVector Deriv(const int* derivPower) const;
152
154 unsigned int PointDimension() const {return _pointDim;}
155
157 unsigned int ValueDimension() const {return _polyCoeffs.num_row();}
158
161 unsigned int PolynomialOrder() const;
162
168 {return new SquarePolynomialVector(*this);}
169
176 MVector<double>& polyVector) const;
177
184 double* MakePolyVector(const double* point, double* polyVector) const;
185
192 static std::vector<int> IndexByPower (int index, int nInputVariables);
193
200 static std::vector<int> IndexByVector(int index, int nInputVariables);
201
207 static unsigned int NumberOfPolynomialCoefficients(int pointDimension, int order);
208
210 friend std::ostream& operator<<(std::ostream&, const SquarePolynomialVector&);
211
217 static void PrintHeaders(bool willPrintHeaders) {_printHeaders = willPrintHeaders;}
218
220 void PrintHeader(std::ostream& out,
221 char int_separator='.',
222 char str_separator=' ',
223 int length=14,
224 bool pad_at_start=true) const;
225
234 template < class Container >
235 static void PrintContainer(std::ostream& out,
236 const Container& container,
237 char T_separator,
238 char str_separator,
239 int length,
240 bool pad_at_start);
241
242private:
243 static void IndexByPowerRecursive(
244 std::vector<int> check,
245 size_t check_index,
246 size_t poly_power,
247 std::vector<std::vector<int> >& nearby_points);
248
251 static std::vector< std::vector< std::vector<int> > > _polyKeyByPower;
252 static std::vector< std::vector< std::vector<int> > > _polyKeyByVector;
253 static bool _printHeaders;
254};
255
256std::ostream& operator<<(std::ostream&, const SquarePolynomialVector&);
257
258}
259#endif // SquarePolynomialVector_hh
260
261
262
263
std::ostream & operator<<(std::ostream &out, const Mesh::Iterator &it)
Definition: Mesh.cpp:33
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)