main.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include "modules/Elliptic_integrals.h"
  2. #include <iomanip>
  3. #include <string>
  4. void PrintEF(int index)
  5. {
  6. Elliptic_Integrals EL;
  7. std::cout << "------------------------------------------------------------------------------------------" << std::endl;
  8. std::cout << std::setw(2) << "alpha/phi";
  9. for (int j=0; j <=6; j++)
  10. {
  11. std::cout << std::setw(11) << std::right << std::setprecision(6) << j * 5;
  12. }
  13. std::cout << std::endl;
  14. // std::cout << " ";
  15. for (double alpha = 0; alpha <= 90; alpha = alpha + 2)
  16. {
  17. double k = sin(alpha * M_PI / 180);
  18. if ((int) alpha % 10 == 0 && alpha != 0)
  19. {
  20. std::cout << std::endl;
  21. }
  22. std::cout << std::setw(9) << int(alpha) << ' ';
  23. for (double phi = 0; phi <= 30; phi = phi + 5)
  24. {
  25. std::vector<double> res = EL.Elliptic(phi, k);
  26. std::cout << std::fixed << std::setprecision(8) << res[index] << " ";
  27. }
  28. std::cout << std::endl;
  29. }
  30. std::cout << "------------------------------------------------------------------------------------------" << std::endl;
  31. std::cout << std::setw(2) << "alpha/phi";
  32. for (int j=7; j <=12; j++)
  33. {
  34. std::cout << std::setw(11) << std::right << std::setprecision(6) << j * 5;
  35. }
  36. std::cout << std::endl;
  37. // std::cout << " ";
  38. for (double alpha = 0; alpha <= 90; alpha = alpha + 2)
  39. {
  40. double k = sin(alpha * M_PI / 180);
  41. if ((int) alpha % 10 == 0 && alpha != 0)
  42. {
  43. std::cout << std::endl;
  44. }
  45. std::cout << std::setw(9) << int(alpha) << ' ';
  46. for (double phi = 35; phi <= 60; phi = phi + 5)
  47. {
  48. std::vector<double> res = EL.Elliptic(phi, k);
  49. std::cout << std::fixed << std::setprecision(8) << res[index] << " ";
  50. }
  51. std::cout << std::endl;
  52. }
  53. std::cout << "------------------------------------------------------------------------------------------" << std::endl;
  54. std::cout << std::setw(2) << "alpha/phi";
  55. for (int j=13; j <=18; j++)
  56. {
  57. std::cout << std::setw(11) << std::right << std::setprecision(6) << j * 5;
  58. }
  59. std::cout << std::endl;
  60. // std::cout << " ";
  61. for (double alpha = 0; alpha <= 90; alpha = alpha + 2)
  62. {
  63. double k = sin(alpha * M_PI / 180);
  64. if ((int) alpha % 10 == 0 && alpha != 0)
  65. {
  66. std::cout << std::endl;
  67. }
  68. std::cout << std::setw(9) << int(alpha) << ' ';
  69. for (double phi = 65; phi <= 90; phi = phi + 5)
  70. {
  71. std::vector<double> res = EL.Elliptic(phi, k);
  72. std::cout << std::fixed << std::setprecision(8) << res[index] << " ";
  73. }
  74. std::cout << std::endl;
  75. }
  76. std::cout << "------------------------------------------------------------------------------------------" << std::endl;
  77. }
  78. /**
  79. * Purpose: A table for comparison with Irene A. Stegun, Milton Abramowitz, "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables", page 613-618
  80. *
  81. * @return A table for comparison
  82. */
  83. int main()
  84. {
  85. std::cout << "------------------------------------------------------------------------------------------" << std::endl;
  86. std::cout << "Elliptic integral of the first kind F(phi, sin(alpha))" << std::endl;
  87. std::cout << "------------------------------------------------------------------------------------------" << std::endl;
  88. PrintEF(0);
  89. std::cout << "------------------------------------------------------------------------------------------" << std::endl;
  90. std::cout << "Elliptic integral of the second kind E(phi, sin(alpha))" << std::endl;
  91. std::cout << "------------------------------------------------------------------------------------------" << std::endl;
  92. PrintEF(1);
  93. // Elliptic_Integrals EL;
  94. // std::vector<double> res = EL.Elliptic(135, sqrt(0.5));
  95. // std::cout << res[0];
  96. }