# include # include # include # include # include "minimal_surface_exact.h" int main ( ); double r8vec_norm_rms ( int n, double a[] ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: minimal_surface_exact_test() tests minimal_surface_exact(). Licensing: This code is distributed under the MIT license. Modified: 02 June 2025 Author: John Burkardt */ { double a; double b; double c; int i; int n = 5; double *R; long long int seed = 123456789LL; double *X; double *X1; double *Y; double *Y1; timestamp ( ); printf ( "\n" ); printf ( "minimal_surface_exact_test():\n" ); printf ( " C version.\n" ); printf ( " Test minimal_surface_exact().\n" ); srand48 ( seed ); X = ( double * ) malloc ( n * sizeof ( double ) ); X1 = ( double * ) malloc ( n * sizeof ( double ) ); Y = ( double * ) malloc ( n * sizeof ( double ) ); Y1 = ( double * ) malloc ( n * sizeof ( double ) ); for ( i = 0; i < n; i++ ) { X[i] = drand48 ( ); X1[i] = X[i] + 1.0; Y[i] = drand48 ( ); Y1[i] = Y[i] + 1.0; } a = 1.0; b = 2.0; c = 3.0; /* Linear solution. */ printf ( "\n" ); printf ( " Linear solution residual at random points:\n" ); R = minimal_surface_linear_residual ( n, X, Y, a, b, c ); printf ( " RMS residual norm = %g\n", r8vec_norm_rms ( n, R ) ); free ( R ); /* Helicoid solution. */ printf ( "\n" ); printf ( " Helicoid solution residual at random points:\n" ); R = minimal_surface_helicoid_residual ( n, X, Y ); printf ( " RMS residual norm = %g\n", r8vec_norm_rms ( n, R ) ); free ( R ); /* Catenoid solution. */ printf ( "\n" ); printf ( " Catenoid solution residual at random points:\n" ); R = minimal_surface_catenoid_residual ( n, X1, Y1, a ); printf ( " RMS residual norm = %g\n", r8vec_norm_rms ( n, R ) ); free ( R ); /* Scherk solution. */ printf ( "\n" ); printf ( " Scherk solution residual at random points:\n" ); R = minimal_surface_scherk_residual ( n, X, Y, a ); printf ( " RMS residual norm = %g\n", r8vec_norm_rms ( n, R ) ); free ( R ); free ( X ); free ( X1 ); free ( Y ); free ( Y1 ); /* Terminate. */ printf ( "\n" ); printf ( "minimal_surface_exact_test()\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ double r8vec_norm_rms ( int n, double a[] ) /******************************************************************************/ /* Purpose: r8vec_norm_rms() returns the RMS norm of an R8VEC. Discussion: The vector RMS norm is defined as: R8VEC_NORM_RMS = sqrt ( sum ( 1 <= I <= N ) A(I)^2 / N ) Licensing: This code is distributed under the MIT license. Modified: 26 October 2011 Author: John Burkardt Input: int N, the number of entries in A. double A[N], the vector whose L2 norm is desired. Output: double R8VEC_NORM_RMS, the RMS norm of A. */ { int i; double v; v = 0.0; if ( 0 < n ) { for ( i = 0; i < n; i++ ) { v = v + a[i] * a[i]; } v = sqrt ( v / ( double ) ( n ) ); } return v; } /******************************************************************************/ 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 }