Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-28 Thread Cuckovic Paik
Thank all help help. Ted's intuitive single step definition is what I want. I try to teach elementary Linear Algebra using R to manupilate matrices. Since my students have no programming experience at all, any fancy and muliple step definition in matrix row operation will confuse them. Again, I a

Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-28 Thread Gabor Grothendieck
On Sat, Aug 28, 2010 at 1:32 AM, Cheng Peng wrote: > > Sorry for possible misunderstanding: > > I want to define a matrix (B) based on an existing matrix (A) in a single > step and keep A unchanged: > >> #Existing matrix >> A=matrix(1:16,ncol=4) >> A >     [,1] [,2] [,3] [,4] > [1,]    1    5    9

Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-28 Thread Dennis Murphy
Hi: Here are some functions for computing elementary matrices so that you can do Gauss elimination the hard way (the easy way is the LU decomposition, but I digress) I wouldn't use these for serious work, since there are no checks for matrix instability, but the essential ideas are there. It

Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-28 Thread David Winsemius
On Aug 28, 2010, at 2:54 AM, Joshua Wiley wrote: Is this sufficiently single steppish for you? D <- A <- matrix(1:16, 4) D[3, ] <- 2 * D[1, ] + D[3, ] # Alternately, you could do this # but it is much messier, and I do not see how # two steps is really an issue # you want to end up with two m

Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-27 Thread Joshua Wiley
Is this sufficiently single steppish for you? D <- A <- matrix(1:16, 4) D[3, ] <- 2 * D[1, ] + D[3, ] # Alternately, you could do this # but it is much messier, and I do not see how # two steps is really an issue # you want to end up with two matrices anyways # so it's not like you save memory by

Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-27 Thread Cheng Peng
Sorry for possible misunderstanding: I want to define a matrix (B) based on an existing matrix (A) in a single step and keep A unchanged: > #Existing matrix > A=matrix(1:16,ncol=4) > A [,1] [,2] [,3] [,4] [1,]159 13 [2,]26 10 14 [3,]37 11 15 [4,]4

Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-27 Thread David Winsemius
On Aug 28, 2010, at 12:29 AM, Cuckovic Paik wrote: Thanks for respose. you still used two steps to get the new matrix tst2: For Pete"s sake! Can't you see that I didn't _need_ to use tst2. The same operations would have worked on tst. I was just using tst2 because I wanted to be able to

Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-27 Thread Cuckovic Paik
Thanks for respose. you still used two steps to get the new matrix tst2: step 1: tst2 = tst step 2: perform the row operation in tst2. Can you do this in a single step? A similar example: > tst [,1] [,2] [,3] [,4] [1,]159 13 [2,]26 10 14 [3,]37 11

Re: [R] How to define new matrix based on an elementary row operation in a single step?

2010-08-27 Thread David Winsemius
On Aug 27, 2010, at 9:21 PM, Cuckovic Paik wrote: I'm not absolutely sure I know what you mean by elementary row operations ... you are supposed to offer test cases and specify the desired output on r-help to support the aging faculties of the helpeRs in this case ... having only the v

[R] How to define new matrix based on an elementary row operation in a single step?

2010-08-27 Thread Cuckovic Paik
-- View this message in context: http://r.789695.n4.nabble.com/How-to-define-new-matrix-based-on-an-elementary-row-operation-in-a-single-step-tp2341768p2341768.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mail