All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <stdexcept>
54 #include <blaze/util/Assert.h>
55 #include <blaze/util/DisableIf.h>
56 #include <blaze/util/EnableIf.h>
57 #include <blaze/util/Types.h>
59 
60 
61 namespace 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<T>::value, IsRowMajorMatrix<T>::value >::value };
192  };
194  //**********************************************************************************************
195 
196  public:
197  //**Constructor*********************************************************************************
200  explicit inline MatrixSerializer();
201  // No explicitly declared copy constructor.
203  //**********************************************************************************************
204 
205  //**Destructor**********************************************************************************
206  // No explicitly declared destructor.
207  //**********************************************************************************************
208 
209  //**Assignment operators************************************************************************
210  // No explicitly declared copy assignment operator.
211  //**********************************************************************************************
212 
213  //**Serialization functions*********************************************************************
216  template< typename Archive, typename MT, bool SO >
217  void serialize( Archive& archive, const Matrix<MT,SO>& mat );
219  //**********************************************************************************************
220 
221  //**Deserialization functions*******************************************************************
224  template< typename Archive, typename MT, bool SO >
225  void deserialize( Archive& archive, Matrix<MT,SO>& mat );
227  //**********************************************************************************************
228 
229  private:
230  //**Serialization functions*********************************************************************
233  template< typename Archive, typename MT >
234  void serializeHeader( Archive& archive, const MT& mat );
235 
236  template< typename Archive, typename MT, bool SO >
237  void serializeMatrix( Archive& archive, const DenseMatrix<MT,SO>& mat );
238 
239  template< typename Archive, typename MT, bool SO >
240  void serializeMatrix( Archive& archive, const SparseMatrix<MT,SO>& mat );
242  //**********************************************************************************************
243 
244  //**Deserialization functions*******************************************************************
247  template< typename Archive, typename MT >
248  void deserializeHeader( Archive& archive, const MT& mat );
249 
250  template< typename MT, bool SO >
252 
253  template< typename MT, bool SO >
255 
256  template< typename MT >
257  typename EnableIf< IsResizable<MT> >::Type prepareMatrix( MT& mat );
258 
259  template< typename Archive, typename MT >
260  void deserializeMatrix( Archive& archive, MT& mat );
261 
262  template< typename Archive, typename MT >
265 
266  template< typename Archive, typename MT, bool SO >
268 
269  template< typename Archive, typename MT, bool SO >
272 
273  template< typename Archive, typename MT, bool SO >
276 
277  template< typename Archive, typename MT >
280 
281  template< typename Archive, typename MT, bool SO >
283 
284  template< typename Archive, typename MT, bool SO >
287 
288  template< typename Archive, typename MT, bool SO >
291 
292  template< typename Archive, typename MT, bool SO >
294 
295  template< typename Archive, typename MT >
297 
298  template< typename Archive, typename MT >
300 
301  template< typename Archive, typename MT, bool SO >
303 
304  template< typename Archive, typename MT >
306 
307  template< typename Archive, typename MT >
310  //**********************************************************************************************
311 
312  //**Member variables****************************************************************************
322 
323  //**********************************************************************************************
324 };
325 //*************************************************************************************************
326 
327 
328 
329 
330 //=================================================================================================
331 //
332 // CONSTRUCTOR
333 //
334 //=================================================================================================
335 
336 //*************************************************************************************************
340  : version_ ( 0U ) // The version of the archive
341  , type_ ( 0U ) // The type of the matrix
342  , elementType_( 0U ) // The type of an element
343  , elementSize_( 0U ) // The size in bytes of a single element of the matrix
344  , rows_ ( 0UL ) // The number of rows of the matrix
345  , columns_ ( 0UL ) // The number of columns of the matrix
346  , number_ ( 0UL ) // The total number of elements contained in the matrix
347 {}
348 //*************************************************************************************************
349 
350 
351 
352 
353 //=================================================================================================
354 //
355 // SERIALIZATION FUNCTIONS
356 //
357 //=================================================================================================
358 
359 //*************************************************************************************************
367 template< typename Archive // Type of the archive
368  , typename MT // Type of the matrix
369  , bool SO > // Storage order
371 {
372  if( !archive ) {
373  throw std::runtime_error( "Faulty archive detected" );
374  }
375 
376  serializeHeader( archive, ~mat );
377  serializeMatrix( archive, ~mat );
378 }
379 //*************************************************************************************************
380 
381 
382 //*************************************************************************************************
390 template< typename Archive // Type of the archive
391  , typename MT > // Type of the matrix
392 void MatrixSerializer::serializeHeader( Archive& archive, const MT& mat )
393 {
394  typedef typename MT::ElementType ET;
395 
396  archive << uint8_t ( 1U );
397  archive << uint8_t ( MatrixValueMapping<MT>::value );
398  archive << uint8_t ( TypeValueMapping<ET>::value );
399  archive << uint8_t ( sizeof( ET ) );
400  archive << uint64_t( mat.rows() );
401  archive << uint64_t( mat.columns() );
402  archive << uint64_t( ( IsDenseMatrix<MT>::value ) ? ( mat.rows()*mat.columns() ) : ( mat.nonZeros() ) );
403 
404  if( !archive ) {
405  throw std::runtime_error( "File header could not be serialized" );
406  }
407 }
408 //*************************************************************************************************
409 
410 
411 //*************************************************************************************************
419 template< typename Archive // Type of the archive
420  , typename MT // Type of the matrix
421  , bool SO > // Storage order
423 {
425  for( size_t i=0UL; i<(~mat).rows(); ++i ) {
426  for( size_t j=0UL; j<(~mat).columns(); ++j ) {
427  archive << (~mat)(i,j);
428  }
429  }
430  }
431  else {
432  for( size_t j=0UL; j<(~mat).columns(); ++j ) {
433  for( size_t i=0UL; i<(~mat).rows(); ++i ) {
434  archive << (~mat)(i,j);
435  }
436  }
437  }
438 
439  if( !archive ) {
440  throw std::runtime_error( "Dense matrix could not be serialized" );
441  }
442 }
443 //*************************************************************************************************
444 
445 
446 //*************************************************************************************************
454 template< typename Archive // Type of the archive
455  , typename MT // Type of the matrix
456  , bool SO > // Storage order
458 {
459  typedef typename MT::ConstIterator ConstIterator;
460 
462  for( size_t i=0UL; i<(~mat).rows(); ++i ) {
463  archive << uint64_t( (~mat).nonZeros( i ) );
464  for( ConstIterator element=(~mat).begin(i); element!=(~mat).end(i); ++element ) {
465  archive << element->index() << element->value();
466  }
467  }
468  }
469  else {
470  for( size_t j=0UL; j<(~mat).columns(); ++j ) {
471  archive << uint64_t( (~mat).nonZeros( j ) );
472  for( ConstIterator element=(~mat).begin(j); element!=(~mat).end(j); ++element ) {
473  archive << element->index() << element->value();
474  }
475  }
476  }
477 
478  if( !archive ) {
479  throw std::runtime_error( "Sparse matrix could not be serialized" );
480  }
481 }
482 //*************************************************************************************************
483 
484 
485 
486 
487 //=================================================================================================
488 //
489 // DESERIALIZATION FUNCTIONS
490 //
491 //=================================================================================================
492 
493 //*************************************************************************************************
501 template< typename Archive // Type of the archive
502  , typename MT // Type of the matrix
503  , bool SO > // Storage order
505 {
506  if( !archive ) {
507  throw std::invalid_argument( "Faulty archive detected" );
508  }
509 
510  deserializeHeader( archive, ~mat );
511  prepareMatrix( ~mat );
512  deserializeMatrix( archive, ~mat );
513 }
514 //*************************************************************************************************
515 
516 
517 //*************************************************************************************************
525 template< typename Archive // Type of the archive
526  , typename MT > // Type of the matrix
527 void MatrixSerializer::deserializeHeader( Archive& archive, const MT& mat )
528 {
529  typedef typename MT::ElementType ET;
530 
531  if( !( archive >> version_ >> type_ >> elementType_ >> elementSize_ >> rows_ >> columns_ >> number_ ) ) {
532  throw std::runtime_error( "Corrupt archive detected" );
533  }
534  else if( version_ != 1UL ) {
535  throw std::runtime_error( "Invalid version detected" );
536  }
537  else if( ( type_ & 1U ) != 1U || ( type_ & (~7U) ) != 0U ) {
538  throw std::runtime_error( "Invalid matrix type detected" );
539  }
541  throw std::runtime_error( "Invalid element type detected" );
542  }
543  else if( elementSize_ != sizeof( ET ) ) {
544  throw std::runtime_error( "Invalid element size detected" );
545  }
546  else if( !IsResizable<MT>::value && ( rows_ != mat.rows() || columns_ != mat.columns() ) ) {
547  throw std::runtime_error( "Invalid matrix size detected" );
548  }
549  else if( number_ > rows_*columns_ ) {
550  throw std::runtime_error( "Invalid number of elements detected" );
551  }
552 }
553 //*************************************************************************************************
554 
555 
556 //*************************************************************************************************
562 template< typename MT // Type of the dense matrix
563  , bool SO > // Storage order
565 {
566  reset( ~mat );
567 }
568 //*************************************************************************************************
569 
570 
571 //*************************************************************************************************
577 template< typename MT // Type of the sparse matrix
578  , bool SO > // Storage order
580 {
581  (~mat).reserve( number_ );
582  reset( ~mat );
583 }
584 //*************************************************************************************************
585 
586 
587 //*************************************************************************************************
593 template< typename MT > // Type of the matrix
595 {
596  mat.resize ( rows_, columns_, false );
597  mat.reserve( number_ );
598  reset( mat );
599 }
600 //*************************************************************************************************
601 
602 
603 //*************************************************************************************************
614 template< typename Archive // Type of the archive
615  , typename MT > // Type of the matrix
617 {
618  if( type_ == 1U ) {
619  deserializeDenseRowMatrix( archive, ~mat );
620  }
621  else if( type_ == 5UL ) {
622  deserializeDenseColumnMatrix( archive, ~mat );
623  }
624  else if( type_ == 3UL ) {
625  deserializeSparseRowMatrix( archive, ~mat );
626  }
627  else if( type_ == 7UL ) {
628  deserializeSparseColumnMatrix( archive, ~mat );
629  }
630  else {
631  BLAZE_INTERNAL_ASSERT( false, "Undefined type flag" );
632  }
633 }
634 //*************************************************************************************************
635 
636 
637 //*************************************************************************************************
649 template< typename Archive // Type of the archive
650  , typename MT > // Type of the matrix
653 {
654  if( columns_ == 0UL ) return;
655 
656  for( size_t i=0UL; i<rows_; ++i ) {
657  archive.read( &(~mat)(i,0), columns_ );
658  }
659 
660  if( !archive ) {
661  throw std::runtime_error( "Dense matrix could not be deserialized" );
662  }
663 }
664 //*************************************************************************************************
665 
666 
667 //*************************************************************************************************
679 template< typename Archive // Type of the archive
680  , typename MT // Type of the matrix
681  , bool SO > // Storage order
683 {
684  typedef typename MT::ElementType ET;
685 
686  ET value = ET();
687 
688  for( size_t i=0UL; i<rows_; ++i ) {
689  size_t j( 0UL );
690  while( ( j != columns_ ) && ( archive >> value ) ) {
691  (~mat)(i,j) = value;
692  ++j;
693  }
694  }
695 
696  if( !archive ) {
697  throw std::runtime_error( "Dense matrix could not be deserialized" );
698  }
699 }
700 //*************************************************************************************************
701 
702 
703 //*************************************************************************************************
715 template< typename Archive // Type of the archive
716  , typename MT // Type of the matrix
717  , bool SO > // Storage order
720 {
722  deserializeDenseRowMatrix( archive, tmp );
723  (~mat) = tmp;
724 
725  if( !archive ) {
726  throw std::runtime_error( "Sparse matrix could not be deserialized" );
727  }
728 }
729 //*************************************************************************************************
730 
731 
732 //*************************************************************************************************
744 template< typename Archive // Type of the archive
745  , typename MT // Type of the matrix
746  , bool SO > // Storage order
749 {
750  typedef typename MT::ElementType ET;
751 
752  ET value = ET();
753 
754  const size_t dim1( ( SO == rowMajor )?( rows_ ):( columns_ ) );
755  const size_t dim2( ( SO != rowMajor )?( rows_ ):( columns_ ) );
756 
757  for( size_t i=0UL; i<dim1; ++i ) {
758  (~mat).reserve( i, dim2 );
759  }
760 
761  for( size_t i=0UL; i<rows_; ++i ) {
762  size_t j( 0UL );
763  while( ( j != columns_ ) && ( archive >> value ) ) {
764  (~mat).append( i, j, value, false );
765  ++j;
766  }
767  }
768 
769  if( !archive ) {
770  throw std::runtime_error( "Sparse matrix could not be deserialized" );
771  }
772 }
773 //*************************************************************************************************
774 
775 
776 //*************************************************************************************************
788 template< typename Archive // Type of the archive
789  , typename MT > // Type of the matrix
792 {
793  if( rows_ == 0UL ) return;
794 
795  for( size_t j=0UL; j<columns_; ++j ) {
796  archive.read( &(~mat)(0,j), rows_ );
797  }
798 
799  if( !archive ) {
800  throw std::runtime_error( "Dense matrix could not be deserialized" );
801  }
802 }
803 //*************************************************************************************************
804 
805 
806 //*************************************************************************************************
818 template< typename Archive // Type of the archive
819  , typename MT // Type of the matrix
820  , bool SO > // Storage order
822 {
823  typedef typename MT::ElementType ET;
824 
825  ET value = ET();
826 
827  for( size_t j=0UL; j<columns_; ++j ) {
828  size_t i( 0UL );
829  while( ( i != rows_ ) && ( archive >> value ) ) {
830  (~mat)(i,j) = value;
831  ++i;
832  }
833  }
834 
835  if( !archive ) {
836  throw std::runtime_error( "Dense matrix could not be deserialized" );
837  }
838 }
839 //*************************************************************************************************
840 
841 
842 //*************************************************************************************************
854 template< typename Archive // Type of the archive
855  , typename MT // Type of the matrix
856  , bool SO > // Storage order
859 {
861  deserializeDenseColumnMatrix( archive, tmp );
862  (~mat) = tmp;
863 
864  if( !archive ) {
865  throw std::runtime_error( "Sparse matrix could not be deserialized" );
866  }
867 }
868 //*************************************************************************************************
869 
870 
871 //*************************************************************************************************
883 template< typename Archive // Type of the archive
884  , typename MT // Type of the matrix
885  , bool SO > // Storage order
888 {
889  typedef typename MT::ElementType ET;
890 
891  ET value = ET();
892 
893  const size_t dim1( ( SO == rowMajor )?( rows_ ):( columns_ ) );
894  const size_t dim2( ( SO != rowMajor )?( rows_ ):( columns_ ) );
895 
896  for( size_t i=0UL; i<dim1; ++i ) {
897  (~mat).reserve( i, dim2 );
898  }
899 
900  for( size_t j=0UL; j<columns_; ++j ) {
901  size_t i( 0UL );
902  while( ( i != rows_ ) && ( archive >> value ) ) {
903  (~mat).append( i, j, value, false );
904  ++i;
905  }
906  }
907 
908  if( !archive ) {
909  throw std::runtime_error( "Sparse matrix could not be deserialized" );
910  }
911 }
912 //*************************************************************************************************
913 
914 
915 //*************************************************************************************************
927 template< typename Archive // Type of the archive
928  , typename MT // Type of the matrix
929  , bool SO > // Storage order
931 {
932  typedef typename MT::ElementType ET;
933 
934  uint64_t number( 0UL );
935  size_t index ( 0UL );
936  ET value = ET();
937 
938  for( size_t i=0UL; i<rows_; ++i ) {
939  archive >> number;
940  size_t j( 0UL );
941  while( ( j != number ) && ( archive >> index >> value ) ) {
942  (~mat)(i,index) = value;
943  ++j;
944  }
945  }
946 
947  if( !archive ) {
948  throw std::runtime_error( "Dense matrix could not be deserialized" );
949  }
950 }
951 //*************************************************************************************************
952 
953 
954 //*************************************************************************************************
966 template< typename Archive // Type of the archive
967  , typename MT > // Type of the matrix
969 {
970  typedef typename MT::ElementType ET;
971 
972  uint64_t number( 0UL );
973  size_t index ( 0UL );
974  ET value = ET();
975 
976  for( size_t i=0UL; i<rows_; ++i )
977  {
978  archive >> number;
979  (~mat).reserve( i, number );
980 
981  size_t j( 0UL );
982  while( ( j != number ) && ( archive >> index >> value ) ) {
983  (~mat).append( i, index, value, false );
984  ++j;
985  }
986  }
987 
988  if( !archive ) {
989  throw std::runtime_error( "Sparse matrix could not be deserialized" );
990  }
991 }
992 //*************************************************************************************************
993 
994 
995 //*************************************************************************************************
1007 template< typename Archive // Type of the archive
1008  , typename MT > // Type of the matrix
1010 {
1012  deserializeSparseRowMatrix( archive, tmp );
1013  (~mat) = tmp;
1014 
1015  if( !archive ) {
1016  throw std::runtime_error( "Sparse matrix could not be deserialized" );
1017  }
1018 }
1019 //*************************************************************************************************
1020 
1021 
1022 //*************************************************************************************************
1034 template< typename Archive // Type of the archive
1035  , typename MT // Type of the matrix
1036  , bool SO > // Storage order
1038 {
1039  typedef typename MT::ElementType ET;
1040 
1041  uint64_t number( 0UL );
1042  size_t index ( 0UL );
1043  ET value = ET();
1044 
1045  for( size_t j=0UL; j<columns_; ++j ) {
1046  archive >> number;
1047  size_t i( 0UL );
1048  while( ( i != number ) && ( archive >> index >> value ) ) {
1049  (~mat)(index,j) = value;
1050  ++i;
1051  }
1052  }
1053 
1054  if( !archive ) {
1055  throw std::runtime_error( "Dense matrix could not be deserialized" );
1056  }
1057 }
1058 //*************************************************************************************************
1059 
1060 
1061 //*************************************************************************************************
1073 template< typename Archive // Type of the archive
1074  , typename MT > // Type of the matrix
1076 {
1078  deserializeSparseColumnMatrix( archive, tmp );
1079  (~mat) = tmp;
1080 
1081  if( !archive ) {
1082  throw std::runtime_error( "Sparse matrix could not be deserialized" );
1083  }
1084 }
1085 //*************************************************************************************************
1086 
1087 
1088 //*************************************************************************************************
1100 template< typename Archive // Type of the archive
1101  , typename MT > // Type of the matrix
1103 {
1104  typedef typename MT::ElementType ET;
1105 
1106  uint64_t number( 0UL );
1107  size_t index ( 0UL );
1108  ET value = ET();
1109 
1110  for( size_t j=0UL; j<columns_; ++j )
1111  {
1112  archive >> number;
1113  (~mat).reserve( j, number );
1114 
1115  size_t i( 0UL );
1116  while( ( i != number ) && ( archive >> index >> value ) ) {
1117  (~mat).append( index, j, value, false );
1118  ++i;
1119  }
1120  }
1121 
1122  if( !archive ) {
1123  throw std::runtime_error( "Sparse matrix could not be deserialized" );
1124  }
1125 }
1126 //*************************************************************************************************
1127 
1128 
1129 
1130 
1131 //=================================================================================================
1132 //
1133 // MATRIXVALUEMAPPINGHELPER SPECIALIZATIONS
1134 //
1135 //=================================================================================================
1136 
1137 //*************************************************************************************************
1141 template<>
1142 struct MatrixSerializer::MatrixValueMappingHelper<true,true>
1143 {
1144  enum { value = 1 };
1145 };
1147 //*************************************************************************************************
1148 
1149 
1150 //*************************************************************************************************
1154 template<>
1155 struct MatrixSerializer::MatrixValueMappingHelper<true,false>
1156 {
1157  enum { value = 5 };
1158 };
1160 //*************************************************************************************************
1161 
1162 
1163 //*************************************************************************************************
1167 template<>
1168 struct MatrixSerializer::MatrixValueMappingHelper<false,true>
1169 {
1170  enum { value = 3 };
1171 };
1173 //*************************************************************************************************
1174 
1175 
1176 //*************************************************************************************************
1180 template<>
1181 struct MatrixSerializer::MatrixValueMappingHelper<false,false>
1182 {
1183  enum { value = 7 };
1184 };
1186 //*************************************************************************************************
1187 
1188 
1189 
1190 
1191 //=================================================================================================
1192 //
1193 // GLOBAL FUNCTIONS
1194 //
1195 //=================================================================================================
1196 
1197 //*************************************************************************************************
1262 template< typename Archive // Type of the archive
1263  , typename MT // Type of the matrix
1264  , bool SO > // Storage order
1265 void serialize( Archive& archive, const Matrix<MT,SO>& mat )
1266 {
1267  MatrixSerializer().serialize( archive, ~mat );
1268 }
1269 //*************************************************************************************************
1270 
1271 
1272 //*************************************************************************************************
1284 template< typename Archive // Type of the archive
1285  , typename MT // Type of the matrix
1286  , bool SO > // Storage order
1287 void deserialize( Archive& archive, Matrix<MT,SO>& mat )
1288 {
1289  MatrixSerializer().deserialize( archive, ~mat );
1290 }
1291 //*************************************************************************************************
1292 
1293 } // namespace blaze
1294 
1295 #endif
void deserializeHeader(Archive &archive, const MT &mat)
Deserializes all meta information about the given matrix.
Definition: MatrixSerializer.h:527
Binary archive for the portable serialization of data.The Archive class implements the functionality ...
Definition: Archive.h:141
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:258
EnableIfTrue< MT::vectorizable >::Type deserializeDenseRowMatrix(Archive &archive, DenseMatrix< MT, rowMajor > &mat)
Deserializes a row-major dense matrix from the archive.
Definition: MatrixSerializer.h:652
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
T Type
The instantiated type.
Definition: EnableIf.h:99
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:386
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:178
EnableIfTrue< MT::vectorizable >::Type deserializeDenseColumnMatrix(Archive &archive, DenseMatrix< MT, columnMajor > &mat)
Deserializes a column-major dense matrix from the archive.
Definition: MatrixSerializer.h:791
void serializeHeader(Archive &archive, const MT &mat)
Serializes all meta information about the given matrix.
Definition: MatrixSerializer.h:392
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
MatrixSerializer()
The default constructor of the MatrixSerializer class.
Definition: MatrixSerializer.h:339
Header file for the SparseMatrix base class.
void deserializeSparseColumnMatrix(Archive &archive, DenseMatrix< MT, SO > &mat)
Deserializes a column-major sparse matrix from the archive.
Definition: MatrixSerializer.h:1037
void deserializeMatrix(Archive &archive, MT &mat)
Deserializes a matrix from the archive.
Definition: MatrixSerializer.h:616
Header file for the DisableIf class template.
uint8_t type_
The type of the matrix.
Definition: MatrixSerializer.h:316
uint8_t elementType_
The type of an element.
Definition: MatrixSerializer.h:317
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:104
void serializeMatrix(Archive &archive, const DenseMatrix< MT, SO > &mat)
Serializes the elements of a dense matrix.
Definition: MatrixSerializer.h:422
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
Constraint on the data type.
void serialize(Archive &archive, const Matrix< MT, SO > &mat)
Serializes the given matrix and writes it to the archive.
Definition: MatrixSerializer.h:1265
Header file for the DenseMatrix base class.
DisableIf< IsResizable< MT > >::Type prepareMatrix(DenseMatrix< MT, SO > &mat)
Prepares the given non-resizable dense matrix for the deserialization process.
Definition: MatrixSerializer.h:564
uint64_t rows_
The number of rows of the matrix.
Definition: MatrixSerializer.h:319
Header file for the implementation of a dynamic MxN matrix.
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:195
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
Header file for the IsDenseMatrix type trait.
Header file for the EnableIf class template.
64-bit unsigned integer type of the Blaze library.
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.
Serializer for dense and sparse matrices.The MatrixSerializer implements the necessary logic to seria...
Definition: MatrixSerializer.h:157
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:930
uint64_t columns_
The number of columns of the matrix.
Definition: MatrixSerializer.h:320
void deserialize(Archive &archive, Matrix< MT, SO > &mat)
Deserializes a matrix from the given archive.
Definition: MatrixSerializer.h:504
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void deserialize(Archive &archive, Matrix< MT, SO > &mat)
Deserializes a matrix from the given archive.
Definition: MatrixSerializer.h:1287
Header file for the TypeValueMapping class template.
uint8_t version_
The version of the archive.
Definition: MatrixSerializer.h:315
void serialize(Archive &archive, const Matrix< MT, SO > &mat)
Serializes the given matrix and writes it to the archive.
Definition: MatrixSerializer.h:370
uint8_t elementSize_
The size in bytes of a single element of the matrix.
Definition: MatrixSerializer.h:318
Header file for the IsRowMajorMatrix type trait.
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
Header file for basic type definitions.
#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:79
Header file for the IsResizable type trait.
uint64_t number_
The total number of elements contained in the matrix.
Definition: MatrixSerializer.h:321
#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