MCA World :: Computer Application ::
Questions :  Answers : Solutions of TMA & Project Assignment  of  MCA courses of IGNOU, NIT & Other Universities.

::: Matrix Multiplication



Home • Introduction to Software • Data Structures • System Engineering • Database Management System • Discrete Mathematics • Numerical & Statistical Computing • Software Engineering • Operation Research • Accounting & Finance • Computer Architecture • Operating Systems • Intelligent Systems • Relational Database • Obejct Oiented Systems

Matrix Multiplication

Up • Matrix Multiplication • Factorial • Max Min • Pie chart • Baye's Theorem - Probability • Binomial Theory of Probability • Correlation Calculation

Main Chapters

Home
Introduction to Software
Data Structures
System Engineering
Database Management System
Discrete Mathematics
Numerical & Statistical Computing
Software Engineering
Operation Research
Accounting & Finance
Computer Architecture
Operating Systems
Intelligent Systems
Relational Database
Obejct Oiented Systems

Matrix Multiplication

FORTRAN Program for Matrix Multiplication

Q : A Fortran program that reads four natural numbers m,n,p,q and further reads entries of two matrices A and B of real numbers, respectively of size m x n and p x q. Further, the program checks whether the matrix product A x B is defined. If the product is defined then the program computes the product matrix, else prints a suitable message.

Ans :

Let us assume that Matrix C is the Product of   Matrices A & B.

so          

 (C)mxq =(A)mxn x (B)pxq

  The product of the matrix is defined only when n = p, that is the number of columns of  First Matrix A is equal to the number of rows of second Matrix B. This condition is used in the program to check whether the matrix is defined or not.

            Here is the listing of full program : -

C*****FORTRAN PROGRAM FOR MULTIPLICATION OF TWO MATRIX

DIMENSION A(100,100), B(100,100), C(100,100)

INTEGER P,Q

 

C*****READ THE SIZE OF MATRIX A(MXN)

C*****MAXIMUM SIZE IS ASSUMED TO 100X100

 

 1    WRITE( *,*) 'ENTER THE SIZE(M<100,N<100) OF MATRIX A'

  READ ( *, 2) M, N

2    FORMAT (2I3)

 

     WRITE( *,*) 'ENTER THE SIZE(P<100,Q<100) OF MATRIX B'

  READ ( *, 2) P,Q

 

C*****CHECK WHETHER P=N IF NOT THEN PRODUCT IS NOT DEFINED.

 

 IF(N .EQ. P) GO TO 3

 WRITE( *,*) 'THE PRODUCT OF MATRICES A & NOT DEFINED'

 WRITE( *, *) 'RE-ENTER THE SIZES OF A & B AGAIN'

 GO TO 1

C*****INPUT STARTS FOR A :

3  WRITE ( *,* ) 'ENTER MATRIX A ROW-WISE'

 DO 4 I =1, M

    WRITE (*,*) 'ENTER ROW NO :', I

4              READ (*,5) (A(I,J),J=1,N)

5    FORMAT (F8.2)

C*****INPUT STARTS FOR B :  

    WRITE ( *,* ) 'ENTER MATRIX B ROW-WISE'

 DO 7 I =1, P

    WRITE (*,*) 'ENTER ROW NO :', I

7   READ (*,5) (A(I,J),J=1,Q)

C*****START THE MULTIPLICATION

 

DO 8 I =1,M

DO 8 K =1,Q

C(I,K) = 0.0

DO 9 J =1,N

  9  C(I,K) = C(I,K) + A(I,J)*B(J,K)

 

C*****PRINT THE PRODUCT MATRIX C IN TABULAR FORM

     DO 10  I=1,M

 10  WRITE (*,11) (C(I,J), J=1,Q)

 11  FORMAT ( F8.2 )

     STOP

     END

 

Links for Web Developers Web Publishers

 

Links from Google

 

 
 


Home • Introduction to Software • Data Structures • System Engineering • Database Management System • Discrete Mathematics • Numerical & Statistical Computing • Software Engineering • Operation Research • Accounting & Finance • Computer Architecture • Operating Systems • Intelligent Systems • Relational Database • Obejct Oiented Systems



This is complete MCA study materials containing question, solutions, answers, programming, scripts, TMA, Project assignment solutions for aspiring MCA or BCA student. This website may be useful for all in general and IGNOU student in particulars. Disclaimer : Execution and correctness of programs/answers may be established by the users himself and the mcaworld.net shall not held responsible for any damage/loss caused due to the use of code over this site.



Webmaster Bipin Bihari Pandey, An IT Expert of DotNet Technology, MCA from IGNOU
bipin9830@rediffmail.com or bipin9830@yahoo.com