From gb at stat.umu.se  Wed Aug 12 16:59:52 2009
From: gb at stat.umu.se (=?ISO-8859-1?Q?G=F6ran_Brostr=F6m?=)
Date: Wed, 12 Aug 2009 16:59:52 +0200
Subject: [Rd] Problem with function in fortran 95
In-Reply-To: <795354.83301.qm@web59705.mail.ac4.yahoo.com>
References: <795354.83301.qm@web59705.mail.ac4.yahoo.com>
Message-ID: <4A82D8E8.8020908@stat.umu.se>

Fabio Mathias Corr?a skrev:
> 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

Is REAL in Fortran 95 the same as "double precision" in Fortran 77? It 
should be for this to work.

G?ran

>         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
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Problem with function in fortran 95
=?ISO-8859-1?Q?G=F6ran_Brostr=F6m?=