[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Help with linking / loading libraries on Ubuntu 10.10
From: |
Rhys Ulerich |
Subject: |
Re: [Help-gsl] Help with linking / loading libraries on Ubuntu 10.10 |
Date: |
Fri, 24 Feb 2012 15:53:52 -0600 |
Hi Randall,
Responding to your note with the help-gsl list CCed...
On Fri, Feb 24, 2012 at 11:25 AM, Rhys Ulerich <address@hidden> wrote:
>> I tried writing a simple C program to use this function (a few other gsl
>> functions) and find that I can use other gsl function fine but cannot use
>> the gsl_poly_complex_eval. Again, in the C program I get a
>> gsl_poly_complex_eval() undefined symbol error.
>
> Would you please send the complete source for your short sample code?
Turns out the problem was a combination of mixing gsl_complex* with
gsl_complex as well as using gsl_poly_complex_eval when you wanted
gsl_complex_poly_complex_eval. Here's a working version of your
sample code:
#include <stdio.h>
#include <stdlib.h>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_cblas.h>
#include <gsl/gsl_poly.h>
void testPoly(void)
{
int i = 0;
int r = 0;
double x[3];
double a = 1.0;
double b = 2.0;
double c = 1.0;
x[0] = 0.0;
x[1] = 0.0;
x[2] = 0.0;
r = gsl_poly_solve_quadratic(a, b, c, &x[0], &x[1]);
printf("r = %d\n a = %f, b = %f, c = %f\n x[0] = %f, x[1] =
%f\n\n", r, a, b, c, x[0], x[1]);
x[0] = 0.0;
x[1] = 0.0;
x[2] = 0.0;
r = gsl_poly_solve_cubic(a, b, c, &x[0], &x[1], &x[2]);
printf("r = %d\n a = %f, b = %f, c = %f\n x[0] = %f, x[1] = %f,
x[2] = %f\n\n", r, a, b, c, x[0], x[1], x[2]);
return;
}
void testComplex(void)
{
gsl_complex a, b, c[5];
gsl_complex r, n;
GSL_SET_COMPLEX(&a, 10, 20);
GSL_SET_COMPLEX(&b, 5, 10);
GSL_SET_REAL(&a, 12);
r = gsl_complex_add(a, b);
printf("Adding Complex Numbers\n");
printf("A.Real: %f\n", GSL_REAL(a));
printf("A.Imag: %f\n", GSL_IMAG(a));
printf("\nARCCSC Function\n");
r = gsl_complex_arccsc(a);
printf("A.Real: %f\n", GSL_REAL(r));
printf("A.Imag: %f\n", GSL_IMAG(r));
printf("\nAdd Real\n");
r = gsl_complex_add_real(a, 10.25);
printf("A.Real: %f\n", GSL_REAL(r));
printf("A.Imag: %f\n", GSL_IMAG(r));
printf("gsl_poly_complex_eval(c, 5, z->number)\n");
c[0].dat[0] = 1.0;
c[0].dat[1] = 0.5;
c[0].dat[0] = 2.0;
c[0].dat[1] = 0.1;
c[0].dat[0] = 3.0;
c[0].dat[1] = 1.5;
c[0].dat[0] = 4.0;
c[0].dat[1] = 2.0;
c[0].dat[0] = 5.0;
c[0].dat[1] = 2.5;
n = gsl_complex_poly_complex_eval(c, 5, a);
printf("r.real = %f, r.imag = %f\n", GSL_REAL(n), GSL_IMAG(n));
return;
}
int main()
{
testComplex();
testPoly();
return 0;
}
Hope that helps,
Rhys