9
# TEST NUMBER ZERO : DEFAULT CONSTRUCTOR AND STRING CONVERTER
10
print "test number zero : default constructor and string converter"
16
print "matrix0 = " , matrix0
19
# TEST NUMBER ONE : CONSTRUCTOR WITH SIZE, OPERATOR() AND STRING CONVERTER
20
print "test number one : constructor with size, operator() and string converter"
22
# Constructor with size
25
# Check operator() methods
32
print "matrix1 = " , matrix1
35
# TEST NUMBER TWO : COPY CONSTRUCTOR AND STRING CONVERTER
36
print "test number two : copy constructor and string converter"
39
matrix2 = Matrix(matrix1)
42
print "matrix2 = " , matrix2
45
# TEST NUMBER THREE : GET DIMENSIONS METHODS
46
print "test number three : get dimensions methods"
48
# Get dimension methods
49
print "matrix1's nbRows = " , matrix1.getNbRows()
50
print "matrix1's nbColumns = " , matrix1.getNbColumns()
53
# TEST NUMBER FOUR : CONSTRUCTOR WITH COLLECTION
54
print "test number four : constructor with collection method"
56
# Create the collection of values
57
elementsValues = NumericalScalarCollection()
58
elementsValues.add(1.)
59
elementsValues.add(2.)
60
elementsValues.add(3.)
61
elementsValues.add(4.)
62
elementsValues.add(5.)
63
elementsValues.add(6.)
65
# Check the content of the collection
66
print "elementsValues = " , elementsValues
68
# Check the constructor with collection
69
matrix0bis = Matrix(2,2,elementsValues)
70
print "matrix0bis = " , matrix0bis
72
# TEST NUMBER FIVE : ASSIGNMENT METHOD
73
print "test number five : assignment method"
79
# TEST NUMBER SIX : TRANSPOSITION METHOD
80
print "test number six : transposition method"
82
# Check transpose method
83
matrix4 = matrix1.transpose()
84
print "matrix1 transposed = " , matrix4
87
# TEST NUMBER SEVEN : ADDITION METHOD
88
print "test number seven : addition method"
90
# Check addition method : we check the operator and the symmetry of the operator, thus testing the comparison operator
91
sum1 = matrix1 + matrix4
92
sum2 = matrix4 + matrix1
93
print "sum1 = " , sum1
94
print "sum2 = " , sum2
95
print "sum1 equals sum2 = " , sum1 == sum2
98
# TEST NUMBER EIGHT : SUBSTRACTION METHOD
99
print "test number eight : substraction method"
101
# Check substraction method
102
diff = matrix1-matrix4
103
print "diff = " , diff
106
# TEST NUMBER NINE : MATRIX MULTIPLICATION METHOD
107
print "test number nine : matrix multiplication method"
109
# Check multiplication method
110
prod = matrix1*matrix4
111
print "prod = " , prod
114
# TEST NUMBER TEN : MULTIPLICATION WITH A NUMERICAL POINT METHOD
115
print "test number ten : multiplication with a numerical point method"
117
# Create the numerical point
118
pt = NumericalPoint()
121
print "pt = " , repr(pt)
123
# Check the product method
124
ptResult = matrix1* pt
125
print "ptResult = " , repr(ptResult)
127
# TEST NUMBER ELEVEN : MULTIPLICATION AND DIVISION BY A NUMERICAL SCALAR METHODS
128
print "test number eleven : multiplication and division by a numerical scalar methods"
130
# Check the multiplication method
132
scalprod1 = matrix1 * s
133
#bug PYTHON scalprod2 = s * matrix1
134
scalprod3 = matrix1 * s
135
print "scalprod1 = " , scalprod1
136
#print "scalprod2 = " , scalprod2
137
print "scalprod3 = " , scalprod3
138
#print "scalprod1 equals scalprod2 = " , (scalprod1 == scalprod2)
139
print "scalprod1 equals scalprod3 = " , (scalprod1 == scalprod3)
140
#print "scalprod2 equals scalprod3 = " , (scalprod2 == scalprod3)
142
# Check the division method
145
print "scaldiv1 = " , scaldiv1
146
print "scaldiv2 = " , scaldiv2
147
print "scaldiv1 equals scaldiv2 = " , (scaldiv1 == scaldiv2)
150
# TEST NUMBER TWELVE : ISEMPTY METHOD
151
print "test number twelve : isEmpty method"
153
# Check method isEmpty
156
# matrix6.setDimensions(0,3)
157
print "matrix1 is empty = " , matrix1.isEmpty()
158
print "matrix5 is empty = " , matrix5.isEmpty()
159
print "matrix6 is empty = " , matrix6.isEmpty()
160
print "matrix0 is empty = " , matrix0.isEmpty()
162
# TEST NUMBER FOURTEEN : MULTIPLICATION WITH A NUMERICAL POINT METHOD
163
print "test number fourteen : multiplication with a numerical point method"
165
# Create the numerical point
166
pt_test = NumericalPoint()
169
print "pt_test = " , repr(pt_test)
179
# Check the product method
180
ptResult2 = id* pt_test
184
print "ptResult2 = " , repr(ptResult2)
9
# TEST NUMBER ZERO : DEFAULT CONSTRUCTOR AND STRING CONVERTER
10
print "test number zero : default constructor and string converter"
16
print "matrix0 = " , repr(matrix0)
19
# TEST NUMBER ONE : CONSTRUCTOR WITH SIZE, OPERATOR() AND STRING CONVERTER
20
print "test number one : constructor with size, operator() and string converter"
22
# Constructor with size
25
# Check operator() methods
32
print "matrix1 = " , repr(matrix1)
35
# TEST NUMBER TWO : COPY CONSTRUCTOR AND STRING CONVERTER
36
print "test number two : copy constructor and string converter"
39
matrix2 = Matrix(matrix1)
42
print "matrix2 = " , repr(matrix2)
45
# TEST NUMBER THREE : GET DIMENSIONS METHODS
46
print "test number three : get dimensions methods"
48
# Get dimension methods
49
print "matrix1's nbRows = " , matrix1.getNbRows()
50
print "matrix1's nbColumns = " , matrix1.getNbColumns()
53
# TEST NUMBER FOUR : CONSTRUCTOR WITH COLLECTION
54
print "test number four : constructor with collection method"
56
# Create the collection of values
57
elementsValues = NumericalScalarCollection()
58
elementsValues.add(1.)
59
elementsValues.add(2.)
60
elementsValues.add(3.)
61
elementsValues.add(4.)
62
elementsValues.add(5.)
63
elementsValues.add(6.)
65
# Check the content of the collection
66
print "elementsValues = " , elementsValues
68
# Check the constructor with collection
69
matrix0bis = Matrix(2,2,elementsValues)
70
print "matrix0bis = " , repr(matrix0bis)
72
# TEST NUMBER FIVE : ASSIGNMENT METHOD
73
print "test number five : assignment method"
79
# TEST NUMBER SIX : TRANSPOSITION METHOD
80
print "test number six : transposition method"
82
# Check transpose method
83
matrix4 = matrix1.transpose()
84
print "matrix1 transposed = " , repr(matrix4)
87
# TEST NUMBER SEVEN : ADDITION METHOD
88
print "test number seven : addition method"
90
# Check addition method : we check the operator and the symmetry of the operator, thus testing the comparison operator
91
sum1 = matrix1 + matrix4
92
sum2 = matrix4 + matrix1
93
print "sum1 = " , repr(sum1)
94
print "sum2 = " , repr(sum2)
95
print "sum1 equals sum2 = " , sum1 == sum2
98
# TEST NUMBER EIGHT : SUBSTRACTION METHOD
99
print "test number eight : substraction method"
101
# Check substraction method
102
diff = matrix1-matrix4
103
print "diff = " , repr(diff)
106
# TEST NUMBER NINE : MATRIX MULTIPLICATION METHOD
107
print "test number nine : matrix multiplication method"
109
# Check multiplication method
110
prod = matrix1*matrix4
111
print "prod = " , repr(prod)
114
# TEST NUMBER TEN : MULTIPLICATION WITH A NUMERICAL POINT METHOD
115
print "test number ten : multiplication with a numerical point method"
117
# Create the numerical point
118
pt = NumericalPoint()
121
print "pt = " , repr(pt)
123
# Check the product method
124
ptResult = matrix1* pt
125
print "ptResult = " , repr(ptResult)
127
# TEST NUMBER ELEVEN : MULTIPLICATION AND DIVISION BY A NUMERICAL SCALAR METHODS
128
print "test number eleven : multiplication and division by a numerical scalar methods"
130
# Check the multiplication method
132
scalprod1 = matrix1 * s
133
#bug PYTHON scalprod2 = s * matrix1
134
scalprod3 = matrix1 * s
135
print "scalprod1 = " , repr(scalprod1)
136
#print "scalprod2 = " , scalprod2
137
print "scalprod3 = " , repr(scalprod3)
138
#print "scalprod1 equals scalprod2 = " , (scalprod1 == scalprod2)
139
print "scalprod1 equals scalprod3 = " , (scalprod1 == scalprod3)
140
#print "scalprod2 equals scalprod3 = " , (scalprod2 == scalprod3)
142
# Check the division method
145
print "scaldiv1 = " , repr(scaldiv1)
146
print "scaldiv2 = " , repr(scaldiv2)
147
print "scaldiv1 equals scaldiv2 = " , (scaldiv1 == scaldiv2)
150
# TEST NUMBER TWELVE : ISEMPTY METHOD
151
print "test number twelve : isEmpty method"
153
# Check method isEmpty
156
# matrix6.setDimensions(0,3)
157
print "matrix1 is empty = " , matrix1.isEmpty()
158
print "matrix5 is empty = " , matrix5.isEmpty()
159
print "matrix6 is empty = " , matrix6.isEmpty()
160
print "matrix0 is empty = " , matrix0.isEmpty()
162
# TEST NUMBER FOURTEEN : MULTIPLICATION WITH A NUMERICAL POINT METHOD
163
print "test number fourteen : multiplication with a numerical point method"
165
# Create the numerical point
166
pt_test = NumericalPoint()
169
print "pt_test = " , repr(pt_test)
179
# Check the product method
180
ptResult2 = id* pt_test
181
print "A = " , repr(A)
182
print "B = " , repr(B)
183
print "id = " , repr(id)
184
print "ptResult2 = " , repr(ptResult2)
187
print "t_Matrix_std.py", sys.exc_type, sys.exc_value