hermann on Tue, 27 May 2025 20:40:56 +0200


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

Re: How to determine Mod(a,b) with t_COMPLEX b?


On 2025-05-27 18:27, hermann@stamm-wilbrandt.de wrote:

I found the reason for no difference — real(b) and imag(b) were relative prime.
If not relative prime, there are differences:

? b*=2
6 + 4*I
? S=Set([a - round(a/b)*b |
r<-[-real(b)..real(b)];i<-[-imag(b)..imag(b)];a<-[r+i*I]]);
? myS=Set([a - myround(a/b)*b |
r<-[-real(b)..real(b)];i<-[-imag(b)..imag(b)];a<-[r+i*I]]);
? #S==norml2(b)&&#myS==norml2(b)
1
? setminus(S,myS)
[-3 - 2*I, -1 - 5*I, 2 - 3*I]
? setminus(myS,S)
[-2 + 3*I, 1 + 5*I, 3 + 2*I]
?

Last, but not least, a picture:

? b
6 + 4*I
? imi=vecmin([imag(s)|s<-S]);
? ima=vecmax([imag(s)|s<-S]);
? rmi=vecmin([real(s)|s<-S]);
? rma=vecmax([real(s)|s<-S]);
? M=matrix(ima-imi+1,rma-rmi+1);
? foreach(S,s,M[imag(s)-imi+1,real(s)-rmi+1]=1)
? foreach(M~,m,foreach(m,e,print1(if(e,"x"," ")));print())
   x
   xx
  xxxxx
 xxxxxxx
 xxxxxxxx
xxxxxxxxx
xxxxxxxx
 xxxxxx
   xxxx
    xx
?


Regards,

Hermann.