Silverfrost Forums

Welcome to our forums

Matrix/vector multiplication

6 Mar 2015 11:11 #15819

I am new to fortran 95. I need help on how to multiply matrix and vectors. I have consulted books and online tutorial but to no avail. Also, is silverfrost FTN95 code different from that of other publishers?

7 Mar 2015 10:28 #15837

There are intrinsic functions to help with this. Dot_Product will multiply 2 vectors. MATMUL will multiply 2 matrices of rank 2.

You need to understand how to declare the arrays and then use intrinsic functions. As you say you are new to Fortran 95, I am not sure to what detail you require further help. I suggest you google Fortran tutorials and see if you can follow the examples they have.

John

8 Mar 2015 3:34 #15841

It is difficult to know what is being asked here. Help with the maths or help with code?

MATMUL can be used in 3 ways (using numeric data).

C = MATMUL(A,B)

(1) If A has shape (M,K) and B has shape (K,N), C will have shape (M,N)
(2) If A has shape (K) and B has shape (K,M), C will have shape (M) (3) If A has shape (N, K) and B has shape (K), C will have shape (N)

(1) C(i,j) has the value SUM(A(i,:)*B(:,j) (2) C(j) has the value SUM(A(:)*B(:,j)) (3) C(i) has the value SUM(A(i,:)*B(:))

Please login to reply.