With this example set.seed(123) A <- matrix(runif(40), nrow = 8) y <- 1:nrow(A) A.laqr <- qr(A, LAPACK=TRUE) both qr.qy(A.laqr,y) and qr.qty(A.laqr,y) give the respective error messages Error in qr.qy(A.laqr, y) : 'b' must be a numeric matrix Error in qr.qty(A.laqr, y) : 'b' must be a numeric matrix However when Lapack is not used as in A.liqr <- qr(A, LAPACK=FALSE) qr.qy(A.liqr,y) and qr.qty(A.liqr,y) don't issue error messages. Looking at the source of qr.qy and qr.qty in https://svn.r-project.org/R/trunk/src/library/base/R/qr.R I see that in the case of Lapack the storage.mode of y is not set to "double" (in contrast to when Linpack QR has been used). I assume that the error issued when LAPACK=TRUE is not intended. Berend Suggested code change in qr.qy Replace if(!is.null(a) && is.logical(a) && a) return(.Call("qr_qy_real", qr, as.matrix(y), 0, PACKAGE = "base")) with if(!is.null(a) && is.logical(a) && a) { storage.mode(y) <- "double" return(.Call("qr_qy_real", qr, as.matrix(y), 0, PACKAGE = "base")) } and a similar change in qr.qty
qr.qy and qr.qty give an error message when y is integer and LAPACK=TRUE
3 messages · Berend Hasselman, Martin Maechler
Berend Hasselman <bhh at xs4all.nl>
on Mon, 3 Dec 2012 15:25:21 +0100 writes:
> With this example
> set.seed(123) A <- matrix(runif(40), nrow = 8) y <-
> 1:nrow(A)
> A.laqr <- qr(A, LAPACK=TRUE)
> both qr.qy(A.laqr,y) and qr.qty(A.laqr,y) give the
> respective error messages
> Error in qr.qy(A.laqr, y) : 'b' must be a numeric matrix
> Error in qr.qty(A.laqr, y) : 'b' must be a numeric matrix
> However when Lapack is not used as in
> A.liqr <- qr(A, LAPACK=FALSE)
> qr.qy(A.liqr,y) and qr.qty(A.liqr,y) don't issue error
> messages.
You are right... if you look at R 2.15.2 (or even it's patched
version).
> Looking at the source of qr.qy and qr.qty in
> https://svn.r-project.org/R/trunk/src/library/base/R/qr.R
Hmm, no: If you really looked at that code (during the last several weeks),
you would have noted that the code has *changed* from what you
give below...
and the current R development version uses
.Internal(.) instead of .Call() and the C code behind the
.Internal() nicely deals with integer 'y' as well.
In short, this is already fixed in R, since ~ September,
but it won't probably be fixed in "R 2.15.2 patched" ...
Thank you for the report, anyway!
Martin
> I see that in the case of Lapack the storage.mode of y is
> not set to "double" (in contrast to when Linpack QR has
> been used).
> I assume that the error issued when LAPACK=TRUE is not
> intended.
> Berend
> Suggested code change in qr.qy Replace
> if(!is.null(a) && is.logical(a) && a)
> return(.Call("qr_qy_real", qr, as.matrix(y), 0, PACKAGE =
> "base"))
> with
> if(!is.null(a) && is.logical(a) && a) {
> storage.mode(y) <- "double" return(.Call("qr_qy_real", qr,
> as.matrix(y), 0, PACKAGE = "base")) }
> and a similar change in qr.qty
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
On 03-12-2012, at 16:17, Martin Maechler wrote:
Berend Hasselman <bhh at xs4all.nl> on Mon, 3 Dec 2012 15:25:21 +0100 writes:
With this example
set.seed(123) A <- matrix(runif(40), nrow = 8) y <- 1:nrow(A)
A.laqr <- qr(A, LAPACK=TRUE)
both qr.qy(A.laqr,y) and qr.qty(A.laqr,y) give the respective error messages
Error in qr.qy(A.laqr, y) : 'b' must be a numeric matrix Error in qr.qty(A.laqr, y) : 'b' must be a numeric matrix
However when Lapack is not used as in
A.liqr <- qr(A, LAPACK=FALSE)
qr.qy(A.liqr,y) and qr.qty(A.liqr,y) don't issue error messages.
You are right... if you look at R 2.15.2 (or even it's patched version).
Which I did. And copied from R 2.15.2.
Looking at the source of qr.qy and qr.qty in https://svn.r-project.org/R/trunk/src/library/base/R/qr.R
Hmm, no: If you really looked at that code (during the last several weeks), you would have noted that the code has *changed* from what you give below...
and the current R development version uses .Internal(.) instead of .Call() and the C code behind the .Internal() nicely deals with integer 'y' as well.
I did look at that code but did not drill down. Stupid.
In short, this is already fixed in R, since ~ September, but it won't probably be fixed in "R 2.15.2 patched" ...
Apologies for the noise. Berend