From: Rick DeNatale Date: 2006-09-12T10:52:28+09:00 Subject: Re: Matrix On 9/11/06, MonkeeSage wrote: > Dave Burt wrote: > > If you want a matrix-like data structure (rather than a mathematical > > matrix), why not use an array of arrays? > > A mathematical matrix is just a dimensional arrangement of data into > "rows" and "columns", thus allowing for certain algorithmic > relationships to be defined and applied (e.g., canonical > decompositions). Every matrix (i.e., the actual matrix considered as a > complex value) is immutable and has a unique identity, just like every > number -- that's true -- but they can also be permuted or otherwise > transformed into different matrices. Why should one have to do that > constructively (i.e., construct a new matrix "from scratch"), rather > than destructively (i.e., change the existing matrix "in place"). Think > of it like this: n = 1; n = n + 1 -- even though the number 1 is > immutable and has a unique identity, the reference to it is not, and > can thus be destructively altered by assignment with the result that it > refers to new identity. It would be a pain to have to do o = n + 1, p = > n + 2 (i.e., creating new references every time the data changes), just > because 1 is immutable. Why should a matrix be any different? Mabye I'm > missing something... Yes, you're missing the distinction between a variable which references a sequence of objects over time, and the objects it references. a = 1 a = 2 Does NOT change 1 to 2. Fortran II used to let you change 1 to 2: subroutine a(arg) arg = 2 end subroutine a call a(1) But this was considered a bug and was changed in Fortran IV. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/