[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #38085] image package: fails to build with --e
From: |
Jordi Gutiérrez Hermoso |
Subject: |
[Octave-bug-tracker] [bug #38085] image package: fails to build with --enable-64 |
Date: |
Mon, 16 Mar 2015 15:41:36 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0 Iceweasel/36.0.1 |
Follow-up Comment #7, bug #38085 (project octave):
The line numbers don't seem to match what I see in __spatial__.cc at revision
faa0a913015f. Regardless, the problem seems to be with the following
function:
template <class ET, class MT, class ET_OUT>
ET_OUT entropy_filt (MT &vals, octave_idx_type len, int nbins)
{
ET add;
get_entropy_info<ET> (add, nbins);
// Compute histogram from values
ColumnVector hist (nbins, 0);
for (octave_idx_type i = 0; i < len; i++)
hist (vals (i) + add) ++;
for (octave_idx_type i = 0; i < len; i++)
hist (vals (i) + add) /= (double)len;
// Compute entropy
double entropy = 0;
for (octave_idx_type i = 0; i < nbins; i++)
{
const double p = hist (i);
if (p > 0)
entropy -= p * xlog2 (p);
}
return entropy;
}
A first weirdness is that it's templating the return value ET_OUT, yet it's
always returning a double. I think the template argument ET_OUT is probably
unnecessary, or else entropy should be changed to type ET_OUT so that it can
use both float and double types.
As to the actual bug, I assume the problem is that `vals (i) + add` is
returning octave_int8 values, but those can't be used for indexing. I don't
even know why this used to work. I can't see what conversion path was used
when octave_idx_type was int.
I think a simple fix might be to change those lines to
hist ((vals (i) + add).value ()) ++;
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?38085>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/