graph2mat.core.data.sparse
Conversion between different sparse representations.
Different sparse representations of a matrix are required during the different
steps of a typical workflow using graph2mat
.
Functions
|
Converts a block dictionary into a coo array. |
|
Creates a BasisMatrix object from a SparseCSR matrix |
|
Converts a scipy CSR array to a sisl sparse orbital matrix. |
|
Converts an orbital matrix from node and edges array to scipy coo. |
|
|
|
- graph2mat.core.data.sparse.block_dict_to_coo(block_dict: Dict[Tuple[int, int, int], ndarray], first_orb: ndarray, n_supercells: int = 1, threshold: float = 1e-08) coo_array [source]
Converts a block dictionary into a coo array.
Conversions to any other sparse structure can be done once we’ve got the coo array.
- graph2mat.core.data.sparse.csr_to_block_dict(spmat: SparseCSR, atoms: Atoms, nsc: ndarray, geometry_atoms: Atoms | None = None, matrix_cls: Type[BasisMatrix] = graph2mat.core.data.matrices.physics.orbital_matrix.OrbitalMatrix) BasisMatrix [source]
Creates a BasisMatrix object from a SparseCSR matrix
- Parameters:
spmat – The sparse matrix to convert to a block dictionary.
atoms – The atoms object for the matrix, containing orbital information.
nsc – The auxiliary supercell size.
matrix_cls – Matrix class to initialize.
geometry_atoms – The atoms object for the full geometry. This allows the matrix to contain atoms without any orbital. Geometry atoms should contain the matrix atoms first and then the orbital-less atoms.
- graph2mat.core.data.sparse.csr_to_sisl_sparse_orbital(csr: csr_array, geometry: Geometry, sp_class: Type[SparseOrbital] = sisl.SparseOrbital) SparseOrbital [source]
Converts a scipy CSR array to a sisl sparse orbital matrix.
- graph2mat.core.data.sparse.nodes_and_edges_to_coo(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, orbitals: ndarray, n_supercells: int = 1, edge_neigh_isc: ndarray | None = None, threshold: float | None = None, symmetrize_edges: bool = False) coo_array [source]
Converts an orbital matrix from node and edges array to scipy coo.
Conversions to any other sparse structure can be done once we’ve got the coo array.
- Parameters:
node_vals – Flat array containing the values of the node blocks. The order of the values is first by node index, then row then column.
edge_vals – Flat array containing the values of the edge blocks. The order of the values is first by edge index, then row then column.
edge_index – Array of shape (2, n_edges) containing the indices of the atoms that participate in each edge.
orbitals – Array of shape (n_nodes, ) containing the number of orbitals for each atom.
n_supercells – Number of auxiliary supercells.
edge_neigh_isc – Array of shape (n_edges, ) containing the supercell index of the second atom in each edge with respect to the first atom. If not provided, all interactions are assumed to be in the unit cell.
threshold – Matrix elements with a value below this number are set to 0.
symmetrize_edges – whether for each edge only one direction is provided. The edge block for the opposite direction is then created as the transpose.
- graph2mat.core.data.sparse.nodes_and_edges_to_sparse_orbital(node_vals: ndarray, edge_vals: ndarray, edge_index: ndarray, geometry: Geometry, sp_class: Type[SparseOrbital] = sisl.SparseOrbital, edge_neigh_isc: ndarray | None = None, threshold: float = 1e-08, symmetrize_edges: bool = False) SparseOrbital [source]