|
From: | Rik |
Subject: | [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1 |
Date: | Mon, 06 Oct 2014 20:25:41 +0000 |
User-agent: | Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0 |
Follow-up Comment #9, bug #43349 (project octave): I agree that the problem is the conversion of a real to a complex value with zero for the imaginary unit. I think the problem is that we use the default form of the C++ Complex constructor with just a single argument. The Complex constructor is shown below template<> class complex<double> { complex (double re = 0.0, double im = 0.0); When it is called in rc_asin with just a single argument then the imaginary unit takes the default which is always +0.0. return fabs (x) > 1.0 ? asin (Complex (x)) : Complex (asin (x)); However, if I use the two argument form and explicitly set the phase of the imaginary unit then I get the correct answer. The replacement code below works on the examples in this bug report. Complex rc_asin (double x) { return fabs (x) > 1.0 ? asin (Complex (x, signbit (x) ? -0.0 : +0.0)) : Complex (asin (x)); } _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?43349> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |