Skip to content
Back to formatted view

Raw Message

Message-ID: <1233935820.3122.68.camel@desktop.localhost>
Date: 2009-02-06T15:57:00Z
From: Gavin Simpson
Subject: Matrix Multiplication
In-Reply-To: <689267.5402.qm@web59514.mail.ac4.yahoo.com>

On Fri, 2009-02-06 at 04:57 -0800, Maithili Shiva wrote:
> Hi R helpers,
> 
> 
> 
> I have two matrices A and B of the order (4 * 5) and (5 * 3)
> respectively. How to multiply these two matrices to obtain resultant
> matrix of the order (4 * 3). 

?`%*%`

E.g.:

> A <- matrix(runif(4*5), nrow = 4)
> B <- matrix(rnorm(5*3), nrow = 5)
> A %*% B
            [,1]      [,2]      [,3]
[1,]  0.11087765 0.1172641 -1.965684
[2,]  0.08811864 0.6628032 -2.704704
[3,] -0.99875302 1.2822072 -1.388777
[4,] -1.01109686 1.5752980 -1.560827

> 
> Thanks in advance
> 
> With regards
> 
> Maithili

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090206/5c016def/attachment-0002.bin>