[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #50553] eps with imaginary argument gives wron
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #50553] eps with imaginary argument gives wrong value |
Date: |
Wed, 15 Mar 2017 20:00:13 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 |
Update of bug #50553 (project octave):
Category: None => Octave Function
Item Group: None => Matlab Compatibility
Status: None => Confirmed
Operating System: GNU/Linux => Any
_______________________________________________________
Follow-up Comment #1:
Confirmed. The function eps is written in C++ and is located in
libinterp/corefcn/data.cc. The bit of code which is the problem is
Array<double> x = args(0).array_value ();
Array<double> epsval (x.dims ());
for (octave_idx_type i = 0; i < x.numel (); i++)
{
double val = ::fabs (x(i));
if (octave::math::isnan (val) || octave::math::isinf (val))
epsval(i) = lo_ieee_nan_value ();
else if (val < std::numeric_limits<double>::min ())
epsval(i) = pow (2.0, -1074e0);
else
{
int expon;
octave::math::frexp (val, &expon);
epsval(i) = std::pow (2.0,
static_cast<double> (expon - 53));
}
retval = epsval;
}
The first line asks for "array_value" which produces an array of doubles (and
thus only the real part). It seems that this needs to be broken up in to two
sections.
if (args(0).is_complex_type)
{
// Different calculation for complex
}
else
{
// Existing code
}
I don't know if the best strategy is to declare a complex NDArray and then use
the abs() function to produce a real NDArray and then iterate through that.
Or whether we should be using Array directly.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?50553>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/