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)
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)
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)
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)
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)