vectorize mldivide
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Currently I'm using mldivide in the following way: A data vector and a number of model vectors which are added up to approximate the data. I want to determine the scaling factors (coefficients) of the model vectors to approximate the data (least squares...).
example: data [1024,1]; %1 data vector with 1024 elements models [1024,4]; %4 model vectors
coeff = models\data;
Now I want to run hundreds/thousands of those linear optimizations concurrently (even using an identical data vector but thats not so much the point). As mldivide doesn't support this I'm forced to run this in a loop. To use parfor doesn't get me any speedup (even takes 2x longer).
3 Kommentare
David Provencher
am 9 Dez. 2011
Are the optimization problems completely different from one another (i.e. the data and model vectors change every time)? Or is the data vector the same?
Antworten (1)
Titus Edelhofer
am 9 Dez. 2011
Hi,
there is probably not too much you can do (as long as the models differ from run to run). On the other hand:
x = rand(1024,4);
y = ones(1024, 1);
results = zeros(1000, 4);
tic,
for i=1:1000
results(i,:) = (x\y)';
end
time=toc
%
time =
0.1164
The loop shouldn't be all that bad for the size of your problem...?
Titus
Siehe auch
Kategorien
Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!