Révision 83 pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage

sageMatrixOperations.sage (revision 83)
45 45
    return True
46 46
# End smo_is_lower_triangular_matrix
47 47

  
48
def smo_is_upper_triangular_matrix(mat):
49
    """
50
    Check that the matrix is upper triangular.
51
    """
52
    dimensions = mat.dimensions()
53
    # Must be a bidimensional matrix.
54
    if len(dimensions) != 2:
55
        return False
56
    # Must be square.
57
    if dimensions[0] != dimensions[1]:
58
        return False
59
    # A 1x1 matrix is lower triangular.
60
    if dimensions[0] == 1:
61
        return True
62
    for rowIndex in xrange(1, dimensions[0]):
63
        for colIndex in xrange(0, rowIndex):
64
            if mat[rowIndex, colIndex] != 0:
65
                print mat.rows()[rowIndex]
66
                return False
67
    return True
68
# End smo_is_upper_triangular_matrix
69

  
70
print "sageMatrixOperations loaded..."

Formats disponibles : Unified diff