|
3 | 3 | copy_transform, |
4 | 4 | crout_matrix_decomposition, |
5 | 5 | cholesky_matrix_decomposition, |
| 6 | + matrix_exponentiation, |
6 | 7 | matrix_inversion, |
7 | 8 | multiply, |
8 | 9 | rotate_image, |
@@ -159,6 +160,29 @@ def test_inversion(self): |
159 | 160 | [Fraction(13, 53), Fraction(-22, 53), Fraction(5, 53)]]) |
160 | 161 |
|
161 | 162 |
|
| 163 | +class TestMatrixExponentiation(unittest.TestCase): |
| 164 | + """[summary] |
| 165 | + Test for the file matrix_exponentiation.py |
| 166 | +
|
| 167 | + Arguments: |
| 168 | + unittest {[type]} -- [description] |
| 169 | + """ |
| 170 | + |
| 171 | + def test_matrix_exponentiation(self): |
| 172 | + mat = [[1, 0, 2], [2, 1, 0], [0, 2, 1]] |
| 173 | + |
| 174 | + self.assertEqual(matrix_exponentiation.matrix_exponentiation(mat, 0), |
| 175 | + [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) |
| 176 | + |
| 177 | + self.assertEqual(matrix_exponentiation.matrix_exponentiation(mat, 1), |
| 178 | + [[1, 0, 2], [2, 1, 0], [0, 2, 1]]) |
| 179 | + |
| 180 | + self.assertEqual(matrix_exponentiation.matrix_exponentiation(mat, 2), |
| 181 | + [[1, 4, 4], [4, 1, 4], [4, 4, 1]]) |
| 182 | + |
| 183 | + self.assertEqual(matrix_exponentiation.matrix_exponentiation(mat, 5), |
| 184 | + [[81, 72, 90], [90, 81, 72], [72, 90, 81]]) |
| 185 | + |
162 | 186 |
|
163 | 187 | class TestMultiply(unittest.TestCase): |
164 | 188 | """[summary] |
|
0 commit comments