| Bill Allombert on Tue, 18 Sep 2007 00:59:45 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Libpari Function Somme |
On Mon, Sep 17, 2007 at 10:30:24AM -0700, Thomas D. Dean wrote:
> I have a problem using the libpari function, somme.
>
> Help on sum shows:
>
> The library syntax is somme(entree *ep, GEN a, GEN b, char *expr, GEN
> x). This is to be used as follows: ep represents the dummy variable
> used in the expression expr
>
> /* compute a^2 + ... + b^2 */
> {
> /* define the dummy variable "i" */
> entree *ep = is_entry("i");
> /* sum for a <= i <= b */
> return somme(ep, a, b, "i^2", gen_0);
> }
>
> However, my code
>
> entree *ep = is_entry("i");
> s = somme(ep, gen_1, n, "i^2", gen_0);
>
> produces the fault:
>
> *** segmentation fault: bug in PARI or calling program.
> *** Error in the PARI system. End of program.
Yes, you need to use fetch_named_var("i") because
is_entry("i") fails if the variable "i" does not already exist,
which is the case here.
But I strongly suggest to avoid using 'somme' here, because it will not
work with PARI/GP 2.4.
Cheers,
Bill