35 #ifndef _BLAZE_MATH_SERIALIZATION_MATRIXSERIALIZER_H_ 36 #define _BLAZE_MATH_SERIALIZATION_MATRIXSERIALIZER_H_ 175 template<
bool IsDenseMatrix,
bool IsRowMajorMatrix >
176 struct MatrixValueMappingHelper;
188 template<
typename T >
189 struct MatrixValueMapping
217 template<
typename Archive,
typename MT,
bool SO >
225 template<
typename Archive,
typename MT,
bool SO >
234 template<
typename Archive,
typename MT >
237 template<
typename Archive,
typename MT,
bool SO >
240 template<
typename Archive,
typename MT,
bool SO >
248 template<
typename Archive,
typename MT >
251 template<
typename MT,
bool SO >
254 template<
typename MT,
bool SO >
257 template<
typename MT >
260 template<
typename Archive,
typename MT >
263 template<
typename Archive,
typename MT >
267 template<
typename Archive,
typename MT,
bool SO >
270 template<
typename Archive,
typename MT,
bool SO >
274 template<
typename Archive,
typename MT,
bool SO >
278 template<
typename Archive,
typename MT >
282 template<
typename Archive,
typename MT,
bool SO >
285 template<
typename Archive,
typename MT,
bool SO >
289 template<
typename Archive,
typename MT,
bool SO >
293 template<
typename Archive,
typename MT,
bool SO >
296 template<
typename Archive,
typename MT >
299 template<
typename Archive,
typename MT >
302 template<
typename Archive,
typename MT,
bool SO >
305 template<
typename Archive,
typename MT >
308 template<
typename Archive,
typename MT >
398 archive << uint8_t ( MatrixValueMapping<MT>::value );
399 archive << uint8_t ( TypeValueMapping<ET>::value );
400 archive << uint8_t (
sizeof( ET ) );
402 archive <<
uint64_t( mat.columns() );
403 archive << uint64_t( ( IsDenseMatrix<MT>::value ) ? ( mat.rows()*mat.columns() ) : ( mat.nonZeros() ) );
426 for(
size_t i=0UL; i<(~mat).
rows(); ++i ) {
427 for(
size_t j=0UL; j<(~mat).
columns(); ++j ) {
428 archive << (~mat)(i,j);
433 for(
size_t j=0UL; j<(~mat).
columns(); ++j ) {
434 for(
size_t i=0UL; i<(~mat).
rows(); ++i ) {
435 archive << (~mat)(i,j);
463 for(
size_t i=0UL; i<(~mat).
rows(); ++i ) {
466 archive << element->index() << element->value();
471 for(
size_t j=0UL; j<(~mat).
columns(); ++j ) {
474 archive << element->index() << element->value();
538 else if( (
type_ & 1U ) != 1U || (
type_ & (~7U) ) != 0U ) {
563 template<
typename MT
578 template<
typename MT
594 template<
typename MT >
622 else if(
type_ == 5UL ) {
625 else if(
type_ == 3UL ) {
628 else if(
type_ == 7UL ) {
657 for(
size_t i=0UL; i<
rows_; ++i ) {
658 archive.read( &(~mat)(i,0),
columns_ );
689 for(
size_t i=0UL; i<
rows_; ++i ) {
691 while( ( j !=
columns_ ) && ( archive >> value ) ) {
758 for(
size_t i=0UL; i<dim1; ++i ) {
759 (~mat).reserve( i, dim2 );
762 for(
size_t i=0UL; i<
rows_; ++i ) {
764 while( ( j !=
columns_ ) && ( archive >> value ) ) {
765 (~mat).append( i, j, value,
false );
794 if(
rows_ == 0UL )
return;
796 for(
size_t j=0UL; j<
columns_; ++j ) {
797 archive.read( &(~mat)(0,j),
rows_ );
828 for(
size_t j=0UL; j<
columns_; ++j ) {
830 while( ( i !=
rows_ ) && ( archive >> value ) ) {
897 for(
size_t i=0UL; i<dim1; ++i ) {
898 (~mat).reserve( i, dim2 );
901 for(
size_t j=0UL; j<
columns_; ++j ) {
903 while( ( i !=
rows_ ) && ( archive >> value ) ) {
904 (~mat).append( i, j, value,
false );
936 size_t index ( 0UL );
939 for(
size_t i=0UL; i<
rows_; ++i ) {
942 while( ( j != number ) && ( archive >> index >> value ) ) {
943 (~mat)(i,index) = value;
974 size_t index ( 0UL );
977 for(
size_t i=0UL; i<
rows_; ++i )
982 while( ( j != number ) && ( archive >> index >> value ) ) {
983 (~mat).append( i, index, value,
false );
987 (~mat).finalize( i );
1044 size_t index ( 0UL );
1047 for(
size_t j=0UL; j<
columns_; ++j ) {
1050 while( ( i != number ) && ( archive >> index >> value ) ) {
1051 (~mat)(index,j) = value;
1109 size_t index ( 0UL );
1112 for(
size_t j=0UL; j<
columns_; ++j )
1117 while( ( i != number ) && ( archive >> index >> value ) ) {
1118 (~mat).append( index, j, value,
false );
1122 (~mat).finalize( j );
1145 struct MatrixSerializer::MatrixValueMappingHelper<true,true>
1158 struct MatrixSerializer::MatrixValueMappingHelper<true,false>
1171 struct MatrixSerializer::MatrixValueMappingHelper<false,true>
1184 struct MatrixSerializer::MatrixValueMappingHelper<false,false>
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
void deserializeHeader(Archive &archive, const MT &mat)
Deserializes all meta information about the given matrix.
Definition: MatrixSerializer.h:528
Binary archive for the portable serialization of data.The Archive class implements the functionality ...
Definition: Archive.h:141
Header file for basic type definitions.
const bool columnMajor
Storage order flag for column-major matrices.
Definition: StorageOrder.h:99
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:221
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
8-bit unsigned integer type of the Blaze library.
Implementation of a compressed MxN matrix.
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:560
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:217
void serializeHeader(Archive &archive, const MT &mat)
Serializes all meta information about the given matrix.
Definition: MatrixSerializer.h:393
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
MatrixSerializer()
The default constructor of the MatrixSerializer class.
Definition: MatrixSerializer.h:340
Header file for the SparseMatrix base class.
#define BLAZE_THROW_RUNTIME_ERROR(MESSAGE)
Macro for the emission of a std::runtime_error exception.This macro encapsulates the default way of B...
Definition: Exception.h:379
void deserializeSparseColumnMatrix(Archive &archive, DenseMatrix< MT, SO > &mat)
Deserializes a column-major sparse matrix from the archive.
Definition: MatrixSerializer.h:1039
void deserializeMatrix(Archive &archive, MT &mat)
Deserializes a matrix from the archive.
Definition: MatrixSerializer.h:617
Header file for the DisableIf class template.
uint8_t type_
The type of the matrix.
Definition: MatrixSerializer.h:317
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
uint8_t elementType_
The type of an element.
Definition: MatrixSerializer.h:318
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:110
void serializeMatrix(Archive &archive, const DenseMatrix< MT, SO > &mat)
Serializes the elements of a dense matrix.
Definition: MatrixSerializer.h:423
DisableIf_< IsResizable< MT > > prepareMatrix(DenseMatrix< MT, SO > &mat)
Prepares the given non-resizable dense matrix for the deserialization process.
Definition: MatrixSerializer.h:565
Constraint on the data type.
Header file for the DenseMatrix base class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
uint64_t rows_
The number of rows of the matrix.
Definition: MatrixSerializer.h:320
Header file for the exception macros of the math module.
Header file for the implementation of a dynamic MxN matrix.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
Header file for the IsDenseMatrix type trait.
Header file for the EnableIf class template.
64-bit unsigned integer type of the Blaze library.
EnableIfTrue_< MT::simdEnabled > deserializeDenseColumnMatrix(Archive &archive, DenseMatrix< MT, columnMajor > &mat)
Deserializes a column-major dense matrix from the archive.
Definition: MatrixSerializer.h:792
Header file for the IsNumeric type trait.
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
Header file for the Matrix base class.
typename EnableIfTrue< Condition, T >::Type EnableIfTrue_
Auxiliary type for the EnableIfTrue class template.The EnableIfTrue_ alias declaration provides a con...
Definition: EnableIf.h:138
Serializer for dense and sparse matrices.The MatrixSerializer implements the necessary logic to seria...
Definition: MatrixSerializer.h:158
Header file for run time assertion macros.
Conversion from a data type to a serial representation.This class template converts the given data ty...
Definition: TypeValueMapping.h:163
void deserializeSparseRowMatrix(Archive &archive, DenseMatrix< MT, SO > &mat)
Deserializes a row-major sparse matrix from the archive.
Definition: MatrixSerializer.h:931
uint64_t columns_
The number of columns of the matrix.
Definition: MatrixSerializer.h:321
void deserialize(Archive &archive, Matrix< MT, SO > &mat)
Deserializes a matrix from the given archive.
Definition: MatrixSerializer.h:505
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:101
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
Header file for the TypeValueMapping class template.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
uint8_t version_
The version of the archive.
Definition: MatrixSerializer.h:316
EnableIfTrue_< MT::simdEnabled > deserializeDenseRowMatrix(Archive &archive, DenseMatrix< MT, rowMajor > &mat)
Deserializes a row-major dense matrix from the archive.
Definition: MatrixSerializer.h:653
void serialize(Archive &archive, const Matrix< MT, SO > &mat)
Serializes the given matrix and writes it to the archive.
Definition: MatrixSerializer.h:371
uint8_t elementSize_
The size in bytes of a single element of the matrix.
Definition: MatrixSerializer.h:319
Header file for the IsRowMajorMatrix type trait.
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a N-dimensional matrix type...
Definition: Matrix.h:61
Header file for the IsResizable type trait.
uint64_t number_
The total number of elements contained in the matrix.
Definition: MatrixSerializer.h:322
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101