gpuR icon indicating copy to clipboard operation
gpuR copied to clipboard

Misunderstanding if trying to add matrix with a vector

Open szhang0629 opened this issue 7 years ago • 2 comments

library(gpuR) A <- vclMatrix(rnorm(4), ncol = 2, nrow = 2) B <- vclVector(rnorm(2)) as.matrix(A+B) as.matrix(A)

We get same value.

as.matrix(A+B) [,1] [,2] [1,] 1.3868894 -0.3154218 [2,] -0.9026289 -1.1150675 as.matrix(A) [,1] [,2] [1,] 1.3868894 -0.3154218 [2,] -0.9026289 -1.1150675

I think it may cause hidden trouble if it doesn't behave like normal matrix without an error or warning.

szhang0629 avatar Jun 07 '18 20:06 szhang0629

Thanks for the report, I can confirm this is a bug. I will address it as quickly as I am able.

cdeterman avatar Jun 08 '18 18:06 cdeterman

@shan0629 this is actually because I don't have 'recycling' currently implemented when the size of the matrix and vector do not match. That is part of issue #62. If the sizes of the two objects match, then the functions continue to behave correctly.

cdeterman avatar Jun 12 '18 16:06 cdeterman