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

digitalfiltercostrans.cpp 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // ===========================================================================
  2. //
  3. // Filename: utdigitalfiltercostrans.cpp
  4. //
  5. // Created: 02/08/2011 11:52:39 AM
  6. // Compiler: Tested with g++, icpc, and MSVC 2010
  7. //
  8. // Author: Trevor Irons (ti)
  9. //
  10. // Organisation: Colorado School of Mines (CSM)
  11. // United States Geological Survey (USGS)
  12. //
  13. // Email: tirons@mines.edu, tirons@usgs.gov
  14. //
  15. // This program is free software: you can redistribute it and/or modify
  16. // it under the terms of the GNU General Public License as published by
  17. // the Free Software Foundation, either version 3 of the License, or
  18. // (at your option) any later version.
  19. //
  20. // This program is distributed in the hope that it will be useful,
  21. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. // GNU General Public License for more details.
  24. //
  25. // You should have received a copy of the GNU General Public License
  26. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. //
  28. // ===========================================================================
  29. /**
  30. @file
  31. @author Trevor Irons
  32. @date 02/08/2011
  33. @version 0.0
  34. **/
  35. #include "digitalfiltercostrans.h"
  36. #include "costransintegrationkernel.h"
  37. #include "integrationkernel.h"
  38. //class TestDriverKernel : public IntegrationKernel<Real> {
  39. //
  40. //};
  41. using namespace Lemma;
  42. int main() {
  43. //Real A = 2.;
  44. //Real B = 12.5;
  45. Real A = 1.;
  46. Real B = 2.;
  47. DigitalFilterCosTrans* Cos = DigitalFilterCosTrans::New();
  48. std::cout << *Cos << std::endl;
  49. CosTransIntegrationKernel* Kernel = CosTransIntegrationKernel::New();
  50. Cos->AttachKernel(Kernel);
  51. Cos->Compute(B, 1, 1e-16);
  52. std::cout << "numeric " << Cos->GetAnswer() << std::endl;
  53. Real SQPI = std::sqrt(PI);
  54. Real analytic = SQPI*std::exp(-B*B/(4.*A*A))/(2.*A);
  55. std::cout << "analytic " << analytic <<std::endl;
  56. std::cout << "absolute error " << Cos->GetAnswer()(0,0) - analytic <<std::endl;
  57. std::cout << "relative error " << (Cos->GetAnswer()(0,0) - analytic) / analytic <<std::endl;
  58. Cos->Delete();
  59. Kernel->Delete();
  60. }