{"action":"closed","issue":{"url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/28","labels_url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/28/comments","events_url":"https://api.github.com/repos/HenrikBengtsson/matrixStats/issues/28/events","html_url":"https://github.com/HenrikBengtsson/matrixStats/issues/28","id":76968715,"number":28,"title":"The function rowCumprods seems to have a bug.","user":{"login":"Dongcan-Jiang","id":10103762,"avatar_url":"https://avatars.githubusercontent.com/u/10103762?v=3","gravatar_id":"","url":"https://api.github.com/users/Dongcan-Jiang","html_url":"https://github.com/Dongcan-Jiang","followers_url":"https://api.github.com/users/Dongcan-Jiang/followers","following_url":"https://api.github.com/users/Dongcan-Jiang/following{/other_user}","gists_url":"https://api.github.com/users/Dongcan-Jiang/gists{/gist_id}","starred_url":"https://api.github.com/users/Dongcan-Jiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dongcan-Jiang/subscriptions","organizations_url":"https://api.github.com/users/Dongcan-Jiang/orgs","repos_url":"https://api.github.com/users/Dongcan-Jiang/repos","events_url":"https://api.github.com/users/Dongcan-Jiang/events{/privacy}","received_events_url":"https://api.github.com/users/Dongcan-Jiang/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-16T07:15:29Z","updated_at":"2015-05-16T19:27:44Z","closed_at":"2015-05-16T19:27:44Z","body":"```\r\n//Example\r\n> x <- matrix(NA, nrow=3, ncol=2)\r\n> x[1,2] <- 0\r\n> x[2,2] <- 1\r\n> x[3,1] <- 0\r\n> storage.mode(x) <- \"integer\"\r\n> r0 <- rowCumprods_R(x)\r\n> print(r0)\r\n    [,1] [,2]\r\n[1,]   NA   NA\r\n[2,]   NA   NA\r\n[3,]    0   NA\r\n> r1 <- rowCumprods(x)\r\nWarning message:\r\nIn rowCumprods(x) :\r\n Integer overflow. Detected one or more elements whose absolute values were out of the range [-2147483647,2147483647] that can be used to for integers. Such values are set to NA_integer_.\r\n> print(r1)\r\n    [,1] [,2]\r\n[1,]   NA    0\r\n[2,]   NA   NA\r\n[3,]    0    0\r\n> r2 <- t(colCumprods(t(x)))\r\nWarning message:\r\nIn colCumprods(t(x)) :\r\n Integer overflow. Detected one or more elements whose absolute values were out of the range [-2147483647,2147483647] that can be used to for integers. Such values are set to NA_integer_.\r\n> print(r2)\r\n    [,1] [,2]\r\n[1,]   NA   NA\r\n[2,]   NA   NA\r\n[3,]    0    0\r\n```\r\n\r\nAbove cases show us 2 problems.\r\n\r\n1. the result r1 and r2 are wrong, as they are not the same as r0.\r\n1. warning messages are wrong, as NAs are not induced by integer overflow.\r\n\r\nThe reason is that the function rowCumprods doesn't deal with NA correctly in [rowComprods_TYPE-template.h:L59-L61](https://github.com/HenrikBengtsson/matrixStats/blob/master/src/rowCumprods_TYPE-template.h#L59-L61)."}}