NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
orthoPoly1D.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_ORTHOPOLY1D_H_
30 #define NEMOSYS_ORTHOPOLY1D_H_
31 
32 #include "nemosys_export.h"
33 
34 #include <iostream>
35 #include <vector>
36 
37 #include <Eigen/Core>
38 
39 class NEMOSYS_EXPORT orthoPoly1D
40 {
41  // ctors and dtor
42  public:
43  orthoPoly1D(int _order, const std::vector<double> &x);
44  orthoPoly1D() = default;
45 
46  orthoPoly1D(const orthoPoly1D &op);
47  orthoPoly1D &operator=(const orthoPoly1D &op);
48 
49  ~orthoPoly1D() = default;
50 
51  // methods invoked in constructor
52  public:
53  /* Use recurrence relation to calculate power^th orthogonal polynomial:
54  p_m+1(x) = (x-a_m+1(x))*p_m(x) - b_m*p_m-1(x) for m>=1;
55  p_0(x) = 1; p_1(x) = x - a[0] */
56  double EvaluateOrthogonal(int power, double xk) const;
57 
58  /* Compute coefficients a_m, b_m to be used in recurrence relation for
59  calculating orthogonal polynomial:
60  a_m+1 = (sum_k=0^n-1 x_k*p_m^2(x_k))/(sum_k=0^n-1 p_m^2(x_k))
61  b_m = (sum_k=0^n-1 p_m^2(x_k))/(sum_k=0^n-1 p_m-1^2(x_k)) */
62  void ComputeAB(const std::vector<double> &x);
63 
64  /* Evaluate Orthogonal polynomials at data x and collect them in basis
65  matrix phi */
66  void EvaluateOrthogonals(const std::vector<double> &x);
67 
68  /* Compute inverted matrix for use in normal equation */
69  void ComputePhiTPhiInv(const std::vector<double> &x);
70 
71  public:
72  // polynomial order
73  int order;
74  // coordinate array
75  //const std::vector<double> &x;
76  // coefficient array to calculate value of orthogonal polynomial
77  std::vector<double> a;
78  // coefficient array to calculate value of orthogonal polynomial
79  std::vector<double> b;
80  // Matrix of polynomial basis phi, evaluated at x
81  Eigen::MatrixXd phi;
82  // Inverted matrix in normal equations a = [(phiT*phi)^-1]*phiT*f
83  Eigen::MatrixXd phiTphiInv;
84 };
85 
86 #endif // NEMOSYS_ORTHOPOLY1D_H_
std::vector< double > a
Definition: orthoPoly1D.H:77
std::vector< double > b
Definition: orthoPoly1D.H:79
Eigen::MatrixXd phiTphiInv
Definition: orthoPoly1D.H:83
Eigen::MatrixXd phi
Definition: orthoPoly1D.H:81