The following is a suggestion - there are many ways to implement matrices.
- Define a class as a subclass of Object with instance variables for cells, numberOfRows and numberOfColumns.
- Create a class method to initialize the matrix given the number of rows and number of columns - make the cells an array of size rows * columns
- Create methods like at:at: and at:at:put: which calculate an index into the cells array as follows:
cellNumberAt: row at: column ^(row - 1) * numberOfColumns + column at: row at: column put: value cells at: (self cellNumberAt: row at: column) put: value at: row at: column ^cells at: (self cellNumberAt: row at: column) rowAt: rowNumber | row | row := OrderedCollection new. 1 to: numberOfColumns do: [:columnNumber | row add: (self at: rowNumber at: columnNumber)]. ^row columnAt: columnNumber | column | column := OrderedCollection new. 1 to: numberOfRows do: [:rowNumber | column add: (self at: rowNumber at: columnNumber)]. ^column
I hope that helps.