Well, there's a very simple fix for the problem we're seeing here. Here's the definition of the remainder function, from vz.c (you don't have to read the whole thing!)
ZF2(jtzrem){D a,b,d;Z q; if(ZEZ(u))R v; ZASSERT(!ZINF(v),EVNAN); if(INF(u.re)&&!u.im&&!v.im){ if(u.re==inf )R 0<=v.re?v:u; if(u.re==infm)R 0>=v.re?v:u; } ZASSERT(!ZINF(u),EVNONCE); d=u.re*u.re+u.im*u.im; a=u.re*v.re+u.im*v.im; q.re=tfloor(0.5+a/d); b=u.re*v.im-u.im*v.re; q.im=tfloor(0.5+b/d); R zminus(v,ztymes(u,q)); } The offending code here is the "0.5+" when q.re and q.im are evaluated. q should be the "integer division" of u by v, so that v - u*q (the last line) will give us the remainder. I'm looking into how this affects antibase just to check that I don't mess anything up there. However, I think that barring backwards compatibility issues, this is definitely a fix that needs to be made. Marshall On Sun, Jan 22, 2012 at 2:36 PM, Marshall Lochbaum <mwlochb...@gmail.com>wrote: > That isn't what complex | does, or what it should do, I think. However, it > is a consistent extension of "mod" to the complex numbers--we are just > using a different subgroup of the complex numbers to mod out by. > Note, however, that this approach adapts poorly to complex left arguments. > It still works, by subtracting (real) integer multiples of x from y, but > the resultant range is a weird bar in the complex plane. > As you noted, it's easy to define your version in terms of real | . > > Marshall > > > On Sun, Jan 22, 2012 at 2:27 PM, Bo Jacoby <bojac...@yahoo.dk> wrote: > >> I wanted to take 'mod' of the real part and leave the imaginary part >> untouched. >> f=:(|9&o.)+j.&(11&o.)&] >> 7 f 73j73+i.6 >> 3j73 4j73 5j73 6j73 0j73 1j73 >> Perhaps this is not done by a complex '|' ? >> >> >> >> >> >________________________________ >> > Fra: Marshall Lochbaum <mwlochb...@gmail.com> >> >Til: Programming forum <programming@jsoftware.com> >> >Sendt: 19:50 søndag den 22. januar 2012 >> >Emne: Re: [Jprogramming] 5|0 1 2 3 4 is not equal to 5|0 1 2 3 4 j.0 >> > >> >It would be possible to change complex mod without changing floor. Floor >> is >> >consistent on reals and complex numbers, while complex mod is not, so it >> >doesn't necessarily need to be fixed. >> > >> >The problem with complex mod is that for left argument b it that it >> ensures >> >that the result is in the box defined by corners -:(j./~ _0.5 0.5)*b . >> That >> >means that it subtracts the closest Gaussian integer multiple of b from >> the >> >right argument. This is inconsistent with mod for the reals, which >> >subtracts the floor under division by b. >> > >> >Marshall >> > >> >On Sun, Jan 22, 2012 at 1:28 PM, Henry Rich <henryhr...@nc.rr.com> >> wrote: >> > >> >> Well, I know complex floor was something Gene McDonnell was proud of, >> >> and I expect it's embedded in some applications. You'll need to >> produce >> >> a compelling argument for changing it. >> >> >> >> Henry Rich >> >> >> >> On 1/22/2012 12:38 PM, Marshall Lochbaum wrote: >> >> > I'm pretty sure I understand the definition, but I still don't get >> the >> >> > rationale. Under my scheme the "obvious" complex floor would be (- >> 1&|), >> >> > which also has the properties of convexity, translatability, and >> >> > compatibility listed in the dictionary. >> >> > >> >> > Marshall >> >> > >> >> > On Sun, Jan 22, 2012 at 12:08 PM, Henry Rich<henryhr...@nc.rr.com> >> >> wrote: >> >> > >> >> >> As Don said, make sure you understand complex floor before you start >> >> >> coding. >> >> >> >> >> >> Henry Rich >> >> >> >> >> >> On 1/22/2012 11:38 AM, Marshall Lochbaum wrote: >> >> >>> The theory of moduli is based on the quotient group of the >> integers by >> >> a >> >> >>> subgroup. For instance, the integers (mod 2) are produced by >> taking all >> >> >> the >> >> >>> integers and identifying all the ones that are even, as well as >> all the >> >> >>> ones that are odd. Then we get a two-element group which we can >> preform >> >> >>> addition on: even+even=even, even+odd=odd, etc. >> >> >>> >> >> >>> To reduce a number in a particular modulus, we need to find a >> canonical >> >> >>> representation for that number. For positive numbers n the choice >> is >> >> >> fairly >> >> >>> simple: n|l gives the l' such that 0<=l'<n. In the complex plane, a >> >> >> number >> >> >>> generates a grid by taking its product with the Gaussian integers; >> try >> >> >>> 'dot; pensize 2' plot , 1j2 * j./~i:10 >> >> >>> to see what I mean. Then what we want is a canonical form for what >> >> >> happens >> >> >>> when we identify all those points together. We're allowed to >> "shift" by >> >> >> any >> >> >>> Gaussian integer times the modulus. >> >> >>> >> >> >>> Based on this, I think a good way to calculate the modulus is to >> get >> >> the >> >> >>> number into the square that lies counterclockwise of the modulus >> >> number. >> >> >>> Practically, this means we decompose a complex number y into (a >> j.b)*x, >> >> >> and >> >> >>> then return (1|a)j.(1|b) . >> >> >>> >> >> >>> I'll see if I can get around to editing this. I have a working >> copy of >> >> >> the >> >> >>> source, but I haven't made sense of it entirely. >> >> >>> >> >> >>> Marshall >> >> >>> >> >> >>> On Sun, Jan 22, 2012 at 10:45 AM, Raul Miller< >> rauldmil...@gmail.com> >> >> >> wrote: >> >> >>> >> >> >>>> Yes, this is a bug. >> >> >>>> >> >> >>>> Someone should fix it. >> >> >>>> >> >> >>>> J is open source. (Though distributed sources do not compile for >> me, >> >> >>>> and I keep getting sidetracked when I investigate forks that might >> >> >>>> compile.) >> >> >>>> >> >> >>>> -- >> >> >>>> Raul >> >> >>>> >> ---------------------------------------------------------------------- >> >> >>>> For information about J forums see >> >> http://www.jsoftware.com/forums.htm >> >> >>>> >> >> >>> >> ---------------------------------------------------------------------- >> >> >>> For information about J forums see >> http://www.jsoftware.com/forums.htm >> >> >>> >> >> >> >> ---------------------------------------------------------------------- >> >> >> For information about J forums see >> http://www.jsoftware.com/forums.htm >> >> >> >> >> > >> ---------------------------------------------------------------------- >> >> > For information about J forums see >> http://www.jsoftware.com/forums.htm >> >> > >> >> ---------------------------------------------------------------------- >> >> For information about J forums see http://www.jsoftware.com/forums.htm >> >> >> >---------------------------------------------------------------------- >> >For information about J forums see http://www.jsoftware.com/forums.htm >> > >> > >> > >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm