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