# Problems with CircleTimes and infix notation

I am trying to create a function called TensorBasis that takes as input a list (thought of as a list of names of basis vectors of a vector space) and an integer d and output the lexicographically ordered basis of the d-fold tensor product of the vector space with itself.

For instance, the output of TensorBasis[{v1,v2},2] should be

{ v1 [\CircleTimes] v1, v1 [\CircleTimes] v2, v2 [\CircleTimes] v1, v2 [\CircleTimes] v2 },


and so on.

I have written the following code:

TensorBasis[labels_, d_] := Module[
{dim = Length[labels], basis, j, k, indexlist, tmp},

basis = ConstantArray[0, dim^d];
tmp = ConstantArray[0, d];

For[j = 1, j <= dim^d, j++,
(* Indexlist stores the indices of the jth element of the basis for the d-fold tensor product  *)

indexlist = InverseLex[dim, d, j];

(* tmp holds the list of individual factors that will make up the jth element of the basis *)
For[k = 1, k <= d, k++,
tmp[[k]] = labels[[indexlist[[k]] ]]
];

(* jth element of the basis is created by tensoring together all elements of tmp *)
basis[[j]] = Infix[tmp, "\[CircleTimes]"]
];
Return[basis]
];


The function InverseLex just gives me the appropriate list of indices for the basis element I am trying to construct. I am sure that that function is working properly. But the output is all weird. The problem is that in the output, the [CircleTimes] (i.e. tensor product) symbol is replaced by some junk: in Plain Text form it is

{Subscript[v, 1]â Subscript[v, 1],Subscript[v, 1]â Subscript[v, 2],Subscript[v, 2]â Subscript[v, 1],Subscript[v, 2]â Subscript[v, 2]}


When I use the Infix notation with "[CircleTimes]" otherwise it works fine. Why won't it work inside this function?

-
With mma v8.0.4.0 in Windows your code gives the expected output. You can also try using basis[[j]] = CircleTimes[Sequence @@ tmp]]. –  kguler May 2 '12 at 8:03
Mma 8.0.1.0 on OSX also gives the desired output. Maybe you have a font issue. –  noe May 2 '12 at 10:48
Hmmm, perhaps it's a Linux issue then if it's working ok on Windows and Mac.... –  MTS May 2 '12 at 15:11
@kguler, your advice worked. Thanks! I am pretty new to Mathematica and didn't know about the Sequence command. –  MTS May 2 '12 at 15:48

Infix is only an output form. You most probably want the expression which you'd get when typing v1 ⊗ v2 into Mathematica, which is entered with either \[CircleTimes] or Escc*Esc.
As you can see by typing v1 ⊗ v2 //FullForm, this is CircleTimes[v1, v2]. The same is true for longer chains of ⊗, i.e. v1 ⊗ v2 ⊗ … ⊗ vn has the internal form CircleTimes[v1, v2, …, vn].
TensorBasis[labels_List,d_Integer] := Outer[CircleTimes, Sequence@@Table[labels,{d}]]