Caution
The functions available in this submodule have been designed to work with classes in the pyCTQW.MPI module; that is, they are being called implicitly by the above classes, invisible to the user.
It is not recommended that they be used by themselves, however it is possible to do so.
adjToH(adj[, d, amp]) | Creates a 1 particle PETSc-type Hamiltonian matrix from a PETSc adjacency matrix. |
arrayToMat(matArray) | Converts a (global) 2D array to a PETSc matrix over petsc4py.PETSc.COMM_WORLD. |
arrayToVec(vecArray) | Converts a (global) array to a PETSc vector over petsc4py.PETSc.COMM_WORLD. |
exportMat(mat, filename, filetype[, mattype]) | Export a PETSc matrix to a file. |
exportVec(vec, filename, filetype) | Export a PETSc vector to a file. |
exportVecToMat(vec, filename, filetype) | Export a \(N^2\) element PETSc vector as a \(N\times N\) matrix. |
loadMat(filename, filetype[, delimiter]) | Import a PETSc matrix from a file. |
loadMatToVec(filename, filetype) | Load a \(N\times N\) matrix as a \(N^2\) element PETSc vector. |
loadVec(filename, filetype) | Import a PETSc vector from a file. |
matToSparse(mat) | Converts a PETSc matrix to a (global) sparse matrix. |
vecToArray(obj) | Converts a PETSc vector to a numpy array, available on all MPI nodes. |
vecToArray0(obj) | Converts a PETSc vector to a numpy array available on MPI node 0. |
Input and output functions.
Creates a 1 particle PETSc-type Hamiltonian matrix from a PETSc adjacency matrix.
Parameters: |
|
---|---|
Returns: | : 1 particle Hamiltonian matrix |
Return type: | petsc4py.PETSc.Mat() |
Warning
The size of a and d must be identical
>>> amp = [0.5,-1.,4.2]
>>> len(d) == len(amp)
True
Elements of d can range from \([0,N-1]\) where the adjacency matrix is \(N\times N\).
Converts a (global) 2D array to a PETSc matrix over petsc4py.PETSc.COMM_WORLD.
Parameters: | matArray (array or numpy.array) – input square array. |
---|---|
Return type: | petsc4py.PETSc.Mat() |
Important
Requires SciPy.
Converts a (global) array to a PETSc vector over petsc4py.PETSc.COMM_WORLD.
Parameters: | vecArray (array or numpy.array) – input vector. |
---|---|
Returns: | petsc4py.PETSc.Vec() : |
Export a PETSc matrix to a file.
Parameters: |
|
---|
Export a PETSc vector to a file.
Parameters: |
|
---|
Export a \(N^2\) element PETSc vector as a \(N\times N\) matrix.
This is useful when wanting to view the full statespace of a 2 particle quantum walk.
Parameters: |
|
---|
Import a PETSc matrix from a file.
Parameters: |
|
---|
Load a \(N\times N\) matrix as a \(N^2\) element PETSc vector.
This is useful when wanting to import the full statespace of a 2 particle quantum walk to use for propagation.
Parameters: |
|
---|
Import a PETSc vector from a file.
Parameters: |
|
---|
Converts a PETSc matrix to a (global) sparse matrix.
Parameters: | mat (petsc4py.PETSc.Mat) – input PETSc matrix. |
---|---|
Return type: | scipy.sparse.csr_matrix |
Important
Requires SciPy.