TwoDimensionalMatrix.st
author Stefan Vogel <sv@exept.de>
Wed, 08 Apr 2020 19:02:35 +0200
changeset 5473 de911f462862
parent 5382 eda4b952a1e7
permissions -rw-r--r--
*** empty log message ***

"{ Encoding: utf8 }"

"
 COPYRIGHT (c) 2018 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libbasic2' }"

"{ NameSpace: Smalltalk }"

Matrix variableSubclass:#TwoDimensionalMatrix
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Collections-MultiDimensional'
!

!TwoDimensionalMatrix class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2018 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
! !

!TwoDimensionalMatrix methodsFor:'accessing'!

subMatrix: aPoint
    |nRows "{Class: SmallInteger }"
     nCols "{Class: SmallInteger }"
     retval retRow retCol |

    nRows := self rows.
    nCols := self columns.
    retval := Matrix newForRows:(nRows-1) cols:(nCols-1).

    retRow := retCol := 1.

    1 to:nRows do:[:r |
        r ~= aPoint x ifTrue: [
            1 to:nCols do:[:c |
                c ~= aPoint y ifTrue: [
                    retval _at: retRow at: retCol put: (self _at: r at: c).
                    retCol := retCol + 1 
                ] 
            ].
            retRow := retRow + 1 
        ].
        retCol := 1 
    ].
    ^ retval

    "
     (Matrix3_3 withAll:#(11 12 13 
                          21 22 23 
                          31 32 33))
        subMatrix:(1 @ 1)  
    "
! !

!TwoDimensionalMatrix methodsFor:'matrix operations'!

minor: aPoint
    ^ (self subMatrix: aPoint) determinantByCofactors
! !

!TwoDimensionalMatrix methodsFor:'queries'!

cofactor:aPoint
    (aPoint x + aPoint y) odd
            ifTrue: [ ^ -1 * (self minor: aPoint) ]
            ifFalse: [ ^ self minor: aPoint ]
! !

!TwoDimensionalMatrix class methodsFor:'documentation'!

version_CVS
    ^ '$Header$'
! !