Question

2. Suppose we want to multiply two N-by-N matrices, C-A B, by following the componentwise formula に1 (a) What are the operati

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Matlab code for matrix multiplication clear all close all Matrix of order N h-5; %1st matrix A-rand (N,N); fprintf1st matrix2nd Matrix is B= 0. 92047 0.85471 0. 96215 0.45747 0.22997 0.74021 0. 75424 0.029836 0.53637 0.028759 0.20939 0.22189 0.09184

%Matlab code for matrix multiplication
clear all
close all

%Matrix of order N
N=5;

%1st matrix
A=rand(N,N);

fprintf('1st matrix is A=\n')
disp(A)

%2nd matrix
B=rand(N,N);

fprintf('2nd Matrix is B=\n')
disp(B)

%Code for matrix multipliction
CNT=0;
for i=1:N
  
    for j=1:N
      
        sum=0;
      
        for k=1:N
            sum=sum+A(i,k)*B(k,j);
          
        end
      
        C(i,j)=sum;
    end
end

fprintf('The matrix C=A*B= \n')
disp(C)

fprintf('\n\tTotal number of operation count is %d\n',2*N*N*N);
fprintf('\tAmong which %d are sum operations and %d are multiplications.\n',N*N*N,N*N*N)
fprintf('\tFor multiplication operation order matters.\n')

%%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
2. Suppose we want to multiply two N-by-N matrices, C-A B, by following the componentwise formula に1 (a) What are the operation counts? (b) In floating-point arithmetic, for which of these operation...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT