# Version differences in Parallelize

I am having a problem which I guess is due to version difference. I have to generate a list of unitary matrices, which I can do easily. However I came to know about Parallelize command by which I wanted to speed the process. First the Hamiltonian (if anybody really wants to check)

X = 1/Sqrt[2] {{0, 1, 0}, {1, 0, 1}, {0, 1, 0}};
Y = I/Sqrt[2] {{0, -1, 0}, {1, 0, -1}, {0, 1, 0}};
Z = DiagonalMatrix[{1, 0, -1}];
Subscript[S, 1, x] = KroneckerProduct[X, IdentityMatrix[3], IdentityMatrix[3]];
Subscript[S, 2, x] = KroneckerProduct[IdentityMatrix[3], X, IdentityMatrix[3]];
Subscript[S, 3, x] = KroneckerProduct[IdentityMatrix[3], IdentityMatrix[3], X];
Subscript[S, 1, y] = KroneckerProduct[Y, IdentityMatrix[3], IdentityMatrix[3]];
Subscript[S, 2, y] = KroneckerProduct[IdentityMatrix[3], Y, IdentityMatrix[3]];
Subscript[S, 3, y] = KroneckerProduct[IdentityMatrix[3], IdentityMatrix[3], Y];
Subscript[S, 1, z] = KroneckerProduct[Z, IdentityMatrix[3], IdentityMatrix[3]];
Subscript[S, 2, z] =  KroneckerProduct[IdentityMatrix[3], Z, IdentityMatrix[3]];
Subscript[S, 3, z] = KroneckerProduct[IdentityMatrix[3], IdentityMatrix[3], Z];
H = Sum[Sum[(Subscript[S, i, x].Subscript[S, j, x] +
Subscript[S, i, y].Subscript[S, j, y] +
Subscript[S, i, z].Subscript[S, j, z]), {j, i + 1, 3}], {i, 1,
3}];


Now, the table

unitary = ParallelTable[Chop[N[MatrixExp[I θ H]]], {θ, 0, 1, 1/100}]; // Timing


The problem is, it is not working in Mathematica 7 and gives the following errors:

MatrixExp::matsq: Argument 0 at position 1 is not a nonempty square matrix.


Mathematica 8 gives result without any trouble and error! I guess it is due to some version difference. Can someone give me a workaround method for both Mathematica 6 and 7? I can only use 6 for any lengthy calculation, and it seems to speed up the calculations a lot.

-

For version 7 I believe you need this before the ParallelTable call:

DistributeDefinitions[H]


For version 6 I don't know, but presumably you will need to define H in each kernel manually.

-
can you tell me how to do that. this is the first time i am trying to use parallel process. i do not know how many kernels it will take (as some other guys use it for same purpose too). – RSG Jul 29 '12 at 11:34
@rsg as version 6 doesn't even have ParallelTable how are you going about this? – Mr.Wizard Jul 29 '12 at 11:37
true. there was a toolkit for 6 by which i hoped i could do some of the things. It seems it is not possible. i have to work in 7 instead. thanks for the help. – RSG Jul 29 '12 at 12:10
@rsg I'm not sure. I think you should not Accept this answer yet as someone may have a solution if they know to look at the question. – Mr.Wizard Jul 29 '12 at 12:13
@rsg just for completeness, the DistributeDefinitions-equivalent function in the PCT is called ExportEnvironment. However, I don't have version 6 or the PCT installed any more so unfortunately I can't test whether 6 can actually do this calculation correctly as stated. – Oleksandr R. Jul 31 '12 at 1:05