Lemma is an Electromagnetics API
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 10/07/2010
  9. @version $Id: gaussianquadrature.h 193 2014-11-10 23:51:41Z tirons $
  10. **/
  11. #ifndef __gaussianquadrature_h
  12. #define __gaussianquadrature_h
  13. #include "LemmaObject.h"
  14. namespace Lemma {
  15. // ===================================================================
  16. // Class: gaussianquadrature
  17. /// \brief Numerical integration via Legendre-Gauss Quadrature.
  18. /// \details Returns integration result, weights, and abscissae. This
  19. /// script computes the Legendre-Gauss nodes and weights on an interval
  20. /// [a,b] with truncation order N. This class is heavily derived from
  21. /// lgwt.m by Greg von Winckel (2/25/2004).
  22. // ===================================================================
  23. class gaussianquadrature {
  24. public:
  25. friend std::ostream &operator<<(std::ostream &stream,
  26. const gaussianquadrature &ob);
  27. // ==================== LIFECYCLE =======================
  28. static gaussianquadrature* New();
  29. void Delete();
  30. // ==================== OPERATORS =======================
  31. // ==================== OPERATIONS =======================
  32. /// Perform Gaussian Quadrature Integration
  33. void Integrate();
  34. /// Calculate abscissae and weights
  35. void CalcAW();
  36. // ==================== ACCESS =======================
  37. /// Set number of points and limits
  38. void SetFreqs(const int& nfreq, const Real& a, const Real& b);
  39. /// Eigen Vector of function values to be integrated over
  40. void SetFunc(const VectorXr& fx);
  41. // ==================== INQUIRY =======================
  42. /// Returns Eigen Vector of Abscissae
  43. VectorXr GetAbscissae();
  44. /// Returns Eigen Vector of Weights
  45. VectorXr GetWeights();
  46. /// Returns integration result
  47. Real GetResult();
  48. protected:
  49. // ==================== LIFECYCLE =======================
  50. /// Default protected constructor.
  51. gaussianquadrature ();
  52. /// Default protected constructor.
  53. ~gaussianquadrature ();
  54. // ==================== DATA MEMBERS =========================
  55. /// Interval
  56. Real dx;
  57. /// Machine precision
  58. Real machineeps;
  59. /// Bookkeeping variable
  60. int N;
  61. /// Bookkeeping variable
  62. int N1;
  63. /// Bookkeeping variable
  64. int N2;
  65. /// Lower bound
  66. Real a;
  67. /// Upper bound
  68. Real b;
  69. /// Placeholder vector
  70. VectorXr ytemp;
  71. /// Abscissae
  72. VectorXr xu;
  73. /// Intermediate Abscissae vector
  74. VectorXr y;
  75. /// Intermediate Abscissae vector
  76. VectorXr y0;
  77. /// Legendre-Gauss Vandermonde Matrix
  78. MatrixXr L;
  79. /// Derivative of LGVM
  80. VectorXr Lp;
  81. /// Intermediate Matrix
  82. VectorXr Ltemp;
  83. /// Weights Vector
  84. VectorXr wgq;
  85. ///Function to integrate
  86. VectorXr funcx;
  87. /// Integration result
  88. Real intres;
  89. private:
  90. }; // ----- end of class gaussianquadrature -----
  91. } // end of namespace Lemma
  92. #endif // __gaussianquadrature_h