The most efficient way to calculate multiplication and summation of two large matrices
조회 수: 1 (최근 30일)
이전 댓글 표시
Support I have two matrices and , I would like to calculate following:
where matrix , and represent each columne of two matrices
I was wondering, what is the most efficient way to calculate matrix C? Many thanks!
댓글 수: 0
채택된 답변
Bruno Luong
2023년 3월 11일
편집: Bruno Luong
2023년 3월 11일
It is just a scaling of matrix multiplication, if you haven't recorgnize it
A=rand(300,1000);
B=rand(300,1000);
tic
C1=(A*B')/size(A,2);
toc
% or
tic
C2 = sum(pagemtimes(reshape(A,size(A,1),1,[]),reshape(B,1,size(B,1),[])),3)/size(A,2);
toc
% or
tic
C3 = sum(reshape(A,size(A,1),1,[]).*reshape(B,1,size(B,1),[]),3)/size(A,2);
toc
norm(C1-C2,'fro')
norm(C1-C3,'fro')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!