From c42c3d71ac9244ebb42e76808f0a2e1be4a67f66 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Tue, 12 May 2015 00:04:24 +0100 Subject: [PATCH] Removed the last dangling full matrix --- python/multired.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python/multired.py b/python/multired.py index 0023d38..be5ddbf 100644 --- a/python/multired.py +++ b/python/multired.py @@ -126,7 +126,8 @@ class layer: #K = np.multiply(self.adj_matr.sum(0), np.ones((self.N,self.N))) #D = np.diag(np.diag(K)) K = self.adj_matr.sum(0) - D = K * eye(self.N) + D = csr_matrix((self.N, self.N)) + D.setdiag(eye(self.N) * K.transpose()) self.laplacian = csr_matrix(D - self.adj_matr) K = self.laplacian.diagonal().sum() self.resc_laplacian = csr_matrix(self.laplacian / K) @@ -140,12 +141,13 @@ class layer: #K = np.multiply(self.adj_matr.sum(0), np.ones((self.N,self.N))) #D = np.diag(np.diag(K)) K = self.adj_matr.sum(0) - D = K * eye(self.N) + D = csr_matrix((self.N, self.N)) + D.setdiag(eye(self.N) * K.transpose()) self.laplacian = csr_matrix(D - self.adj_matr) K = self.laplacian.diagonal().sum() self.resc_laplacian = csr_matrix(self.laplacian / K) self._matrix_called = True - + def dump_info(self): N, M = self.adj_matr.shape K = self.adj_matr.nnz @@ -178,13 +180,15 @@ class layer: #K = np.multiply(self.adj_matr.sum(0), np.ones((self.N,self.N))) #D = np.diag(np.diag(K)) K = self.adj_matr.sum(0) - D = K * eye(self.N) + D = csr_matrix((self.N, self.N)) + D.setdiag(eye(self.N) * K. transpose()) self.laplacian = csr_matrix(D - self.adj_matr) K = self.laplacian.diagonal().sum() self.resc_laplacian = csr_matrix(self.laplacian / K) self._matrix_called = True - + def dump_laplacian(self): + print self.laplacian class multiplex_red: