From: "M. Edward (Ed) Borasky" Date: 2006-09-11T21:37:50+09:00 Subject: Re: Matrix Paul Lutus wrote: > MonkeeSage wrote: > >> Dave Burt wrote: >>> It's by design. A Matrix is immutable, like Ruby's other numbers >>> (Fixnum, Rational, Complex...) >> Why should a Matrix be immutable? It's not a type like a Fixnum, it's a >> data structure, like an Array or Hash. What is gained by creating a new >> Matrix from a changing data stream, rather than updating an existing >> one? > > In mathematics, matrices of various kinds are regarded as a unit, usually > indivisible. For example, they're used a lot in computer graphics > processing to hold rotation matrices. > > The rotation matrices are loaded with specific values that accomplish > rotations and translations, and until the computed viewpoint changes, the > entire matrix is used to process all the image vertices. > > Then, when the viewpoint changes, the entire matrix is recomputed, and a new > immutable matrix is created. The point I am making is that the matrix can't > function if it is thought of as nine scalar values rather than a 3x3 square > matrix. The immutability of a Matrix violates Whoever's Law, which states It is possible to write Fortran programs in any language. Seriously, though, I agree with the poster who said some mathematicians want to be able to compute and change elements of a matrix. I happen to be one of those, and the subclass trick someone posted is one I'll need to use if I use the "Matrix" concept in my Ruby code. Given how slow it is, though, that seems unlikely.