Bill Allombert on Fri, 6 Jun 2003 19:22:24 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: factorint


On Thu, Jun 05, 2003 at 11:30:10PM -0200, trabunix wrote:
> Sorry but I can't understando what you said me. Have I to declare this M or not. Where can I fin this sintaxe to use in  a C program ? Is there a example code anywhere ?

Sorry, I misread your mail. 

You should probably try out GP2C that make C programming somewhat easier
and can generate example code more or less at will.

Anyway, you need to declare M as a GEN and use gcoeff(M,i,j) to
access the coefficients of the matrix.

The alternative is to do

void printfact(GEN n)
{ 
  GEN M=factorint(n, 0);
  GEN primes=(GEN)M[1];
  GEN exponents=(GEN)M[2];
  long i;
  for(i=1;i<lg(primes);i++)
    pariputsf("%Z^%Z\n",(GEN)primes[i],(GEN)exponents[j]);
}

Cheers,
Bill.