main.cpp 3.4 KB

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