# [Rd] lazy evaluation and DUP=F

Thu, 22 Mar 2001 11:23:28 -0500

```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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```