I couldnt find what is wrong

  • Thread starter emre esirik(hacettepe computer science and enginee
  • Start date
E

emre esirik(hacettepe computer science and enginee

void div ( int pol1[] , int pol1p[] , int pol2[] , int pol2p[])
{
int r=5,z,i,g,j,k;
for (i=0 ; i<6 ; i++)
*(po5 + i)=pol1;
for(i=5 ; i >=0 ; i--)
{

for(z=r ; z>=0 ; z--)
{

if(pol2[z]!=0)
{
*(po5 + (i-z))= *(po5 + i)/pol2[z];

for(g=5; g>=0 ; g--) {
for (j=z ; j>=0 ; j--) {
*(po5 + (g+j)) += (*(po5 + j) * pol2[g]);
}
}
for(k=0; k<6 ; k++) {
*(po5 + k) = *(po5 + k) - pol2[k];
}

}
r=z-1;
}

}
for (i=0 ; i<6 ; i++) {
printf("%dX^%d+",*(po5+i),i);
}
}
 
E

emre esirik(hacettepe computer science and enginee

it doesnt calculate two polynom division
 
U

user923005

it doesnt calculate two polynom division

Like I said before, the Cephes collection at Netlib has polynomial
routines.
The file polyn.c does the following:
/* polyn.c
* polyr.c
* Arithmetic operations on polynomials
*
* In the following descriptions a, b, c are polynomials of degree
* na, nb, nc respectively. The degree of a polynomial cannot
* exceed a run-time value MAXPOL. An operation that attempts
* to use or generate a polynomial of higher degree may produce a
* result that suffers truncation at degree MAXPOL. The value of
* MAXPOL is set by calling the function
*
* polini( maxpol );
*
* where maxpol is the desired maximum degree. This must be
* done prior to calling any of the other functions in this module.
* Memory for internal temporary polynomial storage is allocated
* by polini().
*
* Each polynomial is represented by an array containing its
* coefficients, together with a separately declared integer equal
* to the degree of the polynomial. The coefficients appear in
* ascending order; that is,
*
* 2 na
* a(x) = a[0] + a[1] * x + a[2] * x + ... + a[na] * x .
*
*
*
* sum = poleva( a, na, x ); Evaluate polynomial a(t) at t = x.
* polprt( a, na, D ); Print the coefficients of a to D digits.
* polclr( a, na ); Set a identically equal to zero, up to a[na].
* polmov( a, na, b ); Set b = a.
* poladd( a, na, b, nb, c ); c = b + a, nc = max(na,nb)
* polsub( a, na, b, nb, c ); c = b - a, nc = max(na,nb)
* polmul( a, na, b, nb, c ); c = b * a, nc = na+nb
*
*
* Division:
*
* i = poldiv( a, na, b, nb, c ); c = b / a, nc = MAXPOL
*
* returns i = the degree of the first nonzero coefficient of a.
* The computed quotient c must be divided by x^i. An error message
* is printed if a is identically zero.
*
*
* Change of variables:
* If a and b are polynomials, and t = a(x), then
* c(t) = b(a(x))
* is a polynomial found by substituting a(x) for t. The
* subroutine call for this is
*
* polsbt( a, na, b, nb, c );
*
*
* Notes:
* poldiv() is an integer routine; poleva() is double.
* Any of the arguments a, b, c may refer to the same array.
*
*/

The way to find source code to solve a problem is with a web search.
Besides Cephes, you would also have found:
http://pagesperso-orange.fr/jean-pierre.moreau/c_polynoms.html
http://www.codeproject.com/useritems/Polynomial.asp
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top