5087
|
1 |
"{ Package: 'stx:libbasic2' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
|
5 |
SquareMatrix variableSubclass:#Matrix3_3
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Collections-MultiDimensional'
|
|
10 |
!
|
|
11 |
|
|
12 |
!Matrix3_3 class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
3x3 Matrix (2 dimensions).
|
|
17 |
Especially useful with the ArrayIndexing-Parser extension.
|
|
18 |
|
|
19 |
[author:]
|
|
20 |
Claus Gittinger (cg@sinir)
|
|
21 |
|
|
22 |
[instance variables:]
|
|
23 |
|
|
24 |
[class variables:]
|
|
25 |
|
|
26 |
[see also:]
|
|
27 |
MultiDimensionalArrayAccessor
|
|
28 |
"
|
|
29 |
! !
|
|
30 |
|
|
31 |
!Matrix3_3 class methodsFor:'instance creation'!
|
|
32 |
|
|
33 |
new
|
|
34 |
^ self basicNew:3*3
|
|
35 |
! !
|
|
36 |
|
|
37 |
!Matrix3_3 methodsFor:'accessing'!
|
|
38 |
|
|
39 |
_at:index1 at:index2
|
|
40 |
"this is a synthetic selector, generated by the compiler,
|
|
41 |
if a construct of the form expr[idx...] is parsed.
|
|
42 |
I.e.
|
|
43 |
foo[n,m]
|
|
44 |
generates
|
|
45 |
foo _at:n at:m
|
|
46 |
"
|
|
47 |
|idx|
|
|
48 |
|
|
49 |
(index1 between:1 and:3) ifFalse:[self subscriptBoundsError:index1].
|
|
50 |
(index2 between:1 and:3) ifFalse:[self subscriptBoundsError:index2].
|
|
51 |
|
|
52 |
idx := index1 * 3 - 3 + index2.
|
|
53 |
^ self basicAt:idx.
|
|
54 |
!
|
|
55 |
|
|
56 |
_at:index1 at:index2 put:value
|
|
57 |
"this is a synthetic selector, generated by the compiler,
|
|
58 |
if a construct of the form expr[idx...] := val is parsed.
|
|
59 |
I.e.
|
|
60 |
foo[n,m] := val
|
|
61 |
generates
|
|
62 |
foo _at:n at:m put:val
|
|
63 |
"
|
|
64 |
|idx|
|
|
65 |
|
|
66 |
(index1 between:1 and:3) ifFalse:[self subscriptBoundsError:index1].
|
|
67 |
(index2 between:1 and:3) ifFalse:[self subscriptBoundsError:index2].
|
|
68 |
|
|
69 |
idx := index1 * 3 - 3 + index2.
|
|
70 |
^ self basicAt:idx put:value.
|
|
71 |
! !
|
|
72 |
|
|
73 |
!Matrix3_3 methodsFor:'matrix operations'!
|
|
74 |
|
|
75 |
determinantByCofactors
|
|
76 |
"Answer the determinant of this matrix."
|
|
77 |
|
|
78 |
^ ((self _at: 1 at: 1) * (((self _at: 2 at: 2)*(self _at: 3 at: 3)) - ((self _at: 3 at: 2)*(self _at: 2 at: 3)))) -
|
|
79 |
((self _at: 1 at: 2) * (((self _at: 2 at: 1)*(self _at: 3 at: 3)) - ((self _at: 3 at: 1)*(self _at: 2 at: 3)))) +
|
|
80 |
((self _at: 1 at: 3) * (((self _at: 2 at: 1)*(self _at: 3 at: 2)) - ((self _at: 3 at: 1)*(self _at: 2 at: 2)))).
|
|
81 |
! !
|
|
82 |
|
|
83 |
!Matrix3_3 class methodsFor:'documentation'!
|
|
84 |
|
|
85 |
version_CVS
|
|
86 |
^ '$Header$'
|
|
87 |
! !
|
|
88 |
|