Sparse Matrix¶
In block2, we support a few different representations of the block-sparse matrix.
Archived Sparse Matrix¶
-
template<typename
S
, typenameFL
>
structblock2
::
ArchivedSparseMatrix
: public block2::SparseMatrix<S, FL>¶ Block-sparse Matrix associated with disk storage, representing sparse operator.
- tparam S
Quantum label type.
- tparam FL
float point type.
Public Functions
Constructor.
- Parameters
filename – The name of the associated disk file.
offset – Byte offset in the file (where to read/write the content).
alloc – Memory allocator.
-
inline virtual SparseMatrixTypes
get_type
() const override¶ Get the type of this sparse matrix.
- Returns
Type of this sparse matrix.
Allocate memory for the sparse matrix non-zero elements. This method is not allowed here. Will cause assertion failure.
- Parameters
info – The quantum label information for the sparse matrix.
ptr – If not zero, the given pointer is used as the data pointer (no allocation will happen).
-
inline virtual void
deallocate
() override¶ Release the allocated memory. This method does nothing here, since no memory is used by this object.
-
inline shared_ptr<SparseMatrix<S, FL>>
load_archive
()¶ Load the sparse matrix data from disk.
- Returns
A normal or CSR sparse matrix (with data in memory).
Write the sparse matrix data to disk.
- Parameters
mat – A normal or CSR sparse matrix (with data in memory).