Commit 539e2068 authored by rusty1s's avatar rusty1s
Browse files

bandwidth

parent 172640ef
...@@ -243,6 +243,15 @@ class SparseTensor(object): ...@@ -243,6 +243,15 @@ class SparseTensor(object):
def avg_col_length(self) -> float: def avg_col_length(self) -> float:
return self.nnz() / self.sparse_size(1) return self.nnz() / self.sparse_size(1)
def bandwidth(self) -> int:
row, col, _ = self.coo()
return int((row - col).abs_().max())
def bandwidth_proportion(self, bandwidth: int) -> float:
row, col, _ = self.coo()
tmp = (row - col).abs_()
return int((tmp <= bandwidth).sum()) / self.nnz()
def is_quadratic(self) -> bool: def is_quadratic(self) -> bool:
return self.sparse_size(0) == self.sparse_size(1) return self.sparse_size(0) == self.sparse_size(1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment