[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] problems w/ gsl_poly_solve_quadratic
From: |
G1ul10 |
Subject: |
Re: [Help-gsl] problems w/ gsl_poly_solve_quadratic |
Date: |
Tue, 13 Jul 2004 08:13:36 +0200 |
Try this instead:
#include "stdio.h"
#include <gsl/gsl_poly.h>
int main()
{
double a, b, c, x0,x1;
printf("Enter the coefficients a, b, c of ax^2 + b*x + c = 0\n");
scanf("%lf %lf %lf", &a, &b, &c);
gsl_poly_solve_quadratic(a, b, c, &x0, &x1);
printf("The roots are: %lf, %lf\n", x0, x1);
return 0;
}
it should work. See the difference?
G.
On Tue, 13 Jul 2004 00:27:03 -0500
Jon Drews <address@hidden> wrote:
> FreeBSD 5.2-CURRENT #0: Sat Jul 10 17:19:21 CDT 2004
>
> Configured with: FreeBSD/i386 system compiler
> Thread model: posix
> gcc version 3.3.3 [FreeBSD] 20031106
>
> GSL ver. 1.5
>
>
> Hi:
>
> When I run the following program:
> /* Finds the roots to Quadratic Eqn. (a*x^2 + b*x + c = 0) */
>
> #include <stdio.h>
> #include <gsl/gsl_poly.h>
>
>
> int main()
> {
>
> double a, b, c, *x0,*x1;
>
> printf("Enter the coefficients a, b, c of ax^2 + b*x + c = 0\n");
> scanf("%lf %lf %lf", &a, &b, &c);
>
> gsl_poly_solve_quadratic(a, b, c, x0, x1);
>
>
> printf("The roots are: %lf, %lf\n", *x0, *x1);
>
> return 0;
> }
>
> I get a core dump. I have compiled it and run it like so:
>
> bash-2.05b$ gcc -g -c -Wall -I/usr/local/include quadratic.c
> bash-2.05b$ gcc -o QUAD -L/usr/local/lib quadratic.o -lgsl -lgslcblas
> bash-2.05b$ ./QUAD
> Enter the coefficients a, b, c of ax^2 + b*x + c = 0
> 1 2 1
> Bus error (core dumped)
> bash-2.05b$
>
> I get this output from ddd:
>
> Copyright © 1995-1999 Technische Universität Braunschweig, Germany.
> Copyright © 1999-2001 Universität Passau, Germany.
> Copyright © 2001 Universität des Saarlandes, Germany.
> Copyright © 2003 Free Software Fundation, Inc.
> (gdb) file /usr/home/xfce/programs/gsl/QUAD
> (gdb) run
> Enter the coefficients a, b, c of ax^2 + b*x + c = 0
> 1 2 1
>
> Program received signal SIGBUS, Bus error.
> 0x281235a9 in gsl_poly_solve_quadratic () from
> /usr/local/lib/libgsl.so.6(gdb) bt
> #0 0x281235a9 in gsl_poly_solve_quadratic () from
> #/usr/local/lib/libgsl.so.6 1 0x080485da in main () at quadratic.c:15
> (gdb)
>
> I also get the same error with gsl_poly_solve_cubic. What might I have
> done wrong here?
>
>
> TIA
> Jonathan
>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
--
Giulio Bottazzi <address@hidden>
Laboratory of Economics and Management
Sant'Anna School for Advanced Studies, Pisa, Italy
Phone: (+39)-050-883365 Fax: (+39)-050-883344
URL: http://www.sssup.it/~bottazzi/
--
Giulio Bottazzi <address@hidden>
Laboratory of Economics and Management
Sant'Anna School for Advanced Studies, Pisa, Italy
Phone: (+39)-050-883365 Fax: (+39)-050-883344
URL: http://www.sssup.it/~bottazzi/
00000000.mimetmp
Description: PGP signature
pgpUeRbY7g4zL.pgp
Description: PGP signature