From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6042 invoked by alias); 13 Dec 2007 20:05:31 -0000 Received: (qmail 6022 invoked by uid 22791); 13 Dec 2007 20:05:28 -0000 X-Spam-Check-By: sourceware.org Received: from nf-out-0910.google.com (HELO nf-out-0910.google.com) (64.233.182.186) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 13 Dec 2007 20:05:21 +0000 Received: by nf-out-0910.google.com with SMTP id b11so719958nfh.48 for ; Thu, 13 Dec 2007 12:05:17 -0800 (PST) Received: by 10.86.79.19 with SMTP id c19mr2190936fgb.31.1197576317657; Thu, 13 Dec 2007 12:05:17 -0800 (PST) Received: from ?192.168.178.21? ( [87.189.21.222]) by mx.google.com with ESMTPS id y18sm421412fkd.2007.12.13.12.05.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 13 Dec 2007 12:05:15 -0800 (PST) Message-ID: <47619079.3040000@googlemail.com> Date: Thu, 13 Dec 2007 20:05:00 -0000 From: Frank Reininghaus User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 To: gsl-discuss@sourceware.org Subject: Re: Complex polynomial evaluation References: <475F1765.5020300@googlemail.com> <87d4tb3lmv.wl%bjg@network-theory.co.uk> In-Reply-To: <87d4tb3lmv.wl%bjg@network-theory.co.uk> Content-Type: multipart/mixed; boundary="------------010409060107050207060503" Mailing-List: contact gsl-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sourceware.org X-SW-Source: 2007-q4/txt/msg00042.txt.bz2 This is a multi-part message in MIME format. --------------010409060107050207060503 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 694 Hi, I've written some documentation for my complex polynomial evaluation functions and some test cases to be checked by 'make check'. I've created patches containing all my modifications to the current CVS version with diff gsl/poly/ [my directory with new version of 'poly'] > patch-poly diff gsl/doc/ [my directory with new version of 'doc'] > patch-doc Let me know if there is a way I could create patch files that are more convenient to you. patch-doc also contains a correction for a typo in the macro @inlinefns in doc/gsl-ref.texi. I think it should be "Inline versions of these *functions* are used...", not "Inline versions of these *function* are used..." Regards, Frank --------------010409060107050207060503 Content-Type: text/plain; name="patch-doc" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-doc" Content-length: 1533 Common subdirectories: gsl/doc/CVS and /home/frank/tmp/doc-with-complex-polynomials/CVS Common subdirectories: gsl/doc/examples and /home/frank/tmp/doc-with-complex-polynomials/examples diff gsl/doc/gsl-ref.texi /home/frank/tmp/doc-with-complex-polynomials/gsl-ref.texi 127c127 < Inline versions of these function are used when @code{HAVE_INLINE} is defined. --- > Inline versions of these functions are used when @code{HAVE_INLINE} is defined. diff gsl/doc/poly.texi /home/frank/tmp/doc-with-complex-polynomials/poly.texi 25,26c25 < @deftypefun double gsl_poly_eval (const double @var{c}[], const int @var{len}, const double @var{x}) < This function evaluates the polynomial --- > The functions described here evaluate the polynomial 29c28,39 < Horner's method for stability. @inlinefn{} --- > Horner's method for stability. @inlinefns{} > > @deftypefun double gsl_poly_eval (const double @var{c}[], const int @var{len}, const double @var{x}) > This function evaluates a polynomial with real coefficients for the real variable @var{x}. > @end deftypefun > > @deftypefun gsl_complex gsl_poly_complex_eval (const double @var{c}[], const int @var{len}, const gsl_complex @var{x}) > This function evaluates a polynomial with real coefficients for the complex variable @var{x}. > @end deftypefun > > @deftypefun gsl_complex gsl_complex_poly_complex_eval (const gsl_complex @var{c}[], const int @var{len}, const gsl_complex @var{x}) > This function evaluates a polynomial with complex coefficients for the complex variable @var{x}. --------------010409060107050207060503 Content-Type: text/plain; name="patch-poly" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-poly" Content-length: 5231 Common subdirectories: gsl/poly/CVS and /home/frank/tmp/poly-with-complex-evaluation/CVS diff gsl/poly/eval.c /home/frank/tmp/poly-with-complex-evaluation/eval.c 35a36,68 > > gsl_complex > gsl_poly_complex_eval(const double c[], const int len, const gsl_complex x) > { > int i; > gsl_complex ans; > GSL_SET_COMPLEX (&ans, c[len-1], 0.0); > for(i=len-1; i>0; i--) { > /* The following three lines are equivalent to > ans = gsl_complex_add_real (gsl_complex_mul (x, ans), c[i-1]); > but faster */ > double tmp = c[i-1] + GSL_REAL (x) * GSL_REAL (ans) - GSL_IMAG (x) * GSL_IMAG (ans); > GSL_SET_IMAG (&ans, GSL_IMAG (x) * GSL_REAL (ans) + GSL_REAL (x) * GSL_IMAG (ans)); > GSL_SET_REAL (&ans, tmp); > } > return ans; > } > > gsl_complex > gsl_complex_poly_complex_eval(const gsl_complex c[], const int len, const gsl_complex x) > { > int i; > gsl_complex ans = c[len-1]; > for(i=len-1; i>0; i--) { > /* The following three lines are equivalent to > ans = gsl_complex_add (c[i-1], gsl_complex_mul (x, ans)); > but faster */ > double tmp = GSL_REAL (c[i-1]) + GSL_REAL (x) * GSL_REAL (ans) - GSL_IMAG (x) * GSL_IMAG (ans); > GSL_SET_IMAG (&ans, GSL_IMAG (c[i-1]) + GSL_IMAG (x) * GSL_REAL (ans) + GSL_REAL (x) * GSL_IMAG (ans)); > GSL_SET_REAL (&ans, tmp); > } > return ans; > } diff gsl/poly/gsl_poly.h /home/frank/tmp/poly-with-complex-evaluation/gsl_poly.h 44a45,46 > > /* real polynomial, real x */ 46a49,54 > /* real polynomial, complex x */ > gsl_complex gsl_poly_complex_eval (const double c [], const int len, const gsl_complex x); > > /* complex polynomial, complex x */ > gsl_complex gsl_complex_poly_complex_eval (const gsl_complex c [], const int len, const gsl_complex x); > 57a66,100 > > extern inline > gsl_complex > gsl_poly_complex_eval(const double c[], const int len, const gsl_complex x) > { > int i; > gsl_complex ans; > GSL_SET_COMPLEX (&ans, c[len-1], 0.0); > for(i=len-1; i>0; i--) { > /* The following three lines are equivalent to > ans = gsl_complex_add_real (gsl_complex_mul (x, ans), c[i-1]); > but faster */ > double tmp = c[i-1] + GSL_REAL (x) * GSL_REAL (ans) - GSL_IMAG (x) * GSL_IMAG (ans); > GSL_SET_IMAG (&ans, GSL_IMAG (x) * GSL_REAL (ans) + GSL_REAL (x) * GSL_IMAG (ans)); > GSL_SET_REAL (&ans, tmp); > } > return ans; > } > > extern inline > gsl_complex > gsl_complex_poly_complex_eval(const gsl_complex c[], const int len, const gsl_complex x) > { > int i; > gsl_complex ans = c[len-1]; > for(i=len-1; i>0; i--) { > /* The following three lines are equivalent to > ans = gsl_complex_add (c[i-1], gsl_complex_mul (x, ans)); > but faster */ > double tmp = GSL_REAL (c[i-1]) + GSL_REAL (x) * GSL_REAL (ans) - GSL_IMAG (x) * GSL_IMAG (ans); > GSL_SET_IMAG (&ans, GSL_IMAG (c[i-1]) + GSL_IMAG (x) * GSL_REAL (ans) + GSL_REAL (x) * GSL_IMAG (ans)); > GSL_SET_REAL (&ans, tmp); > } > return ans; > } diff gsl/poly/test.c /home/frank/tmp/poly-with-complex-evaluation/test.c 33a34,35 > /* Polynomial evaluation */ > 52a55,108 > { > gsl_complex x, y; > double c[1] = {0.3}; > GSL_SET_REAL (&x, 0.75); > GSL_SET_IMAG (&x, 1.2); > y = gsl_poly_complex_eval (c, 1, x); > > gsl_test_rel (GSL_REAL (y), 0.3, eps, "y.real, gsl_poly_complex_eval ({0.3}, 0.75 + 1.2i)"); > gsl_test_rel (GSL_IMAG (y), 0.0, eps, "y.imag, gsl_poly_complex_eval ({0.3}, 0.75 + 1.2i)"); > } > > { > gsl_complex x, y; > double c[4] = {2.1, -1.34, 0.76, 0.45}; > GSL_SET_REAL (&x, 0.49); > GSL_SET_IMAG (&x, 0.95); > y = gsl_poly_complex_eval (c, 4, x); > > gsl_test_rel (GSL_REAL (y), 0.3959143, eps, "y.real, gsl_poly_complex_eval ({2.1, -1.34, 0.76, 0.45}, 0.49 + 0.95i)"); > gsl_test_rel (GSL_IMAG (y), -0.6433305, eps, "y.imag, gsl_poly_complex_eval ({2.1, -1.34, 0.76, 0.45}, 0.49 + 0.95i)"); > } > > { > gsl_complex x, y; > gsl_complex c[1]; > GSL_SET_REAL (&c[0], 0.674); > GSL_SET_IMAG (&c[0], -1.423); > GSL_SET_REAL (&x, -1.44); > GSL_SET_IMAG (&x, 9.55); > y = gsl_complex_poly_complex_eval (c, 1, x); > > gsl_test_rel (GSL_REAL (y), 0.674, eps, "y.real, gsl_complex_poly_complex_eval ({0.674 - 1.423i}, -1.44 + 9.55i)"); > gsl_test_rel (GSL_IMAG (y), -1.423, eps, "y.imag, gsl_complex_poly_complex_eval ({0.674 - 1.423i}, -1.44 + 9.55i)"); > } > > { > gsl_complex x, y; > gsl_complex c[4]; > GSL_SET_REAL (&c[0], -2.31); > GSL_SET_IMAG (&c[0], 0.44); > GSL_SET_REAL (&c[1], 4.21); > GSL_SET_IMAG (&c[1], -3.19); > GSL_SET_REAL (&c[2], 0.93); > GSL_SET_IMAG (&c[2], 1.04); > GSL_SET_REAL (&c[3], -0.42); > GSL_SET_IMAG (&c[3], 0.68); > GSL_SET_REAL (&x, 0.49); > GSL_SET_IMAG (&x, 0.95); > y = gsl_complex_poly_complex_eval (c, 4, x); > > gsl_test_rel (GSL_REAL (y), 1.82462012, eps, "y.real, gsl_complex_poly_complex_eval ({-2.31 + 0.44i, 4.21 - 3.19i, 0.93 + 1.04i, -0.42 + 0.68i}, 0.49 + 0.95i)"); > gsl_test_rel (GSL_IMAG (y), 2.30389412, eps, "y.imag, gsl_complex_poly_complex_eval ({-2.31 + 0.44i, 4.21 - 3.19i, 0.93 + 1.04i, -0.42 + 0.68i}, 0.49 + 0.95i)"); > } > --------------010409060107050207060503--