Re: [R] Product of certain rows in a matrix without loop

2013-09-03 Thread PIKAL Petr
9:34 AM > To: R help > Subject: [R] Product of certain rows in a matrix without loop > > Hello everybody. > Thank you again to Bert and Arun for their help on my previous > question. > I know have the following problem: > I have a matrix : > A = > 1 2 3 > 4 5 6

Re: [R] Product of certain rows in a matrix without loop

2013-09-03 Thread Gerrit Eichner
Ok, here is a bandmatrix solution "by hand": leftmatrix <- matrix( c( rep( 1, k), rep( 0, nrow(A) - k + 1)), byrow = TRUE, ncol = nrow(A), nrow = nrow(A) - k + 1) Gerrit Thank you very much for your answer. Unfortunately, I cannot use any package... Er, ... this is qui

Re: [R] Product of certain rows in a matrix without loop

2013-09-03 Thread Gerrit Eichner
Thank you very much for your answer. Unfortunately, I cannot use any package... Er, ... this is quite unusual! (Is this is homework?) Do you have a solution ? Well, take a look at the resulting bandmatrix leftmatrix. Yould can certainly build it yourself "by hand" somehow. I used the Matrix pa

Re: [R] Product of certain rows in a matrix without loop

2013-09-03 Thread Edouard Hardy
Thank you very much for your answer. Unfortunately, I cannot use any package... Do you have a solution ? Thank you in advance Edouard Hardy On Tue, Sep 3, 2013 at 11:49 AM, Gerrit Eichner < gerrit.eich...@math.uni-giessen.de> wrote: > Hello, Edouard, > > taking logs of A's elements (so that *

Re: [R] Product of certain rows in a matrix without loop

2013-09-03 Thread Gerrit Eichner
Hello, Edouard, taking logs of A's elements (so that * turns into +, so to say), using a left-multiplication with a certain band matrix of the package Matrix, and exponentiating the result again could provide a solution (see below). I know have the following problem: I have a matrix : A = 1

[R] Product of certain rows in a matrix without loop

2013-09-03 Thread Edouard Hardy
Hello everybody. Thank you again to Bert and Arun for their help on my previous question. I know have the following problem: I have a matrix : A = 1 2 3 4 5 6 7 8 9 9 8 7 4 5 6 3 2 1 And I would like to have : B = 1*4*7 2*5*8 3*6*9 4*7*9 5*8*8 6*9*7 7*9*4 8*8*5 9*7*6 9*4*3 8*5*2