def multiply(self, factor):
        if isinstance(factor, IndexMatrix):
            if factor.shape == (1,1):
                return self.multiply(factor[0,0])
            elif factor.shape[0] == 1:
                diag = self._new_instance(sp.dia_matrix((factor.to_ndarray(), [0]),
                                                        shape=(factor.shape[1], factor.shape[1])),
                                                        row2word=factor.col2word)
                return self.dot(diag)
            elif factor.shape[1] == 1:
                diag = self._new_instance(sp.dia_matrix((factor.transpose().to_ndarray(), [0]),
                                          shape=(factor.shape[0], factor.shape[0])),
                                          col2word=factor.row2word)
                return diag.dot(self)
            else:
                return self._new_instance(self.matrix.multiply(factor.matrix))
        elif isinstance(factor, Number):
            return self._new_instance(self.matrix.multiply(factor))
Element-wise multiplication.
dataset/ETHPy150Open jimmycallin/pydsm/pydsm/indexmatrix.py/IndexMatrix.multiply