Re: [Rd] wrong matrix dimension in sparseQR

2018-01-19 Thread Serguei Sokol

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@R) == m)
 # On my box I have nrow(qa@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: so...@insa-toulouse.fr
http://www.lisbp.fr

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] bug fix integer overflow in medpolish function

2018-01-19 Thread Ludger Goeminne
Dear R team 

I noticed a bug in the "medpolish" function in the "stats" package. 
When I run medpolish(x), with "x" the matrix in the attached .rda file, 
I get this rather cryptic error: 

"Error in if (converged) break : missing value where TRUE/FALSE needed 
In addition: Warning message: 
In sum(abs(z), na.rm = na.rm) : integer overflow - use sum(as.numeric(.))" 

I traced this down to the line: 

newsum <- sum(abs(z), na.rm = na.rm) 

I think this "overflow" could be easily fixed by changing this line to: 

newsum <- sum(as.numeric(abs(z)), na.rm = na.rm) 

With kind regards 

Ludger Goeminne 

¯ 
Ludger Goeminne - Ph.D. Student 

VIB-UGent Center for Medical Biotechnology 
Albert Baertsoenkaai 3 - 9000 Gent - Belgium 
Tel: +32 (0)9 264 9360 
mbc.vib-ugent.be 



matrix.rda
Description: GNU Zip compressed data
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] bug fix integer overflow in medpolish function

2018-01-19 Thread Duncan Murdoch

On 19/01/2018 9:33 AM, Ludger Goeminne wrote:

Dear R team

I noticed a bug in the "medpolish" function in the "stats" package.
When I run medpolish(x), with "x" the matrix in the attached .rda file,
I get this rather cryptic error:

"Error in if (converged) break : missing value where TRUE/FALSE needed
In addition: Warning message:
In sum(abs(z), na.rm = na.rm) : integer overflow - use sum(as.numeric(.))"

I traced this down to the line:

newsum <- sum(abs(z), na.rm = na.rm)

I think this "overflow" could be easily fixed by changing this line to:

newsum <- sum(as.numeric(abs(z)), na.rm = na.rm)


Alternatively, you could use medpolish(as.numeric(x)).

Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Buffer overflow in cairoBM.c line 402

2018-01-19 Thread Omri Schwarz
Hi, all.

Testing a change to that line to
strncpy(xd->filename, filename,PATH_MAX);
right now.

The bug itself I've yet to reproduce in anything that doesn't involve
my employer's proprietary code, but strcpy is strcpy, after all.

-- 
*Omri Schwarz*
Engineer
REsurety, Inc.

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Buffer overflow in cairoBM.c line 402

2018-01-19 Thread Tomas Kalibera
Thanks for reporting - there is no need to reproduce this, it is an 
obvious error.
I'll probably fix by throwing an error - like it is done in devX11.c 
when the file names are too long.


Tomas

On 01/19/2018 09:41 PM, Omri Schwarz wrote:

Hi, all.

Testing a change to that line to
 strncpy(xd->filename, filename,PATH_MAX);
right now.

The bug itself I've yet to reproduce in anything that doesn't involve
my employer's proprietary code, but strcpy is strcpy, after all.



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel