Construct product of matrices without for loop
이전 댓글 표시
Hi, everyone:
Suppose A is a 2 by 2 by N matrix, is it possible to construct a matrix B, such that:
B=[Prod(A)_1^{N-n}, Prod(A)_2^{N-n}, ... , Prod(A)_{N-n}^{N-n};
Prod(A)_1^{N-n+1}, Prod(A)_2^{N-n+1}, ... , Prod(A)_{N-n}^{N-n+1};
. . . .
. . . .
Prod(A)_1^N, Prod(A)_2^N, ... , Prod(A)_{N-n}^N]
where Prod(A)_m^n = A(:,:,m)*A(:,:,m+1)*A(:,:,m+2)* ... * A(:,:,n); (1 << n << N)
without any loop?? (maybe use arrayfun? cellfun?)
because for loop is too slow for me.
Thanks
댓글 수: 2
When you claim, that the FOR loop is too slow, do not hope, that CELLFUN or ARRAY is faster. But use loops internally also, but have the additional overhead for calling Matlab from the Mex level.
When your code is too slow for your needs, you could post the relevant part of it and ask, if somebody knows improvements. For testing the ideas before answering, provided test data are very useful.
"n" appears twice with different meaning in your example. How large is it in the definition of B and what are typical sizes of N?
Walter Roberson
2013년 8월 12일
This appears to duplicate part of http://www.mathworks.co.uk/matlabcentral/answers/84498-construct-product-of-matrices-without-for-loop
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!