# include # include # include # include using namespace std; # include "sncndn.hpp" int main ( ); void jacobi_cn_test ( ); void jacobi_dn_test ( ); void jacobi_sn_test ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // sncndn_test() tests sncndn(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 26 June 2025 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "sncndn_test():\n"; cout << " C++ version\n"; cout << " Test sncndn(), to evaluate Jacobi elliptic functions.\n"; jacobi_cn_test ( ); jacobi_dn_test ( ); jacobi_sn_test ( ); // // Terminate. // cout << "\n"; cout << "sncndn_test():\n"; cout << " Normal end of execution.\n"; timestamp ( ); return 0; } //****************************************************************************80 void jacobi_cn_test ( ) //****************************************************************************80 // // Purpose: // // jacobi_cn_test() tests jacobi_cn(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 26 June 2025 // // Author: // // John Burkardt // { double a; double k; double cn1; double cn2; double m; int n_data; double u; cout << "\n"; cout << "jacobi_cn_test():\n"; cout << " jacobi_cn() evaluates the Jacobi elliptic function CN.\n"; cout << "\n"; cout << " U M Exact CN CN(U,M)\n"; cout << "\n"; n_data = 0; while ( true ) { jacobi_cn_values ( n_data, u, a, k, m, cn1 ); if ( n_data == 0 ) { break; } cn2 = jacobi_cn ( u, m ); cout << setw(8) << u << setw(8) << m << setw(24) << cn1 << setw(24) << cn2 << "\n"; } return; } //****************************************************************************80 void jacobi_dn_test ( ) //****************************************************************************80 // // Purpose: // // jacobi_dn_test() tests jacobi_dn(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 26 June 2025 // // Author: // // John Burkardt // { double a; double k; double dn1; double dn2; double m; int n_data; double u; cout << "\n"; cout << "jacobi_dn_test():\n"; cout << " jacobi_dn() evaluates the Jacobi elliptic function DN.\n"; cout << "\n"; cout << " U M Exact DN DN(U,M)\n"; cout << "\n"; n_data = 0; while ( true ) { jacobi_dn_values ( n_data, u, a, k, m, dn1 ); if ( n_data == 0 ) { break; } dn2 = jacobi_dn ( u, m ); cout << setw(8) << u << setw(8) << m << setw(24) << dn1 << setw(24) << dn2 << "\n"; } return; } //****************************************************************************80 void jacobi_sn_test ( ) //****************************************************************************80 // // Purpose: // // jacobi_sn_test() tests jacobi_sn(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 26 June 2025 // // Author: // // John Burkardt // { double a; double k; double m; int n_data; double sn1; double sn2; double u; cout << "\n"; cout << "jacobi_sn_test():\n"; cout << " jacobi_sn() evaluates the Jacobi elliptic function SN.\n"; cout << "\n"; cout << " U M Exact SN SN(U,M)\n"; cout << "\n"; n_data = 0; while ( true ) { jacobi_sn_values ( n_data, u, a, k, m, sn1 ); if ( n_data == 0 ) { break; } sn2 = jacobi_sn ( u, m ); cout << setw(8) << u << setw(8) << m << setw(24) << sn1 << setw(24) << sn2 << "\n"; } return; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // timestamp() prints the current YMDHMS date as a time stamp. // // Example: // // 31 May 2001 09:45:54 AM // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 19 March 2018 // // Author: // // John Burkardt // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }