[seqfan] Re: Project: sequences obtained from Gaussian Integers via Penney's binary method of encoding?
Kevin Ryde
user42_kevin at yahoo.com.au
Tue Oct 18 02:10:52 CEST 2016
zabolotis at mail.ru (Андрей Заболотский) writes:
>
> Now here is the script for negation and addition of Gaussian integers
> written in base i-1 with bit twiddling and all that:
> http://pastebin.com/uHJW13zf
On the addition there might be similar in Gilbert, I can't quite tell.
http://www.math.uwaterloo.ca/~wgilbert/Research/ArithCxBases.pdf
Personally I've found shapes or counts more interesting. :)
For the conversion z->n, you can go by bits if preferred, low to high up
the z = ... a2*b^2 + a1*b + a0 formula. Re+Im mod 2 is the low bit,
then subtract and divide b=i-1. Some gp code I used below. Similar for
other bases and digit sets, even dragon curve etc if work in suitable
"direction" factor.
fromdigits(v,base=10) = subst(Pol(v),'x,base); \\ new in gp 2.8.x
z_mod_b(z) = (real(z) + imag(z)) % 2;
z_base_to_n(z,b) = {
my(l=List([])); \\ bits of n low to high
while(z,
my(bit=z_mod_b(z));
listput(l,bit);
my(new_z=(z-bit)/b);
if(z==new_z,return(-1)); \\ no n for this z
z=new_z);
fromdigits(Vecrev(l),2);
}
MinusUnpoint(z) = z_base_to_n(z,I-1);
PlusUnpoint(z) = z_base_to_n(z,I+1);
matrix(5,11,y,x,y=3-y;x-=6; MinusUnpoint(x+y*I))
matrix(5,11,y,x,y=3-y;x-=6; PlusUnpoint(x+y*I))
More information about the SeqFan
mailing list