home *** CD-ROM | disk | FTP | other *** search
- parfra(nf,cf,cg,xn,a,cfi,rem)
-
- /*function to express a rational algebraic fraction with the */
- /*numerator of lower degree than the denominator as the */
- /*sum of component fractions whose denominators are */
- /*factors of the denominator of the original fraction */
- /*in the form */
- /* f(x)/((x-xn)*g1(x)) = a/(x-xn)+f1(x)g1(x). */
-
- int nf;
- float cf[],cg[],xn,*a,cfi[],*rem;
-
- {
- int i,k,m,mf;
- float ax,fmag[50],fx1,gx1,xp;
- double pow();
-
- cg[nf] = 0.;
- fx1 = cf[0];
- gx1 = cg[0];
-
- for(i = 0;i <= nf-1; i++)
- {
- mf = i + 1;
- xp = mf;
- fx1 += cf[mf]*pow(xn,xp);
- gx1 += cg[mf]*pow(xn,xp);
-
- }
- ax = fx1/gx1;
-
- for(i = 0;i <= nf-1; i++)
- fmag[i] = cf[i] - (ax * cg[i]);
-
- fmag[nf] = cf[nf];
- cfi[nf-1] = fmag[nf];
- k = nf;
- m = nf - 1;
-
- for(i = 0;i <= m-1; i++)
- {
- k = k - 1;
- cfi[k-1] = cfi[k] *xn + fmag[k] ;
- }
- *rem = cfi[0]*xn + fmag[0];
- *a = ax;
- }
-