Ejemplo n.º 1
0
    def _blockmul(self, other):

        if  (other.is_Matrix and other.is_BlockMatrix and
                self.blockshape[1] == other.blockshape[0] and
                self.colblocksizes == other.rowblocksizes):
            return BlockMatrix(self.blocks*other.blocks)

        return MatrixExpr.__mul__(self, other)
Ejemplo n.º 2
0
    def _blockmul(self, other):

        if  (other.is_Matrix and other.is_BlockMatrix and
                self.blockshape[1] == other.blockshape[0] and
                self.colblocksizes == other.rowblocksizes):
            return BlockMatrix(self.mat*other.mat)

        return MatrixExpr.__mul__(self, other)
Ejemplo n.º 3
0
    def _blockadd(self, other):

        if  (other.is_Matrix and other.is_BlockMatrix and
                self.blockshape == other.blockshape and
                self.rowblocksizes == other.rowblocksizes and
                self.colblocksizes == other.colblocksizes):
            return BlockMatrix(self.mat + other.mat)

        return MatrixExpr.__add__(self, other)
Ejemplo n.º 4
0
 def __new__(cls, b, e):
     e = _sympify(e)
     if e is S.One or b.is_ZeroMatrix:
         return b
     elif not b.is_square:
         raise ShapeError("Power of non-square matrix %s"%b)
     elif e is S.Zero:
         return Identity(b.n)
     else:
         return MatrixExpr.__new__(cls, b, e)
Ejemplo n.º 5
0
 def __new__(cls, b, e):
     e = _sympify(e)
     if e is S.One or b.is_ZeroMatrix:
         return b
     elif not b.is_square:
         raise ShapeError("Power of non-square matrix %s"%b)
     elif e is S.Zero:
         return Identity(b.n)
     else:
         return MatrixExpr.__new__(cls, b, e)
Ejemplo n.º 6
0
    def _blockadd(self, other):
        if   (other.is_Matrix and other.is_BlockMatrix
                and self.structurally_equal(other)):
            return BlockMatrix(self.blocks + other.blocks)

        return MatrixExpr.__add__(self, other)
Ejemplo n.º 7
0
    def _blockadd(self, other):
        if (other.is_Matrix and other.is_BlockMatrix
                and self.structurally_equal(other)):
            return BlockMatrix(self.blocks + other.blocks)

        return MatrixExpr.__add__(self, other)