"Fossies" - the Fresh Open Source Software Archive

Member "ccmath-2.2.1/intg/test/tchintg.c" (7 Nov 2000, 1521 Bytes) of package /linux/misc/old/ccmath-2.2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*  tchintg.c    CCMATH mathematics library source code.
    2  *
    3  *  Copyright (C)  2000   Daniel A. Atkinson    All rights reserved.
    4  *  This code may be redistributed under the terms of the GNU library
    5  *  public license (LGPL). ( See the lgpl.license file for details.)
    6  * ------------------------------------------------------------------------
    7  */
    8 /*
    9     Test:  chintg  fchb
   10 
   11     To specify a new order parameter use 'tchintg' order
   12 */
   13 #include <math.h>
   14 #include "ccmath.h"
   15 #define MDM 60
   16 /* order of Tchebycheff approximation */
   17 int mp=8;
   18 double Pi=3.14159265358979324;
   19 double func(double x);
   20 void main(int na,char **av)
   21 { double x,y,f,a[MDM],Pi2=Pi/2.;
   22   printf("     Test of Tchebycheff Integration\n\n");
   23   if(na!=1) mp=atoi(*++av);
   24   printf("  order = %d\n",mp);
   25   f=chintg(a,mp,func);
   26   printf("  test magnitude = %14.10f\n\n",f);
   27   printf("     y       computed       exact\n");
   28   for(y= -1.; y<=1. ;y+=.5){
   29     f=fchb(y,a,mp)*Pi2/2.; x=Pi2*(1.+y)/2.;
   30     printf("  %6.3f  %13.8f  %13.8f\n",y,f,1.-cos(x));
   31    }
   32 }
   33 /* test integrand function
   34    defined on x from -1 to 1.
   35    Integral is 1-cos(Pi*(1+x)/4).
   36 */
   37 double func(double x)
   38 { double y;
   39   y=(1.+x)/2.; return sin(Pi*y/2.);
   40 }
   41 /*  Test output
   42 
   43      Test of Tchebycheff Integration
   44 
   45   order = 8
   46   test magnitude =   0.0000089716
   47 
   48      y       computed       exact
   49   -1.000     0.00000000     0.00000000
   50   -0.500     0.07612047     0.07612047
   51    0.000     0.29289322     0.29289322
   52    0.500     0.61731657     0.61731657
   53    1.000     1.00000000     1.00000000
   54 */