#include <stdlib.h>
#include "laguerre.h"

#define TNArraySize  30   /* maximum size of vectors */

void main()
{
 TNCompVector *Poly, *Roots, *yRoots;
 TNIntVector *Iter;
 TNcomplex InitGuess;
 double Tol = 1e-20;
 int Degree = 6, MaxIter = 10000, NumRoots, Error, i;
 InitGuess.Re = 0; InitGuess.Im = -1;

 Poly = ( TNCompVector * ) calloc(TNArraySize,sizeof(TNcomplex));
 Roots = ( TNCompVector * ) calloc(TNArraySize,sizeof(TNcomplex));
 yRoots = ( TNCompVector * ) calloc(TNArraySize,sizeof(TNcomplex));


 Poly[6].Re =   1;  Poly[6].Im = 0;
 Poly[5].Re =   3;  Poly[5].Im = 0;
 Poly[4].Re =   2;  Poly[4].Im = 0;
 Poly[3].Re = -18;  Poly[3].Im = 0;
 Poly[2].Re = -20;  Poly[2].Im = 0;
 Poly[1].Re =   0;  Poly[1].Im = 0;
 Poly[0].Re =  32;  Poly[0].Im = 0;

 Laguerre(&Degree, &Poly, InitGuess, Tol, MaxIter, &NumRoots,
			   &Roots, &yRoots, &Iter, &Error);

 for ( i = 1; i < 7; i++)
 {
   printf("{ %f, %f }\n",Roots[i].Re,Roots[i].Im);
 }
 free(Poly);free(Roots);free(yRoots);free(Iter);
}
