Friends I'm not seeing why the following occurs:> T1 <- (A1 - A2) %*% D > T2 <- (A1 %*% D) - (A2 %*% D) > identical(T1, T2)[1] FALSE Harold> dput(A1)new("dsCMatrix" , i = c(0L, 1L, 2L, 3L, 0L, 1L, 4L, 2L, 3L, 5L) , p = c(0L, 1L, 2L, 3L, 4L, 7L, 10L) , Dim = c(6L, 6L) , Dimnames = list(NULL, NULL) , x = c(5, 5, 5, 5, 5, 5, 10, 5, 5, 10) , uplo = "U" , factors = list() )> dput(A2)new("dgeMatrix" , x = c(1.41313955042629, 1.23647532592053, 1.36413787785255, 0.986247245800629, 2.64961487634682, 2.35038512365318, 1.23647532592053, 1.55872699943971, 0.579347997632991, 1.62544967700677, 2.79520232536024, 2.20479767463976, 1.36413787785255, 0.579347997632991, 2.75106274522123, 0.305451379293231, 1.94348587548554, 3.05651412451446, 0.986247245800629, 1.62544967700677, 0.305451379293232, 2.08285169789937, 2.6116969228074, 2.3883030771926, 2.64961487634682, 2.79520232536024, 1.94348587548554, 2.6116969228074, 5.44481720170706, 4.55518279829294, 2.35038512365318, 2.20479767463976, 3.05651412451446, 2.3883030771926, 4.55518279829294, 5.44481720170706 ) , Dim = c(6L, 6L) , Dimnames = list(NULL, NULL) , factors = list() )> dput(D)new("ddiMatrix" , diag = "N" , Dim = c(6L, 6L) , Dimnames = list(NULL, NULL) , x = c(5, 5, 5, 5, 10, 10) ) [[alternative HTML version deleted]]
Meant to also add library(Matrix) for reproducing From: Doran, Harold Sent: Tuesday, August 14, 2012 1:26 PM To: r-help@r-project.org Subject: Communative Matrix Multiplcation Friends I'm not seeing why the following occurs:> T1 <- (A1 - A2) %*% D > T2 <- (A1 %*% D) - (A2 %*% D) > identical(T1, T2)[1] FALSE Harold> dput(A1)new("dsCMatrix" , i = c(0L, 1L, 2L, 3L, 0L, 1L, 4L, 2L, 3L, 5L) , p = c(0L, 1L, 2L, 3L, 4L, 7L, 10L) , Dim = c(6L, 6L) , Dimnames = list(NULL, NULL) , x = c(5, 5, 5, 5, 5, 5, 10, 5, 5, 10) , uplo = "U" , factors = list() )> dput(A2)new("dgeMatrix" , x = c(1.41313955042629, 1.23647532592053, 1.36413787785255, 0.986247245800629, 2.64961487634682, 2.35038512365318, 1.23647532592053, 1.55872699943971, 0.579347997632991, 1.62544967700677, 2.79520232536024, 2.20479767463976, 1.36413787785255, 0.579347997632991, 2.75106274522123, 0.305451379293231, 1.94348587548554, 3.05651412451446, 0.986247245800629, 1.62544967700677, 0.305451379293232, 2.08285169789937, 2.6116969228074, 2.3883030771926, 2.64961487634682, 2.79520232536024, 1.94348587548554, 2.6116969228074, 5.44481720170706, 4.55518279829294, 2.35038512365318, 2.20479767463976, 3.05651412451446, 2.3883030771926, 4.55518279829294, 5.44481720170706 ) , Dim = c(6L, 6L) , Dimnames = list(NULL, NULL) , factors = list() )> dput(D)new("ddiMatrix" , diag = "N" , Dim = c(6L, 6L) , Dimnames = list(NULL, NULL) , x = c(5, 5, 5, 5, 10, 10) ) [[alternative HTML version deleted]]
I just updated my R and this no longer occurs. But, below is the sessionInfo() showing details of when this doesn't occur, which I should have posted in the OP> sessionInfo()R version 2.12.2 (2011-02-25) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lme4_0.999375-38 Matrix_0.999375-46 lattice_0.19-13 loaded via a namespace (and not attached): [1] grid_2.12.2 nlme_3.1-98 stats4_2.12.2 tools_2.12.2> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On > Behalf Of Doran, Harold > Sent: Tuesday, August 14, 2012 1:26 PM > To: r-help at r-project.org > Subject: [R] Communative Matrix Multiplcation > > Friends > > I'm not seeing why the following occurs: > > > T1 <- (A1 - A2) %*% D > > T2 <- (A1 %*% D) - (A2 %*% D) > > identical(T1, T2) > [1] FALSE > > Harold > > > dput(A1) > new("dsCMatrix" > , i = c(0L, 1L, 2L, 3L, 0L, 1L, 4L, 2L, 3L, 5L) > , p = c(0L, 1L, 2L, 3L, 4L, 7L, 10L) > , Dim = c(6L, 6L) > , Dimnames = list(NULL, NULL) > , x = c(5, 5, 5, 5, 5, 5, 10, 5, 5, 10) > , uplo = "U" > , factors = list() > ) > > dput(A2) > new("dgeMatrix" > , x = c(1.41313955042629, 1.23647532592053, 1.36413787785255, > 0.986247245800629, 2.64961487634682, 2.35038512365318, 1.23647532592053, > 1.55872699943971, 0.579347997632991, 1.62544967700677, 2.79520232536024, > 2.20479767463976, 1.36413787785255, 0.579347997632991, 2.75106274522123, > 0.305451379293231, 1.94348587548554, 3.05651412451446, 0.986247245800629, > 1.62544967700677, 0.305451379293232, 2.08285169789937, 2.6116969228074, > 2.3883030771926, 2.64961487634682, 2.79520232536024, 1.94348587548554, > 2.6116969228074, 5.44481720170706, 4.55518279829294, 2.35038512365318, > 2.20479767463976, 3.05651412451446, 2.3883030771926, 4.55518279829294, > 5.44481720170706 > ) > , Dim = c(6L, 6L) > , Dimnames = list(NULL, NULL) > , factors = list() > ) > > dput(D) > new("ddiMatrix" > , diag = "N" > , Dim = c(6L, 6L) > , Dimnames = list(NULL, NULL) > , x = c(5, 5, 5, 5, 10, 10) > ) > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.