Hi,
please disregard my comment on bif_floor() below.
The proper line should be this (note the - instead of +):
if (D < 1.0 - Workspace::get_CT())
return zv(Z, fr, fi);
With that change
my testcases (which contain the examples of both the ISO
standard and
the IBM language reference) are now properly working again.
Fixed in SVN 970.
/// Jürgen
On 06/23/2017 09:02 PM, Juergen
Sauermann wrote:
Hi Frederick,
I suppose that this is caused by a rounding error just before
the complex floor.
I have attached a debug version of ComplexCell.cc that
prints every partial result of the computation.
If I run it then I get:
5J3 | 14J5
modulus (A) is: (5,3)
A=0 is: (0,0)
A+A=0 is: (5,3)
B÷A+A=0 is: (2.5,-0.5)
⌊B÷A+A=0 is: (3,-1)
A×⌊B÷A+A=0 is: (18,4)
B-A×⌊B÷A+A=0 is: (-4,1)
¯4J1
However if I use a slightly smaller B (kind of
simulating a rounding error) then I get:
5J3 |
14J4.999999999
modulus (A) is: (5,3)
A=0 is: (0,0)
A+A=0 is: (5,3)
B÷A+A=0 is: (2.4999999999118,-0.50000000014706)
⌊B÷A+A=0 is: (2,-1)
A×⌊B÷A+A=0 is: (13,1)
B-A×⌊B÷A+A=0 is: (1,3.999999999)
1J3.999999999
I suppose that is what happens on your machine but not on mine.
You may also want to try out the following. In ComplexCell::bif_floor()
around line 231 ff it says:
// ISO: if D
is tolerantly less than 1 return fr + 0J1×fi
// IBM: if D is less than 1 return fr +
0J1×fi
// However, ISO examples follow IBM (and so do we)
//
// if (D < 1.0 + Workspace::get_CT()) return zv(Z,
fr, fi); // ISO
if (D < 1.0) return zv(Z, fr, fi); // IBM
and examples in ISO
If you uncomment the first if statement then you get the ISO
variant of bif_floor() while otherwise you
get the IBM variant (which is also the one described in the
McDonnel paper). It could be that the ISO variant
works better for the bif_residue() function, but it
causes problems in other places. If uncommenting the if
line should fix your problem, then I can create two variants of
bif_floor(): one for bif_residue() and one
for the rest.
Best Regards,
Jürgen Sauermann
On 06/23/2017 07:31 PM, Frederick
Pitts wrote:
Hello
Jürgen,
SVN 969 on my platform (Fedora 25, Intel(R) Core(TM)
i7-6700 CPU)
5J3
| 14J5 1J4 ¯4J1
gives
1J4
¯4J1 ¯4J1
not
¯1J4
¯4J1 ¯4J1
Regards,
Fred
On Fri, 2017-06-23 at 17:38 +0200, Juergen Sauermann
wrote:
Hi,
I have changed A∣B to literally follow the paper
pointed out by Jay.
The complex floor itself was already implemented like
described in the paper,
but A∣B was not.
Now (SVN 969) the complex A∣B is computed
as
Z←B-A×⌊B÷A+A=0
without any attempts to improve the performance of the
operation.
The result in the 5J3 modulus are now the same
as in IBM APL2 (and I suppose also in J)
5J3 ∣ 14J5 1J4 ¯4J1
¯4J1 ¯4J1 ¯4J1
I hope this finally fixed it. Thanks a lot to all that
helped fixing this bug.
/// Jürgen
On 06/23/2017 09:34 AM, Jay
Foad wrote:
I urge you to read Eugene McDonnell's Complex
Floor, which also discusses Residue. I believe
the design he comes up with in this paper was adopted
more or less verbatim in APL. Also bear in mind that
Floor and Residue in APL have to work well on all
complex numbers, not just the Gaussian
integers.
Jay.
|