[Rd] wrong matrix dimension in sparseQR

Serguei Sokol sokol at insa-toulouse.fr
Fri Jan 19 10:12:21 CET 2018


I have found explanation in the comments to original cs_qr() matlab function
http://users.encs.concordia.ca/~krzyzak/R%20Code-Communications%20in%20Statistics%20and%20Simulation%202014/Zubeh%F6r/SuiteSparse/CSparse3/MATLAB/CSparse/cs_qr.m

"If A is structurally rank deficient, additional empty
  rows may have been added to V and R."

To my mind, it could be useful to mention it in the manual of Matrix::qr
and/or sparseQR-class too. Because in case of augmented nrow
we cannot do anymore A[p+1,] as cited in example in ?"sparseQR-class".

My 2 cents.
Serguei.

Le 18/01/2018 à 16:13, Serguei Sokol a écrit :
> Hi,
>
> I came across a case when the dimensions of matrices returned by qr()
> operated on a sparse matrix does not coincide with the initial matrix.
If A is structurally rank deficient, additional empty
%   rows may have been added to V and R.
>
> Here is a spinet code that should produce an example (one of many that I could provide):
>
>  m=205
>  n=199
>  set.seed(7);
>  a=matrix(rnorm(m*n), m, n)
>  a[sample(seq(m*n), m*(n-4))]=0
>  a=as(a, "Matrix")
>  qa=qr(a);
>  stopifnot(nrow(qa at R) == m)
>  # On my box I have nrow(qa at R):=207 while should be 205 as m is)
>
> Note that for m=203 and n=197, the same code produce right (i.e. coinciding) dimensions.
>
> Have I missed something?
>
> Serguei.
>
> > R.version
> platform       x86_64-pc-linux-gnu
> arch           x86_64
> os             linux-gnu
> system         x86_64, linux-gnu
> status
> major          3
> minor          4.3
> year           2017
> month          11
> day            30
> svn rev        73796
> language       R
> version.string R version 3.4.3 (2017-11-30)
> nickname       Kite-Eating Tree
>
>

-- 
Serguei Sokol
Ingenieur de recherche INRA

Cellule mathématique
LISBP, INSA/INRA UMR 792, INSA/CNRS UMR 5504
135 Avenue de Rangueil
31077 Toulouse Cedex 04

tel: +33 5 6155 9849
email: sokol at insa-toulouse.fr
http://www.lisbp.fr



More information about the R-devel mailing list