[Rd] .C-calls
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
13 Mar 2001 22:32:17 +0100
Martin Schlather <Martin.Schlather@uni-bayreuth.de> writes:
> ## the usual way of getting the Cholesky decomposition
> c0 <- chol(cov.matrix)
>
> ## direct call of the Fortran routine; the code is
> ## taken from the R-code of `chol'
> dummy1 <- .Fortran("chol", cov.matrix, lc, lc,
> v = matrix(0, nr = lc, nc = lc), info = integer(1),
> DUP = FALSE, PACKAGE = "base")
> c1 <- dummy1$v
>
> ## The third way.
> ## The code seems working very well... but?
> dummy2 <- double(lc * lc)
> .Fortran("chol", cov.matrix, lc, lc,
> dummy2, info = integer(1),
> DUP = FALSE, PACKAGE = "base")
> c2 <- matrix(dummy2, lc, lc)
>
> sum(abs(c0-c2)) # == 0
Well... As far as I can see, method 3 should work as long as DUP=FALSE
is used and break if DUP=TRUE. Some might prefer to consider the DUP
argument as an optimization hint and not something that should allow a
completely different calling sequence, but apart from that I cannot
see anything wrong with it.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._