計算の高速化は可能か
3 views (last 30 days)
Show older comments
5変数関数の計算を行っており、それぞれの変数が5パターンの値を持つとき、全ての組み合わは5^5通りできるかと思います。
現在for分を使用して計算を実施しているのですが、2時間程度時間がかかるため、高速計算を実施する手法が無いか探しています。
for分のコードは以下の通りです。
for i=1:5
for j=1:5
for k=1:5
for l=1:5
for m=1:5
OUTPUT(i,j,k,l,m)=subs(f,[a b c d e],[A(i,1) B(j,1) C(k,1) D(l,1) E(m,1)]);
end
end
end
end
end
2 Comments
Hiroyuki Hishida
on 12 Jun 2023
Edited: Hiroyuki Hishida
on 12 Jun 2023
いくつかあります。
まずは、単純に並列化です。 https://jp.mathworks.com/help/parallel-computing/parallel-for-loops-parfor.html 似た方法に、GPUの利用もあります。 https://jp.mathworks.com/help/parallel-computing/gpuarray.html
次はベクトル化です。 https://jp.mathworks.com/help/matlab/matlab_prog/vectorization.html
高速化に取り組まれる前に、どこで計算が遅いかを把握するのも良いと思います。
https://jp.mathworks.com/help/matlab/matlab_prog/measure-performance-of-your-program.html
いかがでしょうか。
Answers (0)
See Also
Categories
Find more on インストールとライセンスの紹介 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!