Révision 75

pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage (revision 75)
137 137
    if columnWidth != 0:
138 138
        print    
139 139
# End spo_add_polynomial_coeffs_to_matrix
140

  
141
def spo_expression_as_string(powI, powT, powP, alpha):
142
    expressionAsString =""
143
    if powI != 0:
144
        expressionAsString += "i^" + str(powI)
145
    if powT != 0:
146
        if len(expressionAsString) != 0:
147
            expressionAsString += " * "
148
        expressionAsString += "t^" + str(powT)
149
    if powP != 0:
150
        if len(expressionAsString) != 0:
151
            expressionAsString += " * "
152
        expressionAsString += "p^" + str(powP)
153
    if (alpha - powP) != 0 :
154
        if len(expressionAsString) != 0:
155
            expressionAsString += " * "
156
        expressionAsString += "N^" + str(alpha - powP)
157
    return(expressionAsString)
158
# End spo_expression_as_string.
pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage (revision 75)
1
def is_lower_triangular_matrix(mat):
1
def smo_is_diagonal_complete_matrix(mat):
2 2
    """
3
    Check that the matrix is lower triangular.
3
    Check that all the element on the diagonal are not 0.
4 4
    """
5 5
    dimensions = mat.dimensions()
6 6
    # Must be a bidimensional matrix.
......
9 9
    # Must be square.
10 10
    if dimensions[0] != dimensions[1]:
11 11
        return False
12
    # A 1x1 matrix is lower triangular.
12
    # A 1x1 matrix is diagonal complete if it's single element is not 0.
13 13
    if dimensions[0] == 1:
14
        return True
14
        if mat[0, 0] != 0:
15
            return True
16
        else:
17
            return False
18
    # End if
15 19
    for rowIndex in xrange(0, dimensions[0]):
16
        for colIndex in xrange(rowIndex + 1, dimensions[1]):
17
            if mat[rowIndex, colIndex] != 0:
18
                print mat.rows()[rowIndex]
19
                return False
20
        if mat[rowIndex, rowIndex] == 0:
21
            print mat.rows()[rowIndex], rowIndex
22
            return False
20 23
    return True
21
# End is_lower_triangular_matrix
24
# End smo_is_diagonal_complete_matrix
22 25

  
23
def is_diagonal_complete_matrix(mat):
26
def smo_is_lower_triangular_matrix(mat):
24 27
    """
25
    Check that all the element on the diagonal are not 0.
28
    Check that the matrix is lower triangular.
26 29
    """
27 30
    dimensions = mat.dimensions()
28 31
    # Must be a bidimensional matrix.
......
31 34
    # Must be square.
32 35
    if dimensions[0] != dimensions[1]:
33 36
        return False
34
    # A 1x1 matrix is diagonal complete if it's single element is not 0.
37
    # A 1x1 matrix is lower triangular.
35 38
    if dimensions[0] == 1:
36
        if mat[0, 0] != 0:
37
            return True
38
        else:
39
            return False
40
    # End if
39
        return True
41 40
    for rowIndex in xrange(0, dimensions[0]):
42
        if mat[rowIndex, rowIndex] == 0:
43
            print mat.rows()[rowIndex], rowIndex
44
            return False
41
        for colIndex in xrange(rowIndex + 1, dimensions[1]):
42
            if mat[rowIndex, colIndex] != 0:
43
                print mat.rows()[rowIndex]
44
                return False
45 45
    return True
46
# End is_diagonal_complete_matrix
46
# End smo_is_lower_triangular_matrix
47

  

Formats disponibles : Unified diff