[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] what's wrong in my poly code?
From: |
Marco Maggi |
Subject: |
[Help-gsl] what's wrong in my poly code? |
Date: |
Fri, 10 Nov 2006 20:55:50 +0100 |
If I run the following GNU Octave code:
real_coeffs = [1 2 3 4 5];
roots(real_coeffs)
I get:
ans =
-1.2878 + 0.8579i
-1.2878 - 0.8579i
0.28782 + 1.4161i
0.28782 - 1.4161i
if I run the following GSL code:
#include <gsl/gsl_poly.h>
#include <stdio.h>
#include <stdlib.h>
int
main (int argc, const char *const argv[])
{
gsl_poly_complex_workspace * w;
double coeffs[5] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
double result[10];
int e;
size_t i;
w = gsl_poly_complex_workspace_alloc(5);
e = gsl_poly_complex_solve(coeffs, 5, w, result);
gsl_poly_complex_workspace_free(w);
for (i=0; i<8; i+=2)
{
printf("%f %f\n", result[i], result[i+1]);
}
return 0;
}
I get:
0.137832 0.678154
0.137832 -0.678154
-0.537832 0.358285
-0.537832 -0.358285
what am I doing wrong?
TIA
--
Marco Maggi
"They say jump!, you say how high?"
Rage Against the Machine - "Bullet in the Head"
- [Help-gsl] what's wrong in my poly code?,
Marco Maggi <=