% pmode script
%
% on the host enter
pmode start local 4
% on the workers
help magic
clc
labindex
numlabs
% SIMD calculations 
M = magic(8)
M*ones(8,1)
A = labindex*eye(8) - 0.01*M
y = A*ones(8,1)
x = A\y
B = A'*A
R = chol(B)
R'*R - B
eig(B)
[V,D] = eig(B)
% MPI calculations
M
% distribute the matrix M across the workers
c1 = 2*(labindex-1)+1
c2 = c1+1
segment = M(:,c1:c2)
M = distributed(segment,distributor())
% Now repeat the calculations with each worker
% doing their piece of the calculation.
M*ones(8,1)
A = eye(8) - 0.01*M
y = A*ones(8,1)
A\y
B = A'*A
R = chol(B)
R'*R - B
eig(B)
[V,D] = eig(B)
% Wrap up
% on the host enter
pmode exit