Alessio Rocchi on Fri, 09 Dec 2005 21:07:19 +0100

 Factoring and gcoeff()

• To: <pari-dev@list.cr.yp.to>
• Subject: Factoring and gcoeff()
• From: "Alessio Rocchi" <alexrocchi@gmail.com>
• Date: Fri, 9 Dec 2005 21:05:25 +0100
• Delivery-date: Fri, 09 Dec 2005 21:07:19 +0100
• Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:from:to:subject:date:mime-version:content-type:content-transfer-encoding:x-priority:x-msmail-priority:x-mailer:x-mimeole; b=A6I1/PNjCGxAufJGB9ghLu5SPJhIzjcdsuHpcxf+lWXtqRRHE2r/U3pt8zhPy2l3+C9CQh3ISe8vy1T6srv+uSkJ3I/egpM2N32kwL84ha85HimbGaYiMrgR1vZyNTmCu5T4twYDiPkwS2p7MG39hANJOq5YjQ2mBEDV3w7NHBA=
• Mailing-list: contact pari-dev-help@list.cr.yp.to; run by ezmlm

```Hi everybody.
```
Before beginning to explain my problem, i would really say thanks to Bill Alombert for all the (wonderful) help he gave me until now. Ok, let's go on: i can succesfully factor numbers using factor() function with libpari. I need now to insert all prime factors (and their exponents) into a long int array (long int*. I know that it would be really simpler to use Pari types, but i need to use just pure C long int pointers).
```Well, I use (pseudo-)code like this:

typedef struct{
long int* factors;
long int* exps;
} Factors;

GEN F=factor(<number>);
long length=lg(F[1]);
//code for allocating Factors.factors[] and Factors.exps[]
for(int i=0; i<length; i++){
Factors.factors[i]=itos(gcoeff(F, i, 1));
Factors.exps[i]=itos(gcoeff(F, i, 2));
}

Compilation is succesful. I get a really bad Segmentation Fault at runtime.
```
Same thing does happen when i try to print out the factors with a standard printf() (something like printf("Got base^exp : %ld^%ld\n", itos(gcoeff(F, i, 1)), itos(gcoeff(F, i, 2)))).
```How can i workaround this problem?
Thank you so much,
cheers
```
Alessio Rocchi