transVec[{rep_,order_,scale_}] :=
Block[ { vec={},n=Length[rep],q,j1,m1,j2,m2,j12,m12,newrep } ,
q = 2 order ;
If[ order!=0 ,
j1 = rep[[q-1]] ;
j2 = rep[[q]] ;
j12 = rep[[q+1]] ;
m12 = rep[[q+2]] ;
For[ m1=-j1,m1<=j1,m1++,
m2=m12-m1 ;
If[ ((-j2<=m2) && (m2<=j2)),
newrep=Delete[rep,q+1] ;
newrep=Delete[newrep,q+1] ;
newrep=Insert[newrep,m1,q] ;
newrep=Insert[newrep,m2,q+2] ;
vec=Join[vec,
transVec[{newrep,
order-1,
scale*cg[j1,j2,m1,m2,j12,m12]}] ] ;
] ;
] ; ,
Return[{{rep,order,scale}}] ;
] ;
Return[vec] ;
] ;
The argument of transVec is a length-three list consisting of
rep, the representation of the basis vector in the basis produced
by genVecs, order, the order of the representation given,
usually N-1, where N is the number of spins (note that transVec
is recursive, order keeps track of the depth), and scale,
the value of the normalization of the vector generated. For example,
Along with transVec, the routine transVecs transforms a list of many vectors, such as would be produced by the output of genVecs.
transVecs[x_] :=
Block[ {n,vecs={},i} ,
n=Length[x] ;
For[ i=1,i<=n,i++,
vecs=Join[vecs,{transVec[x[[i]]]}] ;
] ;
Return[vecs] ;
] ;
For example