home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_02 / 1002102a < prev    next >
Text File  |  1991-12-10  |  672b  |  21 lines

  1.  
  2. void chder(a,b,c,cder,n)
  3. double a,b,c[],cder[]; /* c[] and cder[] must not overlap */
  4. int n;
  5. {
  6.         register int j;
  7.         register double con,cj1,cdj2,cdj1,cdj;
  8.         con = 2/(b-a);
  9.         cdj1 = 2*(n-1)*c[n-1];
  10.         cj1 = 2*(n-2)*c[n-2];
  11.         cder[n-1] = cdj2 = 0;
  12.         for(j = n-2; --j >= 0;){
  13.                 cdj = cdj2+cj1; /* the recursive result of first loop */
  14.                 cj1 = 2*j*c[j]; /* prefetch for next loop iteration */
  15.                 cder[j+1] = con*(cdj2=cdj1); /* complete final loop */
  16.                 cdj1 = cdj; /* compiler doesn't worry about aliasing of locals */
  17.         }
  18.         cder[0] = con*cdj1;
  19. }
  20.  
  21.