Created
August 6, 2017 10:39
-
-
Save YabZhang/2a87488f580056a2139f4b892c60fb30 to your computer and use it in GitHub Desktop.
sparse matrix transpose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| class SparseMatrix(object): | |
| """二维稀疏矩阵""" | |
| def __init__(self, row, col): | |
| self.m = row - 1 | |
| self.n = col - 1 | |
| self.seq = [] | |
| def set(self, x, y, val): | |
| item = [x, y, val] | |
| self.seq.append(item) | |
| self.seq.sort() | |
| def display(self): | |
| pass | |
| def transpose(self): | |
| """ | |
| 1. i <=> j | |
| 2. m <=> n | |
| 3. self.seq.sort | |
| """ | |
| pass | |
| if __name__ == '__main__': | |
| pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment