This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Recommended addition to solve_quadratic.c


Hi,

I'm not sure this qualifies as a bug, so I'm submitting it for your review instead. I've been taking advantage of gsl to upgrade some simulation math libraries we've been using.  For simulation purposes, the 'a' term in a quadratic equation describing motion can occasionally go to zero.  I noticed that solve_quadratic.c does not handle or report an attempted divide-by-zero in that case.  I've added a quick check at the start of the function that requires no changes to documentation or normal behavior.  I've attached a revised version of the source file.  Feel free to incorporate it into your next GPL release.

I would also like to see equal roots returned as a 1 instead of a 2, but I'm sure there is a lot of code that depends upon the current behavior and the documentation would have to be changed.

// Dave

===================================================
L. David Balk, Senior Professional Staff
Johns Hopkins University Applied Physics Laboratory
11100 Johns Hopkins Road, Laurel, MD 20723-6099
Tel. 1-443-778-0791, David.Balk@jhuapl.edu
===================================================

Attachment: solve_quadratic_rev.c
Description: solve_quadratic_rev.c


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]