Blaze 3.9
MatrixSerializer.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_SERIALIZATION_MATRIXSERIALIZER_H_
36#define _BLAZE_MATH_SERIALIZATION_MATRIXSERIALIZER_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
55#include <blaze/util/Assert.h>
56#include <blaze/util/EnableIf.h>
57#include <blaze/util/Types.h>
59
60
61namespace blaze {
62
63//=================================================================================================
64//
65// CLASS DEFINITION
66//
67//=================================================================================================
68
69//*************************************************************************************************
158{
159 private:
160 //**Private class MatrixValueMappingHelper******************************************************
174 template< bool IsDenseMatrix, bool IsRowMajorMatrix >
175 struct MatrixValueMappingHelper;
177 //**********************************************************************************************
178
179 //**Private class MatrixValueMapping************************************************************
187 template< typename T >
188 struct MatrixValueMapping
189 {
190 enum { value = MatrixValueMappingHelper< IsDenseMatrix_v<T>, IsRowMajorMatrix_v<T> >::value };
192 };
194 //**********************************************************************************************
195
196 public:
197 //**Constructors********************************************************************************
200 inline MatrixSerializer();
202 //**********************************************************************************************
203
204 //**Serialization functions*********************************************************************
207 template< typename Archive, typename MT, bool SO >
208 void serialize( Archive& archive, const Matrix<MT,SO>& mat );
210 //**********************************************************************************************
211
212 //**Deserialization functions*******************************************************************
215 template< typename Archive, typename MT, bool SO >
216 void deserialize( Archive& archive, Matrix<MT,SO>& mat );
218 //**********************************************************************************************
219
220 private:
221 //**Serialization functions*********************************************************************
224 template< typename Archive, typename MT >
225 void serializeHeader( Archive& archive, const MT& mat );
226
227 template< typename Archive, typename MT, bool SO >
228 void serializeMatrix( Archive& archive, const DenseMatrix<MT,SO>& mat );
229
230 template< typename Archive, typename MT, bool SO >
231 void serializeMatrix( Archive& archive, const SparseMatrix<MT,SO>& mat );
233 //**********************************************************************************************
234
235 //**Deserialization functions*******************************************************************
238 template< typename Archive, typename MT >
239 void deserializeHeader( Archive& archive, const MT& mat );
240
241 template< typename MT, bool SO >
243
244 template< typename MT, bool SO >
246
247 template< typename MT >
249
250 template< typename Archive, typename MT >
251 void deserializeMatrix( Archive& archive, MT& mat );
252
253 template< typename Archive, typename MT >
256
257 template< typename Archive, typename MT, bool SO >
259
260 template< typename Archive, typename MT, bool SO >
263
264 template< typename Archive, typename MT, bool SO >
267
268 template< typename Archive, typename MT >
271
272 template< typename Archive, typename MT, bool SO >
274
275 template< typename Archive, typename MT, bool SO >
278
279 template< typename Archive, typename MT, bool SO >
282
283 template< typename Archive, typename MT, bool SO >
285
286 template< typename Archive, typename MT >
288
289 template< typename Archive, typename MT >
291
292 template< typename Archive, typename MT, bool SO >
294
295 template< typename Archive, typename MT >
297
298 template< typename Archive, typename MT >
301 //**********************************************************************************************
302
303 //**Member variables****************************************************************************
306 uint8_t version_;
307 uint8_t type_;
308 uint8_t elementType_;
309 uint8_t elementSize_;
310 uint64_t rows_;
311 uint64_t columns_;
312 uint64_t number_;
314 //**********************************************************************************************
315};
316//*************************************************************************************************
317
318
319
320
321//=================================================================================================
322//
323// CONSTRUCTORS
324//
325//=================================================================================================
326
327//*************************************************************************************************
331 : version_ ( 0U ) // The version of the archive
332 , type_ ( 0U ) // The type of the matrix
333 , elementType_( 0U ) // The type of an element
334 , elementSize_( 0U ) // The size in bytes of a single element of the matrix
335 , rows_ ( 0UL ) // The number of rows of the matrix
336 , columns_ ( 0UL ) // The number of columns of the matrix
337 , number_ ( 0UL ) // The total number of elements contained in the matrix
338{}
339//*************************************************************************************************
340
341
342
343
344//=================================================================================================
345//
346// SERIALIZATION FUNCTIONS
347//
348//=================================================================================================
349
350//*************************************************************************************************
358template< typename Archive // Type of the archive
359 , typename MT // Type of the matrix
360 , bool SO > // Storage order
362{
363 if( !archive ) {
364 BLAZE_THROW_RUNTIME_ERROR( "Faulty archive detected" );
365 }
366
367 serializeHeader( archive, *mat );
368 serializeMatrix( archive, *mat );
369}
370//*************************************************************************************************
371
372
373//*************************************************************************************************
381template< typename Archive // Type of the archive
382 , typename MT > // Type of the matrix
383void MatrixSerializer::serializeHeader( Archive& archive, const MT& mat )
384{
385 using ET = ElementType_t<MT>;
386
387 archive << uint8_t ( 1U );
388 archive << uint8_t ( MatrixValueMapping<MT>::value );
389 archive << uint8_t ( TypeValueMapping<ET>::value );
390 archive << uint8_t ( sizeof( ET ) );
391 archive << uint64_t( mat.rows() );
392 archive << uint64_t( mat.columns() );
393 archive << uint64_t( ( IsDenseMatrix_v<MT> ) ? ( mat.rows()*mat.columns() ) : ( mat.nonZeros() ) );
394
395 if( !archive ) {
396 BLAZE_THROW_RUNTIME_ERROR( "File header could not be serialized" );
397 }
398}
399//*************************************************************************************************
400
401
402//*************************************************************************************************
410template< typename Archive // Type of the archive
411 , typename MT // Type of the matrix
412 , bool SO > // Storage order
414{
415 if( IsRowMajorMatrix_v<MT> ) {
416 for( size_t i=0UL; i<(*mat).rows(); ++i ) {
417 for( size_t j=0UL; j<(*mat).columns(); ++j ) {
418 archive << (*mat)(i,j);
419 }
420 }
421 }
422 else {
423 for( size_t j=0UL; j<(*mat).columns(); ++j ) {
424 for( size_t i=0UL; i<(*mat).rows(); ++i ) {
425 archive << (*mat)(i,j);
426 }
427 }
428 }
429
430 if( !archive ) {
431 BLAZE_THROW_RUNTIME_ERROR( "Dense matrix could not be serialized" );
432 }
433}
434//*************************************************************************************************
435
436
437//*************************************************************************************************
445template< typename Archive // Type of the archive
446 , typename MT // Type of the matrix
447 , bool SO > // Storage order
449{
450 if( IsRowMajorMatrix_v<MT> ) {
451 for( size_t i=0UL; i<(*mat).rows(); ++i ) {
452 archive << uint64_t( (*mat).nonZeros( i ) );
453 for( auto element=(*mat).begin(i); element!=(*mat).end(i); ++element ) {
454 archive << element->index() << element->value();
455 }
456 }
457 }
458 else {
459 for( size_t j=0UL; j<(*mat).columns(); ++j ) {
460 archive << uint64_t( (*mat).nonZeros( j ) );
461 for( auto element=(*mat).begin(j); element!=(*mat).end(j); ++element ) {
462 archive << element->index() << element->value();
463 }
464 }
465 }
466
467 if( !archive ) {
468 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be serialized" );
469 }
470}
471//*************************************************************************************************
472
473
474
475
476//=================================================================================================
477//
478// DESERIALIZATION FUNCTIONS
479//
480//=================================================================================================
481
482//*************************************************************************************************
490template< typename Archive // Type of the archive
491 , typename MT // Type of the matrix
492 , bool SO > // Storage order
494{
495 if( !archive ) {
496 BLAZE_THROW_INVALID_ARGUMENT( "Faulty archive detected" );
497 }
498
499 deserializeHeader( archive, *mat );
500 prepareMatrix( *mat );
501 deserializeMatrix( archive, *mat );
502}
503//*************************************************************************************************
504
505
506//*************************************************************************************************
514template< typename Archive // Type of the archive
515 , typename MT > // Type of the matrix
516void MatrixSerializer::deserializeHeader( Archive& archive, const MT& mat )
517{
518 using ET = ElementType_t<MT>;
519
520 if( !( archive >> version_ >> type_ >> elementType_ >> elementSize_ >> rows_ >> columns_ >> number_ ) ) {
521 BLAZE_THROW_RUNTIME_ERROR( "Corrupt archive detected" );
522 }
523 else if( version_ != 1UL ) {
524 BLAZE_THROW_RUNTIME_ERROR( "Invalid version detected" );
525 }
526 else if( ( type_ & 1U ) != 1U || ( type_ & (~7U) ) != 0U ) {
527 BLAZE_THROW_RUNTIME_ERROR( "Invalid matrix type detected" );
528 }
530 BLAZE_THROW_RUNTIME_ERROR( "Invalid element type detected" );
531 }
532 else if( elementSize_ != sizeof( ET ) ) {
533 BLAZE_THROW_RUNTIME_ERROR( "Invalid element size detected" );
534 }
535 else if( !IsResizable_v<MT> && ( rows_ != mat.rows() || columns_ != mat.columns() ) ) {
536 BLAZE_THROW_RUNTIME_ERROR( "Invalid matrix size detected" );
537 }
538 else if( number_ > rows_*columns_ ) {
539 BLAZE_THROW_RUNTIME_ERROR( "Invalid number of elements detected" );
540 }
541}
542//*************************************************************************************************
543
544
545//*************************************************************************************************
551template< typename MT // Type of the dense matrix
552 , bool SO > // Storage order
554{
555 reset( *mat );
556}
557//*************************************************************************************************
558
559
560//*************************************************************************************************
566template< typename MT // Type of the sparse matrix
567 , bool SO > // Storage order
569{
570 (*mat).reserve( number_ );
571 reset( *mat );
572}
573//*************************************************************************************************
574
575
576//*************************************************************************************************
582template< typename MT > // Type of the matrix
584{
585 mat.resize ( rows_, columns_, false );
586 mat.reserve( number_ );
587 reset( mat );
588}
589//*************************************************************************************************
590
591
592//*************************************************************************************************
603template< typename Archive // Type of the archive
604 , typename MT > // Type of the matrix
606{
607 if( type_ == 1U ) {
608 deserializeDenseRowMatrix( archive, *mat );
609 }
610 else if( type_ == 5UL ) {
611 deserializeDenseColumnMatrix( archive, *mat );
612 }
613 else if( type_ == 3UL ) {
614 deserializeSparseRowMatrix( archive, *mat );
615 }
616 else if( type_ == 7UL ) {
617 deserializeSparseColumnMatrix( archive, *mat );
618 }
619 else {
620 BLAZE_INTERNAL_ASSERT( false, "Undefined type flag" );
621 }
622}
623//*************************************************************************************************
624
625
626//*************************************************************************************************
638template< typename Archive // Type of the archive
639 , typename MT > // Type of the matrix
642{
643 if( columns_ == 0UL ) return;
644
645 for( size_t i=0UL; i<rows_; ++i ) {
646 archive.read( &(*mat)(i,0), columns_ );
647 }
648
649 if( !archive ) {
650 BLAZE_THROW_RUNTIME_ERROR( "Dense matrix could not be deserialized" );
651 }
652}
653//*************************************************************************************************
654
655
656//*************************************************************************************************
668template< typename Archive // Type of the archive
669 , typename MT // Type of the matrix
670 , bool SO > // Storage order
672{
673 using ET = ElementType_t<MT>;
674
675 ET value{};
676
677 for( size_t i=0UL; i<rows_; ++i ) {
678 size_t j( 0UL );
679 while( ( j != columns_ ) && ( archive >> value ) ) {
680 (*mat)(i,j) = value;
681 ++j;
682 }
683 }
684
685 if( !archive ) {
686 BLAZE_THROW_RUNTIME_ERROR( "Dense matrix could not be deserialized" );
687 }
688}
689//*************************************************************************************************
690
691
692//*************************************************************************************************
704template< typename Archive // Type of the archive
705 , typename MT // Type of the matrix
706 , bool SO > // Storage order
709{
711 deserializeDenseRowMatrix( archive, tmp );
712 (*mat) = tmp;
713
714 if( !archive ) {
715 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be deserialized" );
716 }
717}
718//*************************************************************************************************
719
720
721//*************************************************************************************************
733template< typename Archive // Type of the archive
734 , typename MT // Type of the matrix
735 , bool SO > // Storage order
738{
739 using ET = ElementType_t<MT>;
740
741 ET value{};
742
743 const size_t dim1( ( SO == rowMajor )?( rows_ ):( columns_ ) );
744 const size_t dim2( ( SO != rowMajor )?( rows_ ):( columns_ ) );
745
746 for( size_t i=0UL; i<dim1; ++i ) {
747 (*mat).reserve( i, dim2 );
748 }
749
750 for( size_t i=0UL; i<rows_; ++i ) {
751 size_t j( 0UL );
752 while( ( j != columns_ ) && ( archive >> value ) ) {
753 (*mat).append( i, j, value, false );
754 ++j;
755 }
756 }
757
758 if( !archive ) {
759 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be deserialized" );
760 }
761}
762//*************************************************************************************************
763
764
765//*************************************************************************************************
777template< typename Archive // Type of the archive
778 , typename MT > // Type of the matrix
781{
782 if( rows_ == 0UL ) return;
783
784 for( size_t j=0UL; j<columns_; ++j ) {
785 archive.read( &(*mat)(0,j), rows_ );
786 }
787
788 if( !archive ) {
789 BLAZE_THROW_RUNTIME_ERROR( "Dense matrix could not be deserialized" );
790 }
791}
792//*************************************************************************************************
793
794
795//*************************************************************************************************
807template< typename Archive // Type of the archive
808 , typename MT // Type of the matrix
809 , bool SO > // Storage order
811{
812 using ET = ElementType_t<MT>;
813
814 ET value{};
815
816 for( size_t j=0UL; j<columns_; ++j ) {
817 size_t i( 0UL );
818 while( ( i != rows_ ) && ( archive >> value ) ) {
819 (*mat)(i,j) = value;
820 ++i;
821 }
822 }
823
824 if( !archive ) {
825 BLAZE_THROW_RUNTIME_ERROR( "Dense matrix could not be deserialized" );
826 }
827}
828//*************************************************************************************************
829
830
831//*************************************************************************************************
843template< typename Archive // Type of the archive
844 , typename MT // Type of the matrix
845 , bool SO > // Storage order
848{
850 deserializeDenseColumnMatrix( archive, tmp );
851 (*mat) = tmp;
852
853 if( !archive ) {
854 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be deserialized" );
855 }
856}
857//*************************************************************************************************
858
859
860//*************************************************************************************************
872template< typename Archive // Type of the archive
873 , typename MT // Type of the matrix
874 , bool SO > // Storage order
877{
878 using ET = ElementType_t<MT>;
879
880 ET value{};
881
882 const size_t dim1( ( SO == rowMajor )?( rows_ ):( columns_ ) );
883 const size_t dim2( ( SO != rowMajor )?( rows_ ):( columns_ ) );
884
885 for( size_t i=0UL; i<dim1; ++i ) {
886 (*mat).reserve( i, dim2 );
887 }
888
889 for( size_t j=0UL; j<columns_; ++j ) {
890 size_t i( 0UL );
891 while( ( i != rows_ ) && ( archive >> value ) ) {
892 (*mat).append( i, j, value, false );
893 ++i;
894 }
895 }
896
897 if( !archive ) {
898 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be deserialized" );
899 }
900}
901//*************************************************************************************************
902
903
904//*************************************************************************************************
916template< typename Archive // Type of the archive
917 , typename MT // Type of the matrix
918 , bool SO > // Storage order
920{
921 using ET = ElementType_t<MT>;
922
923 uint64_t number( 0UL );
924 size_t index ( 0UL );
925 ET value {};
926
927 for( size_t i=0UL; i<rows_; ++i ) {
928 archive >> number;
929 size_t j( 0UL );
930 while( ( j != number ) && ( archive >> index >> value ) ) {
931 (*mat)(i,index) = value;
932 ++j;
933 }
934 }
935
936 if( !archive ) {
937 BLAZE_THROW_RUNTIME_ERROR( "Dense matrix could not be deserialized" );
938 }
939}
940//*************************************************************************************************
941
942
943//*************************************************************************************************
955template< typename Archive // Type of the archive
956 , typename MT > // Type of the matrix
958{
959 using ET = ElementType_t<MT>;
960
961 uint64_t number( 0UL );
962 size_t index ( 0UL );
963 ET value {};
964
965 for( size_t i=0UL; i<rows_; ++i )
966 {
967 archive >> number;
968
969 size_t j( 0UL );
970 while( ( j != number ) && ( archive >> index >> value ) ) {
971 (*mat).append( i, index, value, false );
972 ++j;
973 }
974
975 (*mat).finalize( i );
976 }
977
978 if( !archive ) {
979 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be deserialized" );
980 }
981}
982//*************************************************************************************************
983
984
985//*************************************************************************************************
997template< typename Archive // Type of the archive
998 , typename MT > // Type of the matrix
1000{
1002 deserializeSparseRowMatrix( archive, tmp );
1003 (*mat) = tmp;
1004
1005 if( !archive ) {
1006 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be deserialized" );
1007 }
1008}
1009//*************************************************************************************************
1010
1011
1012//*************************************************************************************************
1024template< typename Archive // Type of the archive
1025 , typename MT // Type of the matrix
1026 , bool SO > // Storage order
1028{
1029 using ET = ElementType_t<MT>;
1030
1031 uint64_t number( 0UL );
1032 size_t index ( 0UL );
1033 ET value {};
1034
1035 for( size_t j=0UL; j<columns_; ++j ) {
1036 archive >> number;
1037 size_t i( 0UL );
1038 while( ( i != number ) && ( archive >> index >> value ) ) {
1039 (*mat)(index,j) = value;
1040 ++i;
1041 }
1042 }
1043
1044 if( !archive ) {
1045 BLAZE_THROW_RUNTIME_ERROR( "Dense matrix could not be deserialized" );
1046 }
1047}
1048//*************************************************************************************************
1049
1050
1051//*************************************************************************************************
1063template< typename Archive // Type of the archive
1064 , typename MT > // Type of the matrix
1066{
1068 deserializeSparseColumnMatrix( archive, tmp );
1069 (*mat) = tmp;
1070
1071 if( !archive ) {
1072 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be deserialized" );
1073 }
1074}
1075//*************************************************************************************************
1076
1077
1078//*************************************************************************************************
1090template< typename Archive // Type of the archive
1091 , typename MT > // Type of the matrix
1093{
1094 using ET = ElementType_t<MT>;
1095
1096 uint64_t number( 0UL );
1097 size_t index ( 0UL );
1098 ET value {};
1099
1100 for( size_t j=0UL; j<columns_; ++j )
1101 {
1102 archive >> number;
1103
1104 size_t i( 0UL );
1105 while( ( i != number ) && ( archive >> index >> value ) ) {
1106 (*mat).append( index, j, value, false );
1107 ++i;
1108 }
1109
1110 (*mat).finalize( j );
1111 }
1112
1113 if( !archive ) {
1114 BLAZE_THROW_RUNTIME_ERROR( "Sparse matrix could not be deserialized" );
1115 }
1116}
1117//*************************************************************************************************
1118
1119
1120
1121
1122//=================================================================================================
1123//
1124// MATRIXVALUEMAPPINGHELPER SPECIALIZATIONS
1125//
1126//=================================================================================================
1127
1128//*************************************************************************************************
1132template<>
1133struct MatrixSerializer::MatrixValueMappingHelper<true,true>
1134{
1135 enum { value = 1 };
1136};
1138//*************************************************************************************************
1139
1140
1141//*************************************************************************************************
1145template<>
1146struct MatrixSerializer::MatrixValueMappingHelper<true,false>
1147{
1148 enum { value = 5 };
1149};
1151//*************************************************************************************************
1152
1153
1154//*************************************************************************************************
1158template<>
1159struct MatrixSerializer::MatrixValueMappingHelper<false,true>
1160{
1161 enum { value = 3 };
1162};
1164//*************************************************************************************************
1165
1166
1167//*************************************************************************************************
1171template<>
1172struct MatrixSerializer::MatrixValueMappingHelper<false,false>
1173{
1174 enum { value = 7 };
1175};
1177//*************************************************************************************************
1178
1179
1180
1181
1182//=================================================================================================
1183//
1184// GLOBAL FUNCTIONS
1185//
1186//=================================================================================================
1187
1188//*************************************************************************************************
1253template< typename Archive // Type of the archive
1254 , typename MT // Type of the matrix
1255 , bool SO > // Storage order
1256void serialize( Archive& archive, const Matrix<MT,SO>& mat )
1257{
1258 MatrixSerializer().serialize( archive, *mat );
1259}
1260//*************************************************************************************************
1261
1262
1263//*************************************************************************************************
1275template< typename Archive // Type of the archive
1276 , typename MT // Type of the matrix
1277 , bool SO > // Storage order
1278void deserialize( Archive& archive, Matrix<MT,SO>& mat )
1279{
1280 MatrixSerializer().deserialize( archive, *mat );
1281}
1282//*************************************************************************************************
1283
1284} // namespace blaze
1285
1286#endif
Header file for auxiliary alias declarations.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the IsDenseMatrix type trait.
Header file for the IsNumeric type trait.
Header file for the IsResizable type trait.
Header file for the IsRowMajorMatrix type trait.
void serialize(Archive &archive, const Matrix< MT, SO > &mat)
Serializes the given matrix and writes it to the archive.
Definition: MatrixSerializer.h:1256
void deserialize(Archive &archive, Matrix< MT, SO > &mat)
Deserializes a matrix from the given archive.
Definition: MatrixSerializer.h:1278
Header file for the TypeValueMapping class template.
Binary archive for the portable serialization of data.
Definition: Archive.h:140
Efficient implementation of a compressed matrix.
Definition: CompressedMatrix.h:239
Base class for dense matrices.
Definition: DenseMatrix.h:82
Efficient implementation of a dynamic matrix.
Definition: DynamicMatrix.h:242
Serializer for dense and sparse matrices.
Definition: MatrixSerializer.h:158
DisableIf_t< IsResizable_v< MT > > prepareMatrix(DenseMatrix< MT, SO > &mat)
Prepares the given non-resizable dense matrix for the deserialization process.
Definition: MatrixSerializer.h:553
EnableIf_t< MT::simdEnabled > deserializeDenseRowMatrix(Archive &archive, DenseMatrix< MT, rowMajor > &mat)
Deserializes a row-major dense matrix from the archive.
Definition: MatrixSerializer.h:641
void serializeHeader(Archive &archive, const MT &mat)
Serializes all meta information about the given matrix.
Definition: MatrixSerializer.h:383
uint64_t columns_
The number of columns of the matrix.
Definition: MatrixSerializer.h:311
uint8_t elementType_
The type of an element.
Definition: MatrixSerializer.h:308
void deserialize(Archive &archive, Matrix< MT, SO > &mat)
Deserializes a matrix from the given archive.
Definition: MatrixSerializer.h:493
uint8_t elementSize_
The size in bytes of a single element of the matrix.
Definition: MatrixSerializer.h:309
uint64_t rows_
The number of rows of the matrix.
Definition: MatrixSerializer.h:310
EnableIf_t< MT::simdEnabled > deserializeDenseColumnMatrix(Archive &archive, DenseMatrix< MT, columnMajor > &mat)
Deserializes a column-major dense matrix from the archive.
Definition: MatrixSerializer.h:780
uint8_t type_
The type of the matrix.
Definition: MatrixSerializer.h:307
void serialize(Archive &archive, const Matrix< MT, SO > &mat)
Serializes the given matrix and writes it to the archive.
Definition: MatrixSerializer.h:361
uint8_t version_
The version of the archive.
Definition: MatrixSerializer.h:306
MatrixSerializer()
The default constructor of the MatrixSerializer class.
Definition: MatrixSerializer.h:330
void deserializeHeader(Archive &archive, const MT &mat)
Deserializes all meta information about the given matrix.
Definition: MatrixSerializer.h:516
void deserializeSparseRowMatrix(Archive &archive, DenseMatrix< MT, SO > &mat)
Deserializes a row-major sparse matrix from the archive.
Definition: MatrixSerializer.h:919
void deserializeSparseColumnMatrix(Archive &archive, DenseMatrix< MT, SO > &mat)
Deserializes a column-major sparse matrix from the archive.
Definition: MatrixSerializer.h:1027
void serializeMatrix(Archive &archive, const DenseMatrix< MT, SO > &mat)
Serializes the elements of a dense matrix.
Definition: MatrixSerializer.h:413
void deserializeMatrix(Archive &archive, MT &mat)
Deserializes a matrix from the archive.
Definition: MatrixSerializer.h:605
uint64_t number_
The total number of elements contained in the matrix.
Definition: MatrixSerializer.h:312
Base class for matrices.
Definition: Matrix.h:85
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Constraint on the data type.
Header file for the implementation of a dynamic MxN matrix.
Header file for the DenseMatrix base class.
Header file for the Matrix base class.
Header file for the SparseMatrix base class.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Matrix.h:61
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_THROW_RUNTIME_ERROR(MESSAGE)
Macro for the emission of a std::runtime_error exception.
Definition: Exception.h:379
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:175
Header file for the exception macros of the math module.
constexpr bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
constexpr bool columnMajor
Storage order flag for column-major matrices.
Definition: StorageOrder.h:99
Implementation of a compressed MxN matrix.
Conversion from a data type to a serial representation.
Definition: TypeValueMapping.h:164
Header file for basic type definitions.