SCM

[#6719] Propagation of NAs sometimes differing from base R

Date:
2021-04-13 04:19
Priority:
3
State:
Open
Submitted by:
David Cortes (david.cortes)
Assigned to:
Martin Maechler (mmaechler)
Product:
None
Operating System:
All
Component:
None
Summary:
Propagation of NAs sometimes differing from base R

Detailed description
Not sure if this is worth fixing, but there are some mismatches in the propagation of NAs (particularly NA*0) between base R and Matrix when multiplying a "dgCMatrix" by a numeric vector with number of elements matching to the number of rows of the matrix.

I'm attaching serialized files as I haven't been able to pinpoint what characteristics does the matrix need to have in order to trigger this bug.

library(Matrix)
X <- readRDS("X.rds")
v <- readRDS("v.rds")
res_Matrix <- (X * v)[1,1:5]
res_R <- (as.matrix(X) * v)[1,1:5]

Matrix:
[1] 0 0 0 0 0

Base R:
[1] NA NA NA NA NA

Comments:

Message  ↓
Date: 2022-06-16 15:38
Sender: Martin Maechler

Moved from Bugs to Feature Requests

Date: 2021-04-17 08:21
Sender: Martin Maechler

Thank you David.

This is actually quite on purpose: A somewhat conscious decision to keep sparse matrices sparse.

It needs to be documented however, *and* if users / collaborators are interested I'd open a "wishlist" item to ask for a global option (still turned off by default) that would make Matrix pkg behavior less sparse but compatible with base R, even in this boundary case.

Attached Files:

Attachments:
Size Name Date By Download
1 KiBX.rds2021-04-13 04:19david.cortesX.rds
504 bytesv.rds2021-04-13 04:19david.cortesv.rds

Changes

Field Old Value Date By
typeBugs2022-06-16 15:38mmaechler
Operating SystemNone2021-04-17 08:21mmaechler
SeverityNone2021-04-17 08:21mmaechler
assigned_tonone2021-04-17 08:21mmaechler
File Added5205: v.rds2021-04-13 04:19david.cortes
File Added5204: X.rds2021-04-13 04:19david.cortes
Thanks to:
Vienna University of Economics and Business Powered By FusionForge