[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61319] idivide fails to distinguish between c
From: |
Markus Mützel |
Subject: |
[Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares |
Date: |
Mon, 21 Feb 2022 14:17:54 -0500 (EST) |
Follow-up Comment #14, bug #61319 (project octave):
Integer division for Octave integer types doesn't follow the same rules as in
C++ for compatibility with Matlab.
Afaict, it is implemented here:
https://hg.savannah.gnu.org/hgweb/octave/file/9a95ccd6c417/liboctave/util/oct-inttypes.h#l491
// Division with rounding to nearest. Note that / and % are
// probably computed by a single instruction.
static T div (T x, T y)
{
if (y != 0)
{
T z = x / y;
T w = x % y;
if (w >= y-w)
z += 1;
return z;
}
else
return x ? octave_int_base<T>::max_val () : 0;
}
You are right that we'll essentially need to revert that post-processing. But
afaict, there is no way to "just" call the C++ division from .m code. (Please,
correct me if that is wrong.)
It would probably be possible to unpack the underlying rep in an .oct file
function, apply the C++ integer division to that and repack into an Octave
array. But with the function call overhead, I don't know if that would be any
faster...
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61319>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Gaël Bonithon, 2022/02/20
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Gaël Bonithon, 2022/02/21
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Markus Mützel, 2022/02/21
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Michael Leitner, 2022/02/21
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares,
Markus Mützel <=
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Michael Leitner, 2022/02/21
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Markus Mützel, 2022/02/22
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Michael Leitner, 2022/02/22
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Gaël Bonithon, 2022/02/22
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Gaël Bonithon, 2022/02/23
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Michael Leitner, 2022/02/23
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Gaël Bonithon, 2022/02/23
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Markus Mützel, 2022/02/26
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Gaël Bonithon, 2022/02/27
- [Octave-bug-tracker] [bug #61319] idivide fails to distinguish between ceil and floor for inputs close to perfect squares, Markus Mützel, 2022/02/27