Matrix multiplication: Difference between revisions

Content added Content deleted
m (→‎{{header|C}}: Syntax hilighting for C)
Line 365: Line 365:
=={{header|Fortran}}==
=={{header|Fortran}}==
In ISO Fortran 90 or later, use the SIZE and MATMUL intrinsic functions:
In ISO Fortran 90 or later, use the SIZE and MATMUL intrinsic functions:
REAL, DIMENSION(N,M) :: A = RESHAPE( (/ (I, I=1, N*M) /), (/ N, M /) )
real, dimension(n,m) :: a = reshape( (/ (i, i=1, n*m) /), (/ n, m /) )
REAL, DIMENSION(M,K) :: B = RESHAPE( (/ (I, I=1, M*K) /), (/ M, K /) )
real, dimension(m,k) :: b = reshape( (/ (i, i=1, m*k) /), (/ m, k /) )
REAL, DIMENSION(SIZE(A,1), SIZE(B,2)) :: C ! C is an array whose first dimension (row) size is the same
real, dimension(size(a,1), size(b,2)) :: c ! C is an array whose first dimension (row) size is the same
! as A's first dimension size, and whose second dimension
! as A's first dimension size, and whose second dimension
! (column) size is the same as B's second dimension size.
! (column) size is the same as B's second dimension size.
C = MATMUL( A, B )
c = matmul( a, b )


=={{header|Haskell}}==
=={{header|Haskell}}==