Re: [R] Matrix multiplication

2017-06-07 Thread Jeff Newmiller
Fine, except that you already seen to have a very compact solution if that really is what you are looking for. What am I missing? -- Sent from my phone. Please excuse my brevity. On June 7, 2017 9:16:48 PM PDT, Steven Yen wrote: >OK Thanks. Your response made me think. Here (the last line) is

Re: [R] Matrix multiplication

2017-06-07 Thread Steven Yen
OK Thanks. Your response made me think. Here (the last line) is what I need: set.seed(76543211) w<-1:10; w a<-matrix(rpois(20,2),nrow=10); a t(w*a)%*%a On 6/8/2017 12:09 PM, Jeff Newmiller wrote: > Is this a question? You seem to have three possible calculations, have > already implemented two o

Re: [R] Matrix multiplication

2017-06-07 Thread Jeff Newmiller
Is this a question? You seem to have three possible calculations, have already implemented two of them (?) and it is unclear (to me) what you think the right answer for any of them is supposed to be. -- Sent from my phone. Please excuse my brevity. On June 7, 2017 8:50:55 PM PDT, Steven Yen w

[R] Matrix multiplication

2017-06-07 Thread Steven Yen
I need to have all elements of a matrix multiplied by a weight before being post-multiplied by itself, as shown in the forst block of codes below. I can also multiply the matrix by the square root of the weight and then take the outer product. Actually, what I need is this. Denote each row of t

Re: [R] R matrix multiplication slowdown

2017-01-27 Thread ken eagle
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 wrote: > You are asked by the Posting Guide

Re: [R] R matrix multiplication slowdown

2017-01-27 Thread Jeff Newmiller
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.

[R] R matrix multiplication slowdown

2017-01-27 Thread ken eagle
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, t

Re: [R] Matrix Multiplication using R.

2013-08-15 Thread Steve Taylor
-project.org Subject: Re: [R] Matrix Multiplication using R. Dear Doran, Bert and Roger, Thank you for attending my query and for your valuable responses. The task is slightly more complex. Here's the real case... I have genetic variation data (40,000 single nucleotide polymorphisms) from 9

Re: [R] Matrix Multiplication using R.

2013-08-15 Thread Hans Thompson
ly appreciated. > > Regards, > > Praveen. > > -Original Message- > From: Roger Koenker [mailto:rkoen...@illinois.edu] > Sent: 14 August 2013 23:06 > To: Praveen Surendran > Cc: r-help@r-project.org > Subject: Re: [R] Matrix Multiplication using R. > > I

Re: [R] Matrix Multiplication using R.

2013-08-15 Thread Praveen Surendran
rkoen...@illinois.edu] Sent: 14 August 2013 23:06 To: Praveen Surendran Cc: r-help@r-project.org Subject: Re: [R] Matrix Multiplication using R. In the event that these are moderately sparse matrices, you could try Matrix or SparseM. Roger Koenker rkoen...@illinois.edu On Aug 14, 2013, at 10:

Re: [R] Matrix Multiplication using R.

2013-08-14 Thread Roger Koenker
In the event that these are moderately sparse matrices, you could try Matrix or SparseM. Roger Koenker rkoen...@illinois.edu On Aug 14, 2013, at 10:40 AM, Praveen Surendran wrote: > Dear all, > > I am exploring ways to perform multiplication of a 9 x 4 matrix with > it's transpose

Re: [R] Matrix Multiplication using R.

2013-08-14 Thread Bert Gunter
Well, one might start by noting that it's usually unnecessary and unwise to multiply a matrix by its transpose. Matrix decompositions, algebraic identities, and/or iterative procedures usually do calculations involving t(x)%*%x in better ways. 'Course without knowledge of your problem, maybe I'm

Re: [R] Matrix Multiplication using R.

2013-08-14 Thread Doran, Harold
To: r-help@r-project.org Subject: [R] Matrix Multiplication using R. Dear all, I am exploring ways to perform multiplication of a 9 x 4 matrix with it's transpose. As expected even a 4 x 100 %*% 100x4 didn't work on my desktop... giving the error "Error: cannot

[R] Matrix Multiplication using R.

2013-08-14 Thread Praveen Surendran
Dear all, I am exploring ways to perform multiplication of a 9 x 4 matrix with it's transpose. As expected even a 4 x 100 %*% 100x4 didn't work on my desktop... giving the error "Error: cannot allocate vector of length 16" However I am trying to run this on one node (64G

Re: [R] Matrix multiplication with scattered NA values

2013-05-13 Thread arun
Hi, Not sure if this is what you wanted:  mat1<- as.matrix(read.table(text="   33    45    50   NA   NA   54 ",sep="",header=FALSE)) mat2<- as.matrix(read.table(text=" 24    0.000    0.000 0.000    14    0.000 0.000 0.000  

Re: [R] matrix multiplication

2013-02-27 Thread arun
Hi, Try this: #mat1 is the data res<-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat1[-i,])),function(j) {x1<-rbind(mat1[i,],mat1[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2

Re: [R] matrix multiplication

2013-02-27 Thread arun
Hi, Just to add: res<-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat1[-i,])),function(j) {x1<-rbind(mat1[i,],mat1[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7

Re: [R] matrix multiplication

2013-02-27 Thread arun
HI Elisa, You can also use: mat2<- head(mat1) resNew<-do.call(cbind,lapply(seq_len(nrow(mat2)),function(i) do.call(rbind,lapply(split(rbind(mat2[i,],mat2[-i,]),1:nrow(rbind(mat2[i,],mat2[-i,]))),function(x) {x1<-rbind(mat2[i,],x); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[

Re: [R] Matrix multiplication

2012-12-12 Thread Thomas Stewart
One solution that does not require matrix multiplication: Remember that the steady state vector is in the nullspace of I - T. Therefore: require(MASS) n1 <- Null(t(diag(nrow(T)) - T)) n1 / sum(n1) On Wed, Dec 12, 2012 at 2:19 AM, annek wrote: > Hi, > I have a transition matrix T for which I

Re: [R] Matrix multiplication

2012-12-12 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of annek > Sent: Tuesday, December 11, 2012 11:19 PM > To: r-help@r-project.org > Subject: [R] Matrix multiplication > > Hi, > I have a transition matrix

Re: [R] Matrix multiplication

2012-12-12 Thread peter dalgaard
On Dec 12, 2012, at 08:19 , annek wrote: > Hi, > I have a transition matrix T for which I want to find the steady state matrix > for. This could be approximated by taking T^n , for large n. > > T= [ 0.8797 0.0382 0.0527 0.0008 > 0.02120.8002 0.0041 0.0143 > 0.09810

Re: [R] Matrix multiplication

2012-12-12 Thread Fg Nu
, ncol = 4,byrow = T) T %^% 200 - Original Message - From: annek To: r-help@r-project.org Cc: Sent: Wednesday, December 12, 2012 12:49 PM Subject: [R] Matrix multiplication Hi, I have a transition matrix T for which I want to find the steady state matrix for. This could be approximated

[R] Matrix multiplication

2012-12-11 Thread annek
Hi, I have a transition matrix T for which I want to find the steady state matrix for. This could be approximated by taking T^n , for large n. T= [ 0.8797 0.0382 0.0527 0.0008 0.02120.8002 0.0041 0.0143 0.09810.0273 0.8802 0.0527 0.00100.1343 0.0630

Re: [R] .Rd vs. .R, matrix multiplication

2012-12-03 Thread Duncan Murdoch
On 12-12-03 5:00 PM, Christian Hoffmann wrote: Hi, I find it cumbersomesome the I have to use \%*\% in .Rd files vs. %*% in .R files. R CMD check will refuse %*% in .Rd files. I would like to have %*% in .Rd files to be able to execute expressions with matrix multiplication from .Rd files direct

[R] .Rd vs. .R, matrix multiplication

2012-12-03 Thread Christian Hoffmann
Hi, I find it cumbersomesome the I have to use \%*\% in .Rd files vs. %*% in .R files. R CMD check will refuse %*% in .Rd files. I would like to have %*% in .Rd files to be able to execute expressions with matrix multiplication from .Rd files directly, but ESS (version 5.13) would refuse to e

[R] Matrix multiplication using Matrix package

2012-06-27 Thread Doran, Harold
I have the following matrix operation A %*% B %*% A Where these matrices have the following dimensions and class attributes. > dim(A) [1] 5764 5764 > class(A) [1] "dgCMatrix" attr(,"package") [1] "Matrix" > dim(B) [1] 5764 5764 > class(B) [1] "dgCMatrix" attr(,"package") [1] "Matrix" Now, wh

Re: [R] Matrix multiplication by multple constants

2012-04-20 Thread Greg Snow
And another way is to remember properties of matrix multiplication: y %*% diag(x) On Fri, Apr 20, 2012 at 8:35 AM, David Winsemius wrote: > > On Apr 20, 2012, at 4:57 AM, Dimitris Rizopoulos wrote: > >> try this: >> >> x  <- 1:3 >> y  <- matrix(1:12, ncol = 3, nrow = 4) >> >> y * rep(x, each =

Re: [R] Matrix multiplication by multple constants

2012-04-20 Thread David Winsemius
On Apr 20, 2012, at 4:57 AM, Dimitris Rizopoulos wrote: try this: x <- 1:3 y <- matrix(1:12, ncol = 3, nrow = 4) y * rep(x, each = nrow(y)) Another way with a function specifically designed for that purpose: sweep(y, 2, x, "*") -- David. I hope it helps. Best, Dimitris On 4/20

Re: [R] Matrix multiplication by multple constants

2012-04-20 Thread Vincy Pyne
Dear Mr. Dimitris Rizopoulos, Thanks a lot for your great help. It worked nicely. I couldn't have figured it out. Thanks again. Regards Vincy --- On Fri, 4/20/12, Dimitris Rizopoulos wrote: From: Dimitris Rizopoulos Subject: Re: [R] Matrix multiplication by multple constants To: &

Re: [R] Matrix multiplication by multple constants

2012-04-20 Thread Dimitris Rizopoulos
try this: x <- 1:3 y <- matrix(1:12, ncol = 3, nrow = 4) y * rep(x, each = nrow(y)) I hope it helps. Best, Dimitris On 4/20/2012 10:51 AM, Vincy Pyne wrote: Dear R helpers Suppose x<- c(1:3) y<- matrix(1:12, ncol = 3, nrow = 4) y [,1] [,2] [,3] [1,]159 [2,]2

[R] Matrix multiplication by multple constants

2012-04-20 Thread Vincy Pyne
Dear R helpers Suppose x  <- c(1:3) y  <- matrix(1:12, ncol = 3, nrow = 4) > y [,1] [,2] [,3] [1,]    1    5    9 [2,]    2    6   10 [3,]    3    7   11 [4,]    4    8   12 I wish to multiply 1st column of y by first element of x i.e. 1, 2nd column of y by 2nd element of x i.e. 2 an so

Re: [R] matrix multiplication

2011-10-11 Thread Rolf Turner
On 12/10/11 09:11, flokke wrote: Dear all, Sorry to bother you with such a stupid question, but I just cannot find the solution to my problem. I'd like to use matrix multiplication for meanA and factorial 3. I use the command meanA%*%factorial 3. But everything I get is: Error in factorial3 %*%

[R] matrix multiplication

2011-10-11 Thread flokke
Dear all, Sorry to bother you with such a stupid question, but I just cannot find the solution to my problem. I'd like to use matrix multiplication for meanA and factorial 3. I use the command meanA%*%factorial 3. But everything I get is: Error in factorial3 %*% A : non-conformable arguments I

Re: [R] matrix multiplication

2011-10-11 Thread B77S
Your question as answered by Timothy in your previous thread http://r.789695.n4.nabble.com/Re-Creating-the-mean-using-algebra-matrix-td3895689.html flokke wrote: > > Dear all, > Sorry to bother you with such a stupid question, but I just cannot find > the solution to my problem. > > I'd lik

Re: [R] Matrix multiplication gives different results some of the times (NaN)

2011-09-13 Thread Xavier Fernández i Marín
Ben Bolker vas escriure el dia dt, 13 set 2011: > You mentioned that you had compiled R yourself. > Can you replicate this with a stock R binary, i.e. from a > Red Hat or Ubuntu repository? If not, can you give details of > your compilation setup, especially if you are using a specialized > or

Re: [R] Matrix multiplication gives different results some of the times (NaN)

2011-09-13 Thread Ben Bolker
Xavier Fernández i Marín gmail.com> writes: > More elements: In python the same algorithm does not show this strange > behaviour. > Is Python using the same BLAS/LAPACK? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-h

Re: [R] Matrix multiplication gives different results some of the times (NaN)

2011-09-13 Thread Ben Bolker
Xavier Fernández i Marín gmail.com> writes: > Rolf Turner vas escriure el dia dt, 13 set 2011: > [snip] > > This sort of thing should not/does not/cannot happen under > > ``normal circumstances''. There has to be something wrong > > somewhere in your setup. Either your hardware or your sof

Re: [R] Matrix multiplication gives different results some of the times (NaN)

2011-09-13 Thread Xavier Fernández i Marín
Rolf Turner vas escriure el dia dt, 13 set 2011: > > I tried your example code on my laptop running Ubuntu Linux, > and of course it ran --- just as it should (*has* to!) without any > problem; no errors thrown. > > This sort of thing should not/does not/cannot happen under > ``normal circumstan

Re: [R] Matrix multiplication gives different results some of the times (NaN)

2011-09-13 Thread Rolf Turner
I tried your example code on my laptop running Ubuntu Linux, and of course it ran --- just as it should (*has* to!) without any problem; no errors thrown. This sort of thing should not/does not/cannot happen under ``normal circumstances''. There has to be something wrong somewhere in your setup

Re: [R] Matrix multiplication gives different results some of the times (NaN)

2011-09-13 Thread Xavier Fernández i Marín
Joshua Wiley vas escriure el dia dt, 13 set 2011: > I cannot replicate this on, even with 1 milllion reps on: > > R version 2.13.1 (2011-07-08) > Platform: i386-pc-mingw32/i386 (32-bit) > > or > > R Under development (unstable) (2011-08-13 r56733) > Platform: x86_64-pc-mingw32/x64 (64-bit) > >

Re: [R] Matrix multiplication gives different results some of the times (NaN)

2011-09-13 Thread Joshua Wiley
I cannot replicate this on, even with 1 milllion reps on: R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) or R Under development (unstable) (2011-08-13 r56733) Platform: x86_64-pc-mingw32/x64 (64-bit) Perhaps it is OS dependent (I am away from my linux box at the moment)?

[R] Matrix multiplication gives different results some of the times (NaN)

2011-09-13 Thread Xavier Fernández i Marín
Dear all, When trying to multiply the same matrices repeatedly I get different results some of the times. It is not systematic, which is the fact that is giving me more trouble to try to isolate the problem. Basically I am doing X %*% B, where X is a Nx2 matrix and B is a vector with 2 values. I

Re: [R] Unusual slowing of R matrix multiplication version 2.12.1 (2010-10-15) vs 2.12.0

2011-02-07 Thread Prof Brian Ripley
You'll need to ask the person who built R (you haven't told us). If this was a binary CRAN build, you are asked to discuss that only on R-sig-mac, and you will find plenty of discussion on that list's archives. Note that - this is Mac-specific (not mentioned in your subject line) - it even d

[R] Unusual slowing of R matrix multiplication version 2.12.1 (2010-10-15) vs 2.12.0

2011-02-07 Thread Joseph Kunkel
R Version 2.12.1 (2010-10-15) vs 2.12.0 has slowed down 8 fold for dual core and 17 fold for dual-core-dual-processor Macs. I have checked this result on 3 different macs using the following R-script: Using Version 2.12.0 on a dual core dual processor Mac: > source("http://www.bio.umass.edu/bi

Re: [R] Matrix multiplication and random numbers

2009-09-11 Thread Henrique Dallazuanna
If I understand you can use replicate: replicate(10, matmult(InitialPop, 1)) On Fri, Sep 11, 2009 at 1:11 PM, RFish wrote: > > Hi > > Sorry I don't seem to have explained what I'm trying to do very clearly. > The piece of code below multiplies the two matrices together a number of > times base

Re: [R] Matrix multiplication and random numbers

2009-09-11 Thread RFish
Hi Sorry I don't seem to have explained what I'm trying to do very clearly. The piece of code below multiplies the two matrices together a number of times based on the value in the matmult(InitialPop,1) term in this case one (year), this gives me the end population for the analysis. InitialPop<

Re: [R] Matrix multiplication and random numbers

2009-09-09 Thread RFish
Sorry I probably wasn't clear with my description. The reason i put for loop in was that I want to do the matrix multiplication about 1000 times to get a 1000 different matrices. Therefore I was hoping the for loop would be able to automate this then use write.table to write to an external documen

Re: [R] Matrix multiplication and random numbers

2009-09-09 Thread Chris Stubben
RFish wrote: > > I new to using R and am struggling with some matrix multiplication. > I'm not sure what you're trying to print, but you could place this vector in an expression mat3<-expression(c(0,rnorm(1,0.6021,0.0987),0,0,0,0,0,0,0,rnorm(1,0.6021,0.0987),0,0,0,0,1.9,0,0,rnorm(1,0.6021,0.

Re: [R] Matrix multiplication and random numbers

2009-09-09 Thread jim holtman
I am not sure what you mean by being the same each time. If I make successive calls to the function, I get different results: > z [,1] [1,] 0. [2,] 0. [3,] 201.6382 [4,] 0. [5,] 0. [6,] 0. [7,] 0. > matmult(InitialPop,1) [,1] [1,] 0.000 [2,]

[R] Matrix multiplication and random numbers

2009-09-09 Thread RFish
Dear All I new to using R and am struggling with some matrix multiplication. I have two matrices, one containing random numbers, these are multiplied together to get another matrix which is different each time. When I put in another for loop to repeat this process a multiple times the matrices

Re: [R] Matrix multiplication precision

2009-07-15 Thread Nair, Murlidharan T
n expert in the area. Cheers../Murli -Original Message- From: dmba...@gmail.com [mailto:dmba...@gmail.com] On Behalf Of Douglas Bates Sent: Wednesday, July 15, 2009 7:29 AM To: Nair, Murlidharan T Cc: r-help@r-project.org Subject: Re: [R] Matrix multiplication precision On Wed,

Re: [R] Matrix multiplication precision

2009-07-15 Thread roger koenker
A good discussion of this is provided by Gill, Murray and Wright Num Lin Alg and Opt, section 4.7.2. url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiuc.eduDepartment of Economics vox: 217-333-4558University of Illinois fax: 217-

Re: [R] Matrix multiplication precision

2009-07-15 Thread Steve Lianoglou
Hi Douglas, And the big lesson, of course, is the first rule of numerical linear algebra., "Just because a formula is written in terms of the inverse of a matrix doesn't mean that is a good way to calculate the result; in fact, it is almost inevitably the worst way of calculating the result". Y

Re: [R] Matrix multiplication precision

2009-07-15 Thread Douglas Bates
On Wed, Jul 15, 2009 at 3:42 AM, Nair, Murlidharan T wrote: > Hi!! > I am trying to multiply 5 matrices and then using the inverse of that matrix > for further computation. I read about precision problems from the archives > and the suggestion was to use as.numeric while computing the products.

[R] Matrix multiplication precision

2009-07-14 Thread Nair, Murlidharan T
Hi!! I am trying to multiply 5 matrices and then using the inverse of that matrix for further computation. I read about precision problems from the archives and the suggestion was to use as.numeric while computing the products. I am still having problems with the results. Here is how I am using

Re: [R] Matrix multiplication - code problem

2009-04-02 Thread Ben Bolker
I think this works in general, although it's a little bit clunky: id_y <- array(1:10,dim=c(2,1,5)) id_yt <- aperm(id_y,c(2,1,3)) m_id <- array(dim=c(dim(id_y)[1],dim(id_y)[1],dim(id_y)[3])) for (i in 1:dim(id_y)[3]){ m1 <- array(id_y[,,i],dim=dim(id_y)[1:2]) m2 <- array(id_yt[,,i],dim=di

Re: [R] Matrix multiplication - code problem

2009-04-02 Thread Patrick Burns
You need to put in calls to 'as.matrix'. It's a bit tricky though -- what you want depends on whether it is the first or second subscript that has length 1. as.matrix(id_y[,,i]) if the second dimension has length 1. t(as.matrix(id_y[,,i])) if the first dimension has length 1. Patrick Burns

Re: [R] Matrix multiplication - code problem

2009-04-02 Thread MarcioRibeiro
Hi again, I understood what you guys explained... But, there isn't a way to do a multiplication of matrix with a FOR command or otherelse where one o my dimension is ONE... Well, as my data file is small, I did the procedure at the excel... But, this is not the good procedure... Thanks, Marcio U

Re: [R] Matrix multiplication - code problem

2009-04-02 Thread Uwe Ligges
MarcioRibeiro wrote: Hi listers, I am having some trouble in a matrix multiplication... I have already checked some posts, but I didn't find my problem... I have the following code... But I am not getting the right multiplication... I checked the dimension and they are fine... id_y <- array(1:

Re: [R] Matrix multiplication - code problem

2009-04-01 Thread MarcioRibeiro
Hi again... I will get an array with 5 matrix 2x2, with dimension 2x2x5 This code below works fine... And I am applying the same procedure... The problem might be when I do the permutation of the array, but I checked the dimension and its all right... array1 <- array(1:30,dim=c(3,2,5)) array2 <-

[R] Matrix multiplication - code problem

2009-04-01 Thread MarcioRibeiro
Hi listers, I am having some trouble in a matrix multiplication... I have already checked some posts, but I didn't find my problem... I have the following code... But I am not getting the right multiplication... I checked the dimension and they are fine... id_y <- array(1:10,dim=c(2,1,5)) id_yt<-

Re: [R] Matrix multiplication - code problem

2009-04-01 Thread Ben Bolker
I think your problem is with R's behavior of dropping array indices when dim==1. Simulating that > m1 <- matrix(1:2,nrow=2) > m2 <- matrix(1:2,ncol=2) > m1 %*% m2 [,1] [,2] [1,]12 [2,]24 > m1[,] %*% m2[,] [,1] [1,]5 [1,]5 > m1[,,drop=FALSE] %*% m2[,,drop=

Re: [R] Matrix multiplication - code problem

2009-04-01 Thread Ben Bolker
MarcioRibeiro wrote: > > Hi listers, > I am having some trouble in a matrix multiplication... > I have already checked some posts, but I didn't find my problem... > I have the following code... > But I am not getting the right multiplication... > I checked the dimension and they are fine... >

Re: [R] matrix multiplication, tensor product, block-diagonal and fast computation

2009-03-16 Thread Camarda, Carlo Giovanni
Thursday, March 12, 2009 4:25 PM To: Camarda, Carlo Giovanni Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] matrix multiplication, tensor product, block-diagonal and fast computation On Wed, 11 Mar 2009, Camarda, Carlo Giovanni wrote: > Dear R-users, > > I am searching to the "bes

Re: [R] matrix multiplication, tensor product, block-diagonal and fast computation

2009-03-12 Thread Charles C. Berry
On Wed, 11 Mar 2009, Camarda, Carlo Giovanni wrote: Dear R-users, I am searching to the "best" way to compute a series of n matrix multiplications between each matrix (mXm) in an array (mXmXn), and each column of a matrix (mXn). Please find below an example with four possible solutions. The fi

[R] matrix multiplication, tensor product, block-diagonal and fast computation

2009-03-11 Thread Camarda, Carlo Giovanni
Dear R-users, I am searching to the "best" way to compute a series of n matrix multiplications between each matrix (mXm) in an array (mXmXn), and each column of a matrix (mXn). Please find below an example with four possible solutions. The first is a simple for-loop which one might avoid; the se

[R] Matrix multiplication multivariate

2009-02-20 Thread MarcioRibeiro
Hi listers... I am trying to do a matrix multiplication... Suppose my data has 100 obs and 2 variables... I calculated the estimateurs of location and dispersion... So now I would like to do the following... t(Xi-location)%*%solve(dispersion)%*%(Xi-location) My code is... Z<-rep(2,200) Z<-matrix(Z

Re: [R] Matrix Multiplication

2009-02-06 Thread Gavin Simpson
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)

Re: [R] Matrix Multiplication

2009-02-06 Thread Jorge Ivan Velez
Dear Maithili, A<-matrix(1:20,4,5)B<-matrix(10:24,5,3) A %*% B See ?"%*%" for more information. HTH, Jorge On Fri, Feb 6, 2009 at 7:57 AM, 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 mat

[R] Matrix Multiplication

2009-02-06 Thread Maithili Shiva
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). Thanks in advance With regards Maithili __ R-help@r-project.org mailing

Re: [R] Matrix multiplication

2008-08-07 Thread Zhang Yanwei - Princeton-MRAm
:42 PM To: Zhang Yanwei - Princeton-MRAm; r-help@r-project.org Subject: RE: [R] Matrix multiplication Hi, Yes. this is a way, and relatively easy ... Using "Reduce". Note: in order to use "Reduce", you need an update-to-date version of R. I'm using 2.6.2. First you have

Re: [R] Matrix multiplication

2008-08-06 Thread Ling, Gary (Electronic Trading)
238 -7.953889 -6.130237 -9.717463 # [4,] -0.7801092 3.003660 1.104163 -5.834807 ### end demo ### So, they are the same. Cheers! -gary -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Zhang Yanwei - Princeton-MRAm Sent: Wednesday, August 06, 2008 5:02 PM

[R] Matrix multiplication

2008-08-06 Thread Zhang Yanwei - Princeton-MRAm
Hi all, Is there an easy way to do cumulative matrix multipliation in R? What's the syntex? Thanks. Sincerely, Yanwei Zhang Department of Actuarial Research and Modeling Munich Re America Tel: 609-275-2176 Email: [EMAIL PROTECTED] [[alternative HTML version

Re: [R] matrix multiplication question

2008-07-18 Thread Doran, Harold
exists). -Original Message- From: [EMAIL PROTECTED] on behalf of Duncan Murdoch Sent: Fri 7/18/2008 1:00 AM To: Murali K Cc: r-help@r-project.org Subject: Re: [R] matrix multiplication question On 17/07/2008 9:47 PM, Murali K wrote: > Hello, > I am a newcomer to R and the

Re: [R] matrix multiplication question

2008-07-17 Thread Tsjerk Wassenaar
Hi Murali, So, the solution to your problem will be to explicitly convert your matrix to a numeric matrix. Maybe matrix (?matrix) will do, or you'll also have to use as.numeric (?as.numeric). The strings on the left seem to me to be the row labels, right..?, not elements in the matrix/table. As a

Re: [R] matrix multiplication question

2008-07-17 Thread Duncan Murdoch
On 17/07/2008 9:47 PM, Murali K wrote: Hello, I am a newcomer to R and therefore apologize for posting such a basic question. I am trying to multiply 2 matrices t(X1)%*%X1, where t(X1) is: It's hard to say for sure, but it looks as though X1 really isn't a numeric matrix. The "ones" a

[R] matrix multiplication question

2008-07-17 Thread Murali K
Hello, I am a newcomer to R and therefore apologize for posting such a basic question. I am trying to multiply 2 matrices t(X1)%*%X1, where t(X1) is: 1 2 3 4 5 8 12 13 20 24 26 27 31 33 34 36 37 40 41 42 45 46 47 48 49 ones 1 1 1 1 1 1 1 1 1 11 1 1 1