I am having some difficulty understanding the implication of lazy evaluation
mixed
with DUP=F in a .Fortran call. In qr.qty from base DUP is not used as an
argument so
defaults to T. I am calling qr.qty with a very large array and would like to set
DUP=F in the .Fortran call so that qr.qty would be defined as copied below. Is
there
some risk that a variable used as the argument in the original calling
environment
would be modified, or is there some other reason that this should not be done?
Also, I still find it surprising that I get very slightly different results in
some
calculations depending on whether I have DUP=T or DUP=F in a call to some of my
own
fortran. I don't think that I am reusing the arguments in anyway that would
require
duplicating them, and if I were I would expect a much bigger difference in the
result? Can anyone think of an explanation?
Thanks,
Paul Gilbert
_____
qr.qty <- function (qr, y)
{
if (!is.qr(qr))
stop("argument is not a QR decomposition")
n <- as.integer(nrow(qr$qr))
p <- as.integer(ncol(qr$qr))
k <- as.integer(qr$rank)
ny <- as.integer(NCOL(y))
storage.mode(y) <- "double"
if (NROW(y) != n)
stop("qr and y must have the same number of rows")
qty <- if (is.matrix(y))
matrix(double(n * ny), n, ny)
else double(n)
.Fortran("dqrqty", as.double(qr$qr), n, k, as.double(qr$qraux),
y, ny, qty = qty, PACKAGE = "base", DUP=F)$qty
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 22 Mar 2001, Paul Gilbert wrote:> I am having some difficulty understanding the implication of lazy > evaluation mixed with DUP=F in a .Fortran call. In qr.qty from base > DUP is not used as an argument so defaults to T. I am calling qr.qty > with a very large array and would like to set DUP=F in the .Fortran > call so that qr.qty would be defined as copied below. Is there some > risk that a variable used as the argument in the original calling > environment would be modified, or is there some other reason that this > should not be done?I am not sure that DUP=FALSE can't change objects in the original calling environment (this is why help(.Fortran) says that there is a risk). It's not precisely lazy evaluation that causes the problem: if the lazy evaluation really worked under the hood the way it appears to work there would be no problem. The problem is that R actually calls by reference until an object is modified. It should be fairly easy to tell by experiment whether this can happen -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Seemingly Similar Threads
- se.contrast: matrix contrast.obj doesn't work as documented (PR#1613)
- se.contrast ....too hard??? .... Too easy????? .....too trivial???? ...... Too boring.....too????????
- qr.qy and qr.qty give an error message when y is integer and LAPACK=TRUE
- QR Decompositon and qr.qty
- How does .Fortran "dqrls" work?