Calculate lsqr of two arrays on GPU

1 回表示 (過去 30 日間)
Mantas Vaitonis
Mantas Vaitonis 2018 年 7 月 19 日
回答済み: Joss Knight 2018 年 7 月 21 日
Hello,
Is there way to calculate lsqr of two arrays, I mean for each columns of arrays respectively. If a (NxM) and b(NxM) are gpuArrays then:
c=lsqr(a(:,1),b(:,1));
This works with no problem. Is there a way to do it on whole arrays? I know that it could be done with for loops, but it becomes bottleneck in my code.

採用された回答

Joss Knight
Joss Knight 2018 年 7 月 21 日
The least squares solution to a system of linear equations of one variable is pretty simple to work out, so you shouldn't really need any fancy linear algebra. I haven't actually checked this in MATLAB, but by my reckoning all you need is
c = sum(a .* b) ./ sum(a .* a);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by