hi all!
i'm trying to write a matrix multiplication code - it's posted below:
CODE
program matrixProduct
implicit none
real, parameter :: N = 3
real, dimension( N , N ) :: A
real, dimension( N ) :: b,c
A = (/1,2,3,4,5,6,7,8,9/)
b = (/11,12,13/)
c = matrixVectorProduct(A,b)
print *, 'A*b = ', c
contains
function matrixVectorProduct(A,b) result (c)
implicit none
real, dimension(:,:), intent(in) :: A
real, dimension(:), intent(in) :: b
real, dimension( size(b) ) :: c
integer :: N , i
N = size(b)
i = 1
do i = 1, N
c = 0.0
c = c + b(i) * A(:,i)
print *,c
end do
end function matrixVectorProduct
end program matrixProduct
the problem is: when i try to run it, i get an error msg like this:
___________________________________________________
Compiling Fortran...
C:\Documents and Settings\mlicer\My Documents\matrixProduct.f90
C:\Documents and Settings\mlicer\My Documents\matrixProduct.f90(13) : Error: The shapes of the array expressions do not conform. [A]
A = (/1,2,3,4,5,6,7,8,9/)
^
Error executing df.exe.
matrixProduct.obj - 1 error(s), 0 warning(s)
___________________________________________________
so obviously i am doing something wrong with the matrix A and vector b. any ideas??