From fabio.ufla at yahoo.com.br  Wed Aug 12 13:32:58 2009
From: fabio.ufla at yahoo.com.br (=?iso-8859-1?Q?Fabio_Mathias_Corr=EAa?=)
Date: Wed, 12 Aug 2009 04:32:58 -0700 (PDT)
Subject: [Rd] Problem with function in fortran 95
Message-ID: <795354.83301.qm@web59705.mail.ac4.yahoo.com>

I am writing a function in fortran 95, but the intrinsic function MATMUL is not working properly. Here's an example.

	SUBROUTINE mymult(x,y,res,m,n)
        IMPLICIT NONE
        INTEGER :: m,n
	REAL :: x, y, res
        DIMENSION :: x(m,n), y(n,m), res(m,m)
        res = MATMUL(x,y)
        END SUBROUTINE mymult

R CMD SHLIB mat.f95

In R:

dyn.load("mat.so")
x   <- matrix(1:20,5)
l   <- nrow(x)
c   <- ncol(x)
y   <- matrix(20:1,c)
res <- matrix(0,l,l)
dim(x)
dim(y)
dim(res)
l
c
.Fortran("mymult", x,y,res,l,c)

[[1]]
     [,1] [,2] [,3] [,4]
[1,]    1    6   11   16
[2,]    2    7   12   17
[3,]    3    8   13   18
[4,]    4    9   14   19
[5,]    5   10   15   20

[[2]]
     [,1] [,2] [,3] [,4] [,5]
[1,]   20   16   12    8    4
[2,]   19   15   11    7    3
[3,]   18   14   10    6    2
[4,]   17   13    9    5    1

[[3]]
     [,1] [,2] [,3] [,4] [,5]
[1,]    0    0    0    0    0
[2,]    0    0    0    0    0
[3,]    0    0    0    0    0
[4,]    0    0    0    0    0
[5,]    0    0    0    0    0

[[4]]
[1] 5

[[5]]
[1] 4


Linux Ubuntu 8.04 and use compiler gfortran 4.2.
The problem is the compiler?

Thanks!

? ???????????? F?bio Mathias Corr?a
Estat?stica e Experimenta??o Agropecu?ria/UFLA
                      Brazil


      ____________________________________________________________________________________
Veja quais s?o os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com



[Rd] Problem with function in fortran 95
=?iso-8859-1?Q?Fabio_Mathias_Corr=EAa?=