[Rd] Problem with function in fortran 95
Fabio Mathias Corrêa
fabio.ufla at yahoo.com.br
Wed Aug 12 13:32:58 CEST 2009
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
More information about the R-devel
mailing list