'From Cuis 2.0 of 4 January 2010 [latest update: #393] on 8 February 2010 at 9:57:20 am'!
!classDefinition: #ObjectMatrix category: #LinearAlgebra!
Matrix subclass: #ObjectMatrix
	instanceVariableNames: 'elements'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'LinearAlgebra'!

!ObjectMatrix commentStamp: '<historical>' prior: 0!
A matrix that can hold any kind of objects.!


!Matrix methodsFor: 'misc' stamp: 'jmv 2/8/2010 09:42'!
withIndexesDo: aBlock
	"Replace each value with the result of evaluating aBlock, with the previous value as the argument"

	1 to: height do: [ :i |
		1 to: width do: [ :j |
				aBlock value: i value: j value: (self i: i j: j) ] ]! !


!ObjectMatrix methodsFor: 'accessing' stamp: 'jmv 2/8/2010 09:30'!
elements
	^ elements! !

!ObjectMatrix methodsFor: 'accessing' stamp: 'jmv 2/8/2010 09:30'!
elementsIndexForI: i j: j
	"Indexes goes from 1 to size (width or height)"

	^ i-1*width+j! !

!ObjectMatrix methodsFor: 'accessing' stamp: 'jmv 2/8/2010 09:30'!
i: i j: j

	"Answer element at row i, column j"

	^ elements at: (self elementsIndexForI: i j: j)! !

!ObjectMatrix methodsFor: 'accessing' stamp: 'jmv 2/8/2010 09:31'!
i: i j: j put: anObject
	"Store anObject as the element at row i, column j"

	elements at: (self elementsIndexForI: i j: j) put: anObject! !

!ObjectMatrix methodsFor: 'initialization' stamp: 'jmv 2/8/2010 09:31'!
initializeElements

	elements _ Array new: height * width! !

!ObjectMatrix methodsFor: 'copying' stamp: 'jmv 2/8/2010 09:30'!
copy

	^self copyTwoLevel! !

