Sorts the given matrix by using the L2 norm. Args: matrix(np.ndarray): The matrix to sort. Returns: np.ndarray: The sorted matrix.
(self, matrix)
| 135 | return matrix |
| 136 | |
| 137 | def sort(self, matrix): |
| 138 | """Sorts the given matrix by using the L2 norm. |
| 139 | |
| 140 | Args: |
| 141 | matrix(np.ndarray): The matrix to sort. |
| 142 | |
| 143 | Returns: |
| 144 | np.ndarray: The sorted matrix. |
| 145 | """ |
| 146 | # Sort the atoms such that the norms of the rows are in descending |
| 147 | # order |
| 148 | norms = np.linalg.norm(matrix, axis=1) |
| 149 | sorted_indices = np.argsort(-norms, kind="stable", axis=0) |
| 150 | sorted_matrix = matrix[sorted_indices] |
| 151 | sorted_matrix = sorted_matrix[:, sorted_indices] |
| 152 | |
| 153 | return sorted_matrix |
| 154 | |
| 155 | def get_eigenspectrum(self, matrix): |
| 156 | """Calculates the eigenvalues of the matrix and returns a list of them |
no outgoing calls
no test coverage detected