OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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 
37 namespace interpolation {
38 
72  public:
78 
82 
85  SquarePolynomialVector (int pointDimension,
86  MMatrix<double> polynomialCoefficients);
87 
95  SquarePolynomialVector (std::vector<PolynomialCoefficient> coefficients);
96 
99 
103  void SetCoefficients(int pointDim, MMatrix<double> coeff);
104 
112  void SetCoefficients(std::vector<PolynomialCoefficient> coeff);
113 
119  void SetCoefficients(MMatrix<double> coeff);
120 
123  {return _polyCoeffs;}
124 
130  void F(const double* point, double* value) const;
131 
138  void F(const MVector<double>& point, MVector<double>& value) const;
139 
141  unsigned int PointDimension() const {return _pointDim;}
142 
144  unsigned int ValueDimension() const {return _polyCoeffs.num_row();}
145 
148  unsigned int PolynomialOrder() const;
149 
155  {return new SquarePolynomialVector(*this);}
156 
163  MVector<double>& polyVector) const;
164 
171  double* MakePolyVector(const double* point, double* polyVector) const;
172 
179  static std::vector<int> IndexByPower (int index, int nInputVariables);
180 
187  static std::vector<int> IndexByVector(int index, int nInputVariables);
188 
194  static unsigned int NumberOfPolynomialCoefficients(int pointDimension, int order);
195 
197  friend std::ostream& operator<<(std::ostream&, const SquarePolynomialVector&);
198 
204  static void PrintHeaders(bool willPrintHeaders) {_printHeaders = willPrintHeaders;}
205 
207  void PrintHeader(std::ostream& out,
208  char int_separator='.',
209  char str_separator=' ',
210  int length=14,
211  bool pad_at_start=true) const;
212 
221  template < class Container >
222  static void PrintContainer(std::ostream& out,
223  const Container& container,
224  char T_separator,
225  char str_separator,
226  int length,
227  bool pad_at_start);
228 
229 private:
230  static void IndexByPowerRecursive(
231  std::vector<int> check,
232  size_t check_index,
233  size_t poly_power,
234  std::vector<std::vector<int> >& nearby_points);
235 
238  static std::vector< std::vector< std::vector<int> > > _polyKeyByPower;
239  static std::vector< std::vector< std::vector<int> > > _polyKeyByVector;
240  static bool _printHeaders;
241 };
242 
243 std::ostream& operator<<(std::ostream&, const SquarePolynomialVector&);
244 
245 }
246 #endif // SquarePolynomialVector_hh
247 
248 
249 
250 
static std::vector< int > IndexByPower(int index, int nInputVariables)
void PrintHeader(std::ostream &out, char int_separator='.', char str_separator=' ', int length=14, bool pad_at_start=true) const
static std::vector< std::vector< std::vector< int > > > _polyKeyByPower
void SetCoefficients(int pointDim, MMatrix< double > coeff)
static void IndexByPowerRecursive(std::vector< int > check, size_t check_index, size_t poly_power, std::vector< std::vector< int > > &nearby_points)
static void PrintHeaders(bool willPrintHeaders)
MVector< double > & MakePolyVector(const MVector< double > &point, MVector< double > &polyVector) const
void F(const double *point, double *value) const
static std::vector< std::vector< std::vector< int > > > _polyKeyByVector
static void PrintContainer(std::ostream &out, const Container &container, char T_separator, char str_separator, int length, bool pad_at_start)
friend std::ostream & operator<<(std::ostream &, const SquarePolynomialVector &)
SquarePolynomialVector describes a vector of multivariate polynomials.
SquarePolynomialVector * Clone() const
MMatrix< double > GetCoefficientsAsMatrix() const
static std::vector< int > IndexByVector(int index, int nInputVariables)
static unsigned int NumberOfPolynomialCoefficients(int pointDimension, int order)
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