Lemma is an Electromagnetics API
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

costransintegrationkernel.cpp 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 02/08/2011
  9. @version $Id: costransintegrationkernel.cpp 87 2013-09-05 22:44:05Z tirons $
  10. **/
  11. #include "costransintegrationkernel.h"
  12. namespace Lemma {
  13. // ==================== FRIENDS =======================
  14. // std::ostream &operator<<(std::ostream &stream,
  15. // const DigitalFilterCosTrans &ob) {
  16. // stream << *(DigitalFilterIntegrator<Real>*)(&ob);
  17. // return stream;
  18. // }
  19. // ==================== LIFECYCLE =======================
  20. CosTransIntegrationKernel::
  21. CosTransIntegrationKernel(const std::string& name) :
  22. IntegrationKernel<Real>(name) {
  23. }
  24. CosTransIntegrationKernel::~CosTransIntegrationKernel() {}
  25. CosTransIntegrationKernel* CosTransIntegrationKernel::New() {
  26. CosTransIntegrationKernel* Obj =
  27. new CosTransIntegrationKernel("CosTransIntegrationKernel");
  28. Obj->AttachTo(Obj);
  29. return Obj;
  30. }
  31. void CosTransIntegrationKernel::Delete() {
  32. this->DetachFrom(this);
  33. }
  34. void CosTransIntegrationKernel::Release() {
  35. delete this;
  36. }
  37. // ==================== OPERATIONS =======================
  38. void CosTransIntegrationKernel::SetA(const Real& Ain) {
  39. A = Ain;
  40. }
  41. void CosTransIntegrationKernel::SetIntegral(const int& i) {
  42. Integral = i;
  43. }
  44. Real CosTransIntegrationKernel::GetAnalytical (const Real& B) {
  45. Real SQPI = std::sqrt(PI);
  46. switch (Integral) {
  47. case 1:
  48. return SQPI*std::exp(-B*B/(4.*A*A))/(2.*A);
  49. break;
  50. case 2:
  51. return (PI/2.)*std::exp(-A*B)/A;
  52. break;
  53. case 3:
  54. return A/(A*A+B*B);
  55. break;
  56. default:
  57. std::cerr << "Test integral is not allowed\n";
  58. exit(EXIT_FAILURE);
  59. }
  60. }
  61. Real CosTransIntegrationKernel::Argument(const Real&x, const int& iRelated) {
  62. // 1 DEXP(-A*A*G*G) SQPI*DEXP(-B*B/(4.*A*A))/(2.*A), WHERE
  63. // SQPI="SQUARE ROOT OF PI"
  64. // 2 1/(A*A+G*G) (PI/2)*DEXP(-A*B)/A
  65. // 3 DEXP(-A*G) A/(A*A+B*B)
  66. switch (Integral) {
  67. case 1:
  68. return std::exp( -A*A*x*x );
  69. case 2:
  70. return 1./(A*A+x*x);
  71. case 3:
  72. return std::exp(-A*x);
  73. default:
  74. std::cerr << "Test integral is not allowed\n";
  75. exit(EXIT_FAILURE);
  76. }
  77. }
  78. int CosTransIntegrationKernel::GetNumRel( ) {
  79. return 1;
  80. }
  81. } // ----- end of Lemma name -----