MATLAB: How to use the Parallel Computing Toolbox 4.1 (R2009a) to find the singular value decomposition of a large matrix

functionsmathmathematicalParallel Computing Toolboxpct

I am trying to determine the singular value decomposition of a large matrix using the Parallel Computing Toolbox 4.1 (R2009a) without being in pmode.

Best Answer

To determine the singular value decomposition (svd) of a large matrix in the Parallel Computing Toolbox 4.1 (R2009a) without using pmode, create a MATLAB function file that creates a codistributed matrix and finds the svd of the matrix.
The concept is illustrated using an example given below:
 
function y = thisJob(n)
x = rand(n,codistributor());
y = svd(x);
Execute the following commands to run the above job on the worker machines:
 
main.m
An example of math with a codistributed matrix in non-pmode
% Find the available parallel computing resources
sched = findResource('scheduler','type','local');
% Construct a parallel job object using the resources
pjob = createParallelJob(sched);
% Set the dimension of the random matrix
a = 16;
% Set the file thisJob.m so that the workers can access it.
pjob.FileDependencies={'thisJob.m'}
% Add the task to the job.
createTask(pjob,@thisJob, 1, {a});
% Run the job.
submit(pjob);
% Retrieve job results.
waitForState(pjob);
out = getAllOutputArguments(pjob);
% Display the random matrices.
% Note: the output values in each worker will all be the same, they
% represent the singular values of the matrix.
out{1}
% Destroy the job.
destroy(pjob);