Hi all. A question about performance of matrix multiplication. I have two relatively large matrices: A is 100x3072, all integers 0-255, not sparse B is 1016x3072, all integers 0-255, not sparse The command z<-B %*% t(A) works fine and takes roughly 0.2 seconds . If I add one row to B, the same command takes 2.4 seconds; at 1050 rows in B, the command is up to almost 4 seconds. Just trying to understand why the big slowdown is occurring, especially since the matrices I actually want to multiply have 1000 and 5000 rows, not 100 and 1017. Thanks, Ken (Macbook Pro running 10.11.6, 16Gb, R v 3.3.1)
R matrix multiplication slowdown
3 messages · Jeff Newmiller, ken eagle
You are asked by the Posting Guide to provide a reproducible example and to post in plain text (because HTML gets mangled). I would guess your problem has nothing to do with multiplication, but without the code there is no way to say for sure.
Sent from my phone. Please excuse my brevity. On January 26, 2017 2:21:07 PM PST, ken eagle <eaglek2011 at gmail.com> wrote: >Hi all. A question about performance of matrix multiplication. > > > >I have two relatively large matrices: > > > >A is 100x3072, all integers 0-255, not sparse > >B is 1016x3072, all integers 0-255, not sparse > > > >The command z<-B %*% t(A) works fine and takes roughly 0.2 seconds . >If I >add one row to B, the same command takes 2.4 seconds; at 1050 rows in >B, >the command is up to almost 4 seconds. Just trying to understand why >the >big slowdown is occurring, especially since the matrices I actually >want to >multiply have 1000 and 5000 rows, not 100 and 1017. > > > >Thanks, > >Ken > > > >(Macbook Pro running 10.11.6, 16Gb, R v 3.3.1) > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.
I've done more searching and found a problem with the data in one of the matrices that was corrupting the calculation. Data now fixed and problem is solved. Apologies if anyone wasted time on this. Ken On Fri, Jan 27, 2017 at 8:29 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
You are asked by the Posting Guide to provide a reproducible example and to post in plain text (because HTML gets mangled). I would guess your problem has nothing to do with multiplication, but without the code there is no way to say for sure. -- Sent from my phone. Please excuse my brevity. On January 26, 2017 2:21:07 PM PST, ken eagle <eaglek2011 at gmail.com> wrote:
Hi all. A question about performance of matrix multiplication.
I have two relatively large matrices:
A is 100x3072, all integers 0-255, not sparse
B is 1016x3072, all integers 0-255, not sparse
The command z<-B %*% t(A) works fine and takes roughly 0.2 seconds .
If I
add one row to B, the same command takes 2.4 seconds; at 1050 rows in
B,
the command is up to almost 4 seconds. Just trying to understand why
the
big slowdown is occurring, especially since the matrices I actually
want to
multiply have 1000 and 5000 rows, not 100 and 1017.
Thanks,
Ken
(Macbook Pro running 10.11.6, 16Gb, R v 3.3.1)
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.