/* tplrt.c CCMATH mathematics library source code. * * Copyright (C) 2000 Daniel A. Atkinson All rights reserved. * This code may be redistributed under the terms of the GNU library * public license (LGPL). ( See the lgpl.license file for details.) * ------------------------------------------------------------------------ */ /* Test: plrt polyc To use an input data file call 'tplrt file'. Input data files pol1.dat and pol2.dat */ #include "ccmath.h" #include #define NN 10 /* complex structure is defined by */ /* struct complex {double re,im;}; */ int n=7; double cof[]={ 10., -4., 7., 8., -3., 7., -2., 1.}; void main(int na,char **av) { struct complex py,root[NN]; double ra,rb,s; int i,ns; FILE *fp; if(na==2){ fp=fopen(*++av,"r"); for(n=0; fscanf(fp,"%lf",cof+n)!=EOF ;++n); } printf(" Test of Polynomial Root Program\n"); printf(" polynomial degree = %d\n",n); printf(" coefficients:\n"); for(i=n; i>=0 ;) printf(" %8.4f\n",cof[i--]); ra=1.; rb=2.; ns=plrt(cof,n,root,ra,rb); printf(" return status = %d\n",ns); printf(" roots and residuals\n"); for(i=0; i