------_ extPart_001_01C646CF.713A3394 Content-Type: text/plain; charset so-8859-1" Content-Transfer-Encoding: quoted-printable >I see your conundrum. However I think it should be possible to do what you >want. If you maintain only the list of columns I think you can still make it >work. > > > class MatrixRow > def initialize(columns, row_number) > @columns = columns > @row_number = row_number > end > def [](index) > @columns[row_number][index] > end > def []=(index, value) > @columns[row_number][index] = value > end > end > >class SparseMatrix > def initialize() > @columns=Hash.new{|hash,key|hash[key]=Hash.new} > end > def []=(i,j,value) > @columns[j][i]=value > end > def getRow(i) > return MatrixRow.new(@colums, i) > end > def getCol(j) > return @columns[j] > end >end The problem with this is you don't know the valid elements in row "i": implementing a #each method for MatrixRow will be problematic and require you to go over ALL @columns, which takes way too long (@columns has length 100000000, while row(i) will in general have only about 30 elements. iterating through all 100M columns is too time consuming) Greetings, Geert. ------_ extPart_001_01C646CF.713A3394--