|
Blaze 3.9
|
Serializer for dense and sparse matrices. More...
#include <MatrixSerializer.h>
Public Member Functions | |
Constructors | |
| MatrixSerializer () | |
| The default constructor of the MatrixSerializer class. | |
Private Attributes | |
Member variables | |
| uint8_t | version_ |
| The version of the archive. | |
| uint8_t | type_ |
| The type of the matrix. | |
| uint8_t | elementType_ |
| The type of an element. | |
| uint8_t | elementSize_ |
| The size in bytes of a single element of the matrix. | |
| uint64_t | rows_ |
| The number of rows of the matrix. | |
| uint64_t | columns_ |
| The number of columns of the matrix. | |
| uint64_t | number_ |
| The total number of elements contained in the matrix. | |
Serialization functions | |
| template<typename Archive, typename MT, bool SO> | |
| void | serialize (Archive &archive, const Matrix< MT, SO > &mat) |
| Serializes the given matrix and writes it to the archive. | |
| template<typename Archive, typename MT> | |
| void | serializeHeader (Archive &archive, const MT &mat) |
| Serializes all meta information about the given matrix. | |
| template<typename Archive, typename MT, bool SO> | |
| void | serializeMatrix (Archive &archive, const DenseMatrix< MT, SO > &mat) |
| Serializes the elements of a dense matrix. | |
| template<typename Archive, typename MT, bool SO> | |
| void | serializeMatrix (Archive &archive, const SparseMatrix< MT, SO > &mat) |
| Serializes the elements of a sparse matrix. | |
Deserialization functions | |
| template<typename Archive, typename MT, bool SO> | |
| void | deserialize (Archive &archive, Matrix< MT, SO > &mat) |
| Deserializes a matrix from the given archive. | |
| template<typename Archive, typename MT> | |
| void | deserializeHeader (Archive &archive, const MT &mat) |
| Deserializes all meta information about the given matrix. | |
| template<typename MT, bool SO> | |
| DisableIf_t< IsResizable_v< MT > > | prepareMatrix (DenseMatrix< MT, SO > &mat) |
| Prepares the given non-resizable dense matrix for the deserialization process. | |
| template<typename MT, bool SO> | |
| DisableIf_t< IsResizable_v< MT > > | prepareMatrix (SparseMatrix< MT, SO > &mat) |
| Prepares the given non-resizable sparse matrix for the deserialization process. | |
| template<typename MT> | |
| EnableIf_t< IsResizable_v< MT > > | prepareMatrix (MT &mat) |
| Prepares the given resizable matrix for the deserialization process. | |
| template<typename Archive, typename MT> | |
| void | deserializeMatrix (Archive &archive, MT &mat) |
| Deserializes a matrix from the archive. | |
| template<typename Archive, typename MT> | |
| EnableIf_t< MT::simdEnabled > | deserializeDenseRowMatrix (Archive &archive, DenseMatrix< MT, rowMajor > &mat) |
| Deserializes a row-major dense matrix from the archive. | |
| template<typename Archive, typename MT, bool SO> | |
| void | deserializeDenseRowMatrix (Archive &archive, DenseMatrix< MT, SO > &mat) |
| Deserializes a row-major dense matrix from the archive. | |
| template<typename Archive, typename MT, bool SO> | |
| DisableIf_t< IsNumeric_v< ElementType_t< MT > > > | deserializeDenseRowMatrix (Archive &archive, SparseMatrix< MT, SO > &mat) |
| Deserializes a row-major dense matrix from the archive. | |
| template<typename Archive, typename MT, bool SO> | |
| EnableIf_t< IsNumeric_v< ElementType_t< MT > > > | deserializeDenseRowMatrix (Archive &archive, SparseMatrix< MT, SO > &mat) |
| Deserializes a row-major dense matrix from the archive. | |
| template<typename Archive, typename MT> | |
| EnableIf_t< MT::simdEnabled > | deserializeDenseColumnMatrix (Archive &archive, DenseMatrix< MT, columnMajor > &mat) |
| Deserializes a column-major dense matrix from the archive. | |
| template<typename Archive, typename MT, bool SO> | |
| void | deserializeDenseColumnMatrix (Archive &archive, DenseMatrix< MT, SO > &mat) |
| Deserializes a column-major dense matrix from the archive. | |
| template<typename Archive, typename MT, bool SO> | |
| DisableIf_t< IsNumeric_v< ElementType_t< MT > > > | deserializeDenseColumnMatrix (Archive &archive, SparseMatrix< MT, SO > &mat) |
| Deserializes a column-major dense matrix from the archive. | |
| template<typename Archive, typename MT, bool SO> | |
| EnableIf_t< IsNumeric_v< ElementType_t< MT > > > | deserializeDenseColumnMatrix (Archive &archive, SparseMatrix< MT, SO > &mat) |
| Deserializes a column-major dense matrix from the archive. | |
| template<typename Archive, typename MT, bool SO> | |
| void | deserializeSparseRowMatrix (Archive &archive, DenseMatrix< MT, SO > &mat) |
| Deserializes a row-major sparse matrix from the archive. | |
| template<typename Archive, typename MT> | |
| void | deserializeSparseRowMatrix (Archive &archive, SparseMatrix< MT, rowMajor > &mat) |
| Deserializes a row-major sparse matrix from the archive. | |
| template<typename Archive, typename MT> | |
| void | deserializeSparseRowMatrix (Archive &archive, SparseMatrix< MT, columnMajor > &mat) |
| Deserializes a row-major sparse matrix from the archive. | |
| template<typename Archive, typename MT, bool SO> | |
| void | deserializeSparseColumnMatrix (Archive &archive, DenseMatrix< MT, SO > &mat) |
| Deserializes a column-major sparse matrix from the archive. | |
| template<typename Archive, typename MT> | |
| void | deserializeSparseColumnMatrix (Archive &archive, SparseMatrix< MT, rowMajor > &mat) |
| Deserializes a column-major sparse matrix from the archive. | |
| template<typename Archive, typename MT> | |
| void | deserializeSparseColumnMatrix (Archive &archive, SparseMatrix< MT, columnMajor > &mat) |
| Deserializes a column-major sparse matrix from the archive. | |
Serializer for dense and sparse matrices.
The MatrixSerializer implements the necessary logic to serialize dense and sparse matrices, i.e. to convert them into a portable, binary representation. The following example demonstrates the (de-)serialization process of matrices:
Note that it is even possible to (de-)serialize matrices with vector or matrix elements:
As the examples demonstrates, the matrix serialization offers an enormous flexibility. However, several actions result in errors:
In case an error is encountered during (de-)serialization, a std::runtime_exception is thrown.
| void blaze::MatrixSerializer::deserialize | ( | Archive & | archive, |
| Matrix< MT, SO > & | mat ) |
Deserializes a matrix from the given archive.
| archive | The archive to be read from. |
| mat | The matrix to be deserialized. |
| std::runtime_error | Error during deserialization. |
|
private |
Deserializes a column-major dense matrix from the archive.
| archive | The archive to be read from. |
| mat | The dense matrix to be reconstituted. |
| std::runtime_error | Dense matrix could not be deserialized. |
This function deserializes a column-major dense matrix from the archive and reconstitutes the given column-major dense matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a column-major dense matrix from the archive.
| archive | The archive to be read from. |
| mat | The dense matrix to be reconstituted. |
| std::runtime_error | Dense matrix could not be deserialized. |
This function deserializes a column-major dense matrix from the archive and reconstitutes the given dense matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a column-major dense matrix from the archive.
| archive | The archive to be read from. |
| mat | The sparse matrix to be reconstituted. |
| std::runtime_error | Sparse matrix could not be deserialized. |
This function deserializes a column-major dense matrix from the archive and reconstitutes the given sparse matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a column-major dense matrix from the archive.
| archive | The archive to be read from. |
| mat | The sparse matrix to be reconstituted. |
| std::runtime_error | Sparse matrix could not be deserialized. |
This function deserializes a column-major dense matrix from the archive and reconstitutes the given sparse matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a row-major dense matrix from the archive.
| archive | The archive to be read from. |
| mat | The dense matrix to be reconstituted. |
| std::runtime_error | Dense matrix could not be deserialized. |
This function deserializes a row-major dense matrix from the archive and reconstitutes the given row-major dense matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a row-major dense matrix from the archive.
| archive | The archive to be read from. |
| mat | The dense matrix to be reconstituted. |
| std::runtime_error | Dense matrix could not be deserialized. |
This function deserializes a row-major dense matrix from the archive and reconstitutes the given dense matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a row-major dense matrix from the archive.
| archive | The archive to be read from. |
| mat | The dense matrix to be reconstituted. |
| std::runtime_error | Sparse matrix could not be deserialized. |
This function deserializes a row-major dense matrix from the archive and reconstitutes the given sparse matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a row-major dense matrix from the archive.
| archive | The archive to be read from. |
| mat | The dense matrix to be reconstituted. |
| std::runtime_error | Sparse matrix could not be deserialized. |
This function deserializes a row-major dense matrix from the archive and reconstitutes the given sparse matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes all meta information about the given matrix.
| archive | The archive to be read from. |
| mat | The matrix to be deserialized. |
| std::runtime_error | Error during deserialization. |
|
private |
Deserializes a matrix from the archive.
| archive | The archive to be read from. |
| mat | The matrix to be reconstituted. |
| std::runtime_error | Error during deserialization. |
This function deserializes the contents of the matrix from the archive and reconstitutes the given matrix.
|
private |
Deserializes a column-major sparse matrix from the archive.
| archive | The archive to be read from. |
| mat | The matrix to be reconstituted. |
| std::runtime_error | Dense matrix could not be deserialized. |
This function deserializes a column-major sparse matrix from the archive and reconstitutes the given dense matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a column-major sparse matrix from the archive.
| archive | The archive to be read from. |
| mat | The matrix to be reconstituted. |
| std::runtime_error | Sparse matrix could not be deserialized. |
This function deserializes a column-major sparse matrix from the archive and reconstitutes the given column-major sparse matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a column-major sparse matrix from the archive.
| archive | The archive to be read from. |
| mat | The matrix to be reconstituted. |
| std::runtime_error | Sparse matrix could not be deserialized. |
This function deserializes a column-major sparse matrix from the archive and reconstitutes the given row-major sparse matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a row-major sparse matrix from the archive.
| archive | The archive to be read from. |
| mat | The matrix to be reconstituted. |
| std::runtime_error | Dense matrix could not be deserialized. |
This function deserializes a row-major sparse matrix from the archive and reconstitutes the given dense matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a row-major sparse matrix from the archive.
| archive | The archive to be read from. |
| mat | The matrix to be reconstituted. |
| std::runtime_error | Sparse matrix could not be deserialized. |
This function deserializes a row-major sparse matrix from the archive and reconstitutes the given column-major sparse matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Deserializes a row-major sparse matrix from the archive.
| archive | The archive to be read from. |
| mat | The matrix to be reconstituted. |
| std::runtime_error | Sparse matrix could not be deserialized. |
This function deserializes a row-major sparse matrix from the archive and reconstitutes the given row-major sparse matrix. In case any error is detected during the deserialization process, a std::runtime_error is thrown.
|
private |
Prepares the given non-resizable dense matrix for the deserialization process.
| mat | The dense matrix to be prepared. |
|
private |
Prepares the given resizable matrix for the deserialization process.
| mat | The matrix to be prepared. |
|
private |
Prepares the given non-resizable sparse matrix for the deserialization process.
| mat | The sparse matrix to be prepared. |
| void blaze::MatrixSerializer::serialize | ( | Archive & | archive, |
| const Matrix< MT, SO > & | mat ) |
Serializes the given matrix and writes it to the archive.
| archive | The archive to be written. |
| mat | The matrix to be serialized. |
| std::runtime_error | Error during serialization. |
|
private |
Serializes all meta information about the given matrix.
| archive | The archive to be written. |
| mat | The matrix to be serialized. |
| std::runtime_error | File header could not be serialized. |
|
private |
Serializes the elements of a dense matrix.
| archive | The archive to be written. |
| mat | The matrix to be serialized. |
| std::runtime_error | Dense matrix could not be serialized. |
|
private |
Serializes the elements of a sparse matrix.
| archive | The archive to be written. |
| mat | The matrix to be serialized. |
| std::runtime_error | Sparse matrix could not be serialized. |