home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / math / cephes / remes / remesp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-17  |  1.4 KB  |  85 lines

  1. /* remesp.c */
  2.  
  3. #include "remes.h"
  4.  
  5. /* Display solution and tabulate errors */
  6.  
  7. remesp()
  8. {
  9. int i, j, k, ip;
  10. double t, a, b, x, y, z, xm, ym;
  11. double approx(), func(), geterr();
  12.  
  13. j = 0;    /* Printout variable */
  14. ip = 0;    /* Solution vector counter */
  15. printf( "Numerator coefficients:\n" );
  16. for( i=0; i<=n; i++, j++, ip++ )
  17.     {
  18.     if( j >= 3 )
  19.         {
  20.         printf( "\n" );
  21.         j = 0;
  22.         }
  23.     printf( "%23.15E ", param[ip] );
  24.     }
  25. if( d > 0 )
  26.     {
  27.     j = 0;
  28.     printf( "\nDenominator coefficients:\n" );
  29.     for( i=0; i<d; i++, j++, ip++ )
  30.         {
  31.         if( j >= 3 )
  32.             {
  33.             printf( "\n" );
  34.             j = 0;
  35.             }
  36.         printf( "%23.15E ", param[ip] );
  37.         }
  38.     if( j >= 3 )
  39.         printf( "\n" );
  40. /* Leading denominator coefficient always = 1. */
  41.     printf( "%9.1E", 1.0 );
  42.     }
  43. else
  44.     printf( "\nDeviation: %.4E", param[n+1] );
  45.  
  46. /* Display table of function and approximation error. */
  47. printf(
  48. "\n\n     x         func      approx      error\n"
  49. );
  50. a = apwidt/N;
  51. b = apstrt;
  52. k = 0;
  53. j = 0;
  54. for( i=0; i<=N; i++ )
  55.     {
  56.     x = b + i * a;
  57.     if( x >= mm[k] )
  58.         {
  59.         xm = mm[k];
  60.         y = geterr(xm);
  61.         z = qyaprx;
  62.         ym = qy;
  63.         printf( "%11.3E %11.3E %11.3E %11.3E*\n",
  64.             xm, ym, z, y*esign );
  65.         k += 1;
  66.         } 
  67. /* Fill in the zeros also. */
  68.     if( (d > 0) && (x >= xx[j]) )
  69.         {
  70.         xm = xx[j];
  71.         y = geterr(xm);
  72.         z = qyaprx;
  73.         ym = qy;
  74.         printf( "%11.3E %11.3E %11.3E %11.3Eo\n",
  75.              xm, ym, z, y*esign );
  76.         j += 1;
  77.         } 
  78.     y = geterr(x);
  79.     z = qyaprx;
  80.     ym = qy;
  81.     printf( "%11.3E %11.3E %11.3E %11.3E\n",
  82.         x, ym, z, y*esign );
  83.     }
  84. }
  85.