vectorize mldivide
16 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
David Provencher
2011 年 12 月 9 日
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?
回答 (1 件)
Titus Edelhofer
2011 年 12 月 9 日
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
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!