root / pobysoPythonSage / src / sageSLZ / sageMatrixOperations.sage @ 75
Historique | Voir | Annoter | Télécharger (1,38 ko)
1 |
def smo_is_diagonal_complete_matrix(mat): |
---|---|
2 |
""" |
3 |
Check that all the element on the diagonal are not 0. |
4 |
""" |
5 |
dimensions = mat.dimensions() |
6 |
# Must be a bidimensional matrix. |
7 |
if len(dimensions) != 2: |
8 |
return False |
9 |
# Must be square. |
10 |
if dimensions[0] != dimensions[1]: |
11 |
return False |
12 |
# A 1x1 matrix is diagonal complete if it's single element is not 0. |
13 |
if dimensions[0] == 1: |
14 |
if mat[0, 0] != 0: |
15 |
return True |
16 |
else: |
17 |
return False |
18 |
# End if |
19 |
for rowIndex in xrange(0, dimensions[0]): |
20 |
if mat[rowIndex, rowIndex] == 0: |
21 |
print mat.rows()[rowIndex], rowIndex |
22 |
return False |
23 |
return True |
24 |
# End smo_is_diagonal_complete_matrix |
25 |
|
26 |
def smo_is_lower_triangular_matrix(mat): |
27 |
""" |
28 |
Check that the matrix is lower triangular. |
29 |
""" |
30 |
dimensions = mat.dimensions() |
31 |
# Must be a bidimensional matrix. |
32 |
if len(dimensions) != 2: |
33 |
return False |
34 |
# Must be square. |
35 |
if dimensions[0] != dimensions[1]: |
36 |
return False |
37 |
# A 1x1 matrix is lower triangular. |
38 |
if dimensions[0] == 1: |
39 |
return True |
40 |
for rowIndex in xrange(0, dimensions[0]): |
41 |
for colIndex in xrange(rowIndex + 1, dimensions[1]): |
42 |
if mat[rowIndex, colIndex] != 0: |
43 |
print mat.rows()[rowIndex] |
44 |
return False |
45 |
return True |
46 |
# End smo_is_lower_triangular_matrix |
47 |
|