(* :Title: BASES IN A CUBIC NUMBER FIELD *)
	
(* :Author: Will Gilbert, Univ of Waterloo, wgilbert @ uwaterloo.ca  *)
(* :History: written June 1994  *)
(* :Mathematica Version: 2.0 *)

base1::usage = "base1 is the matrix form of the base whose minimum polynomial is  b^3+b^2+b+2";
base1 = {{0,0,-2},{1,0,-1},{0,1,-1}};
vectorAdd[vector1_][vector2_] := vector1 + vector2;
basePower[base_, p_] := Nest[base.# &, {1,0,0}, p];

ListOfVecs::usage = "ListOfVecs[m, b] gives a list of the vectors with representation length less than or equal to  m+3  in the base b, that are multiples of  b^3";
ListOfVecs[m_, base_] := Block[{i=3},
	Nest[Join[#, vectorAdd[basePower[base, i++]] /@ #] &, {{0,0,0}}, m]];

Show[Graphics3D[Map[Cuboid,ListOfVecs[4, base1]/2],
	ViewPoint->{-4.000, 2.600, 2.540}]]
	
base2::usage = "base2 is the matrix form of the base whose minimum polynomial is  b^3+b^2+b-2";
base2 = {{0,0,2},{1,0,-1},{0,1,-1}};
Show[Graphics3D[Map[Cuboid,ListOfVecs[4, base2]/2],
	ViewPoint->{4.000, 1.170, 0.980}]]