PROGRAM MATVEC * * Multiplies an (mxn) matrix A by an (nx1) vector X * INTEGER LDA PARAMETER(LDA = 30) REAL A, X, Y INTEGER N, I, J DIMENSION A(LDA,LDA), B(LDA), C(LDA) OPEN(UNIT=1,FILE='input.dat',STATUS='UNKNOWN') READ(1,*) N DO 10 I = 1,N READ(1,*) (A(I,J), J = 1,N) C(I) = 0. 10 CONTINUE READ(1,*) (B(I), I = 1,N) CLOSE(1) CALL MTRVEC(LDA,N,A,B,C) OPEN(UNIT=2,FILE='output.dat',STATUS='UNKNOWN') WRITE(2,*) 'To diavusma eivai:' DO 20 I = 1,N WRITE(2,*) C(I) 20 CONTINUE CLOSE(2) STOP END SUBROUTINE MTRVEC(LDA,NDIM,A,X,Y) REAL A(LDA,*), X(*), Y(*), S INTEGER NDIM, I, J DO 10 I = 1,NDIM Y(I) = 0. 10 CONTINUE C C Matrix-vector multiplication using SAXPY over the C columns of A with length n. C DO 20 J = 1,NDIM CALL SAXPY(NDIM,X(J),A(1,J),Y) 20 CONTINUE C RETURN END SUBROUTINE SAXPY(N,A,X,Y) INTEGER N, I REAL A, X(*), Y(*) DO 10 I = 1,N Y(I) = A * X(I) + Y(I) 10 CONTINUE RETURN END