# include # include # include # include # include "sncndn.h" int main ( ); void jacobi_cn_test ( ); void jacobi_dn_test ( ); void jacobi_sn_test ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: sncndn_test() tests sncndn(). Licensing: This code is distributed under the MIT license. Modified: 26 June 2025 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "sncndn_test():\n" ); printf ( " C version\n" ); printf ( " Test sncndn(), to evaluate Jacobi elliptic functions.\n" ); jacobi_cn_test ( ); jacobi_dn_test ( ); jacobi_sn_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "sncndn_test():\n" ); printf ( " Normal end of execution.\n" ); timestamp ( ); return 0; } /******************************************************************************/ void jacobi_cn_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "jacobi_cn_test():\n" ); printf ( " jacobi_cn() evaluates the Jacobi elliptic function CN.\n" ); printf ( "\n" ); printf ( " U M Exact CN CN(U,M)\n" ); printf ( "\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 ); printf ( "%8.4f %8.4f %24.16g %24.16g\n", u, m, cn1, cn2 ); } return; } /******************************************************************************/ void jacobi_dn_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "jacobi_dn_test():\n" ); printf ( " jacobi_dn() evaluates the Jacobi elliptic function DN.\n" ); printf ( "\n" ); printf ( " U M Exact DN DN(U,M)\n" ); printf ( "\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 ); printf ( "%8.4f %8.4f %24.16g %24.16g\n", u, m, dn1, dn2 ); } return; } /******************************************************************************/ void jacobi_sn_test ( ) /******************************************************************************/ /* 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; printf ( "\n" ); printf ( "jacobi_sn_test():\n" ); printf ( " jacobi_sn() evaluates the Jacobi elliptic function SN.\n" ); printf ( "\n" ); printf ( " U M Exact SN SN(U,M)\n" ); printf ( "\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 ); printf ( "%8.4f %8.4f %24.16g %24.16g\n", u, m, sn1, sn2 ); } return; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: 17 June 2014 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 01 May 2021 Author: John Burkardt */ { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }