File size: 1,675 Bytes
389d072
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# from visma.gui import logger


def isMatrix(matTok):
    """Checks if given token is matrix

    Arguments:
        matTok {visma.matrix.structure.Matrix} -- matrix token

    Returns:
        bool -- if matrix or not
    """
    matTok.dimension()
    for i in range(0, matTok.dim[0]):
        if len(matTok.value[i]) != matTok.dim[1]:
            # logger.setLevel(0)
            # logger.setLogName('\'isMatrix\' in checks.py')
            # logger.error('Invalid matrix. Check dimensions')
            return False
    return True


def dimCheck(matA, matB):
    """Checks if dimension of the given two matrices are same

    Arguments:
        matA {visma.matrix.structure.Matrix} -- matrix token
        matB {visma.matrix.structure.Matrix} -- matrix token

    Returns:
        bool -- if dimensions same or not
    """
    matA.dimension()
    matB.dimension()
    if matA.dim == matB.dim:
        return True
    return False


def multiplyCheck(matA, matB):
    """Checks if the two matrices can be multiplied

    Arguments:
        matA {visma.matrix.structure.Matrix} -- matrix token
        matB {visma.matrix.structure.Matrix} -- matrix token

    Returns:
        bool -- to multiply or not
    """
    if matA.dim[1] == matB.dim[0]:
        return True
    return False


def isEqual(matA, matB):
    """Checks if the two matrices are equal

    Arguments:
        matA {visma.matrix.structure.Matrix} -- matrix token
        matB {visma.matrix.structure.Matrix} -- matrix token

    Returns:
        bool -- to multiply or not
    """
    if not dimCheck(matA, matB) or matA.__str__() != matB.__str__():
        return False
    else:
        return True