summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorKatolaZ <katolaz@yahoo.it>2015-05-12 12:03:53 +0100
committerKatolaZ <katolaz@yahoo.it>2015-05-12 12:03:53 +0100
commitf6c8d6f8691ce36546abb115054d466f1f35f532 (patch)
tree2462e4ca475525c9da6fea165b43b0983e608878 /python
parenta56739c87b2d29c493ee41f60af388bada70c455 (diff)
parent815c998aa757969edd25b34a8eefa8f5be4d4097 (diff)
Merge branch 'lightK'
Conflicts: python/multired.py
Diffstat (limited to 'python')
-rw-r--r--python/multired.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/python/multired.py b/python/multired.py
index 2b52a4f..06fbc79 100644
--- a/python/multired.py
+++ b/python/multired.py
@@ -35,6 +35,7 @@
# --------------------------------------------
#
# -- 2015/04/23 -- release 0.1
+# -- 2015/05/11 -- release 0.1.1 -- removed the last full matrices
#
@@ -122,8 +123,8 @@ class layer:
elif matrix != None:
self.adj_matr = copy.copy(matrix)
self.N, _x = matrix.shape
- 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).reshape((1, self.N)).tolist()[0]
+ D = csr_matrix((K, (range(self.N), range(self.N)) ), shape=(self.N, self.N))
self.laplacian = csr_matrix(D - self.adj_matr)
K = self.laplacian.diagonal().sum()
self.resc_laplacian = csr_matrix(self.laplacian / K)
@@ -134,13 +135,13 @@ class layer:
self.N = N
self.adj_matr = csr_matrix((self._ww, (self._ii, self._jj)), shape=(self.N, self.N))
self.adj_matr = self.adj_matr + self.adj_matr.transpose()
- 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).reshape((1, self.N)).tolist()[0]
+ D = csr_matrix((K, (range(self.N), range(self.N)) ), shape=(self.N, self.N))
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
@@ -170,14 +171,15 @@ class layer:
self.adj_matr = self.adj_matr + other_layer.adj_matr
else:
self.adj_matr = copy.copy(other_layer.adj_matr)
- 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).reshape((1, self.N)).tolist()[0]
+ D = csr_matrix((K, (range(self.N), range(self.N)) ), shape=(self.N, self.N))
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: