bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Modulo or residue function is not generating consistent co


From: Juergen Sauermann
Subject: Re: [Bug-apl] Modulo or residue function is not generating consistent complete residue systems for some arguments
Date: Tue, 20 Jun 2017 14:14:02 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Hi Frederick,

the algorithm for A ∣ B used in GNU APL is this:

- compute the quotient QB÷A,
- "round down" Q to the next (complex) integer Q1,
- return B - Q1×A


Now the problem seems to be what is meant by "round down". There are two candidates:

  Q1 ← ⌊ Q                                          i.e. use APL floor to round down Q
  Q1 ← Complex( floor(Q.real(),
floor(Q.imag()) )   i,e, use C/C++ floor() to round down Q.

In your  5J3 ∣ 14J5 example, the quotient is 2.5J¯0.5, which gives different results for the APL floor and the C/C++ floor().

The APL floor
2.5J¯0.5 is 3J¯1 (a somewhat dubious invention in the ISO standard on page 19, which I used up to
including SVN 963), while the C/C++ floor() is
2J¯1. The difference between the APL floor and the C/C++ floor is 1.0 which,
multiplied by the divisor, explains the differences that we see.

As of SVN 964 I have changed the residue function () to use the C/C++ floor instead of the APL floor. The APL floor and
Ceiling functions ( and ) are still using the apparently broken definition in the ISO standard.

I hope this works better for you. At least I am getting this in SVN 964:

      5J3 | 14J5
1J4
      5J3 | 1J4
1J4


whereas SVN 963 was giving:

      5J3 | 14J5
¯4J1
      5J3 | 1J4
¯4J1



Best Regards,
/// Jürgen



On 06/19/2017 07:03 PM, Frederick Pitts wrote:
Jürgen,

	With gnu apl (svn 961 on Fedora 25, Intel(R) Core(TM) i7-6700
CPU), the residue function (∣) yields the following:

      5J3 ∣ 14J5
1J4
      5J3 | 1J4
¯4J1
      5J3 | ¯4J1
¯4J1
The above result means that two elements in the complete residue system
(CSR) for mod 5J3 are equal, i.e. 1J4 = ¯4J1 mod 5J3, which is not
allowed.  None of the elements of a CSR can be equal modulo the CSR's
basis.

Regards,

Fred



reply via email to

[Prev in Thread] Current Thread [Next in Thread]