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>
55 #include <blaze/util/Assert.h>
56 #include <blaze/util/DisableIf.h>
57 #include <blaze/util/EnableIf.h>
58 #include <blaze/util/Types.h>
60 
61 
62 namespace blaze {
63 
64 //=================================================================================================
65 //
66 // CLASS DEFINITION
67 //
68 //=================================================================================================
69 
70 //*************************************************************************************************
159 {
160  private:
161  //**Private class MatrixValueMappingHelper******************************************************
175  template< bool IsDenseMatrix, bool IsRowMajorMatrix >
176  struct MatrixValueMappingHelper;
178  //**********************************************************************************************
179 
180  //**Private class MatrixValueMapping************************************************************
188  template< typename T >
189  struct MatrixValueMapping
190  {
191  enum { value = MatrixValueMappingHelper< IsDenseMatrix<T>::value, IsRowMajorMatrix<T>::value >::value };
193  };
195  //**********************************************************************************************
196 
197  public:
198  //**Constructor*********************************************************************************
201  explicit inline MatrixSerializer();
202  // No explicitly declared copy constructor.
204  //**********************************************************************************************
205 
206  //**Destructor**********************************************************************************
207  // No explicitly declared destructor.
208  //**********************************************************************************************
209 
210  //**Assignment operators************************************************************************
211  // No explicitly declared copy assignment operator.
212  //**********************************************************************************************
213 
214  //**Serialization functions*********************************************************************
217  template< typename Archive, typename MT, bool SO >
218  void serialize( Archive& archive, const Matrix<MT,SO>& mat );
220  //**********************************************************************************************
221 
222  //**Deserialization functions*******************************************************************
225  template< typename Archive, typename MT, bool SO >
226  void deserialize( Archive& archive, Matrix<MT,SO>& mat );
228  //**********************************************************************************************
229 
230  private:
231  //**Serialization functions*********************************************************************
234  template< typename Archive, typename MT >
235  void serializeHeader( Archive& archive, const MT& mat );
236 
237  template< typename Archive, typename MT, bool SO >
238  void serializeMatrix( Archive& archive, const DenseMatrix<MT,SO>& mat );
239 
240  template< typename Archive, typename MT, bool SO >
241  void serializeMatrix( Archive& archive, const SparseMatrix<MT,SO>& mat );
243  //**********************************************************************************************
244 
245  //**Deserialization functions*******************************************************************
248  template< typename Archive, typename MT >
249  void deserializeHeader( Archive& archive, const MT& mat );
250 
251  template< typename MT >
252  typename DisableIf< IsResizable<MT> >::Type prepareMatrix( MT& mat );
253 
254  template< typename MT >
255  typename EnableIf< IsResizable<MT> >::Type prepareMatrix( MT& mat );
256 
257  template< typename Archive, typename MT >
258  void deserializeMatrix( Archive& archive, MT& mat );
259 
260  template< typename Archive, typename MT >
263 
264  template< typename Archive, typename MT, bool SO >
266 
267  template< typename Archive, typename MT, bool SO >
270 
271  template< typename Archive, typename MT, bool SO >
274 
275  template< typename Archive, typename MT >
278 
279  template< typename Archive, typename MT, bool SO >
281 
282  template< typename Archive, typename MT, bool SO >
285 
286  template< typename Archive, typename MT, bool SO >
289 
290  template< typename Archive, typename MT, bool SO >
292 
293  template< typename Archive, typename MT >
295 
296  template< typename Archive, typename MT >
298 
299  template< typename Archive, typename MT, bool SO >
301 
302  template< typename Archive, typename MT >
304 
305  template< typename Archive, typename MT >
308  //**********************************************************************************************
309 
310  //**Member variables****************************************************************************
320 
321  //**********************************************************************************************
322 };
323 //*************************************************************************************************
324 
325 
326 
327 
328 //=================================================================================================
329 //
330 // CONSTRUCTOR
331 //
332 //=================================================================================================
333 
334 //*************************************************************************************************
338  : version_ ( 0U ) // The version of the archive
339  , type_ ( 0U ) // The type of the matrix
340  , elementType_( 0U ) // The type of an element
341  , elementSize_( 0U ) // The size in bytes of a single element of the matrix
342  , rows_ ( 0UL ) // The number of rows of the matrix
343  , columns_ ( 0UL ) // The number of columns of the matrix
344  , number_ ( 0UL ) // The total number of elements contained in the matrix
345 {}
346 //*************************************************************************************************
347 
348 
349 
350 
351 //=================================================================================================
352 //
353 // SERIALIZATION FUNCTIONS
354 //
355 //=================================================================================================
356 
357 //*************************************************************************************************
365 template< typename Archive // Type of the archive
366  , typename MT // Type of the matrix
367  , bool SO > // Storage order
369 {
370  if( !archive ) {
371  throw std::runtime_error( "Faulty archive detected" );
372  }
373 
374  serializeHeader( archive, ~mat );
375  serializeMatrix( archive, ~mat );
376 }
377 //*************************************************************************************************
378 
379 
380 //*************************************************************************************************
388 template< typename Archive // Type of the archive
389  , typename MT > // Type of the matrix
390 void MatrixSerializer::serializeHeader( Archive& archive, const MT& mat )
391 {
392  typedef typename MT::ElementType ET;
393 
394  archive << uint8_t ( 1U );
395  archive << uint8_t ( MatrixValueMapping<MT>::value );
396  archive << uint8_t ( TypeValueMapping<ET>::value );
397  archive << uint8_t ( sizeof( ET ) );
398  archive << uint64_t( mat.rows() );
399  archive << uint64_t( mat.columns() );
400  archive << uint64_t( ( IsDenseMatrix<MT>::value ) ? ( mat.rows()*mat.columns() ) : ( mat.nonZeros() ) );
401 
402  if( !archive ) {
403  throw std::runtime_error( "File header could not be serialized" );
404  }
405 }
406 //*************************************************************************************************
407 
408 
409 //*************************************************************************************************
417 template< typename Archive // Type of the archive
418  , typename MT // Type of the matrix
419  , bool SO > // Storage order
421 {
423  for( size_t i=0UL; i<(~mat).rows(); ++i ) {
424  for( size_t j=0UL; j<(~mat).columns(); ++j ) {
425  archive << (~mat)(i,j);
426  }
427  }
428  }
429  else {
430  for( size_t j=0UL; j<(~mat).columns(); ++j ) {
431  for( size_t i=0UL; i<(~mat).rows(); ++i ) {
432  archive << (~mat)(i,j);
433  }
434  }
435  }
436 
437  if( !archive ) {
438  throw std::runtime_error( "Dense matrix could not be serialized" );
439  }
440 }
441 //*************************************************************************************************
442 
443 
444 //*************************************************************************************************
452 template< typename Archive // Type of the archive
453  , typename MT // Type of the matrix
454  , bool SO > // Storage order
456 {
457  typedef typename MT::ConstIterator ConstIterator;
458 
460  for( size_t i=0UL; i<(~mat).rows(); ++i ) {
461  archive << uint64_t( (~mat).nonZeros( i ) );
462  for( ConstIterator element=(~mat).begin(i); element!=(~mat).end(i); ++element ) {
463  archive << element->index() << element->value();
464  }
465  }
466  }
467  else {
468  for( size_t j=0UL; j<(~mat).columns(); ++j ) {
469  archive << uint64_t( (~mat).nonZeros( j ) );
470  for( ConstIterator element=(~mat).begin(j); element!=(~mat).end(j); ++element ) {
471  archive << element->index() << element->value();
472  }
473  }
474  }
475 
476  if( !archive ) {
477  throw std::runtime_error( "Sparse matrix could not be serialized" );
478  }
479 }
480 //*************************************************************************************************
481 
482 
483 
484 
485 //=================================================================================================
486 //
487 // DESERIALIZATION FUNCTIONS
488 //
489 //=================================================================================================
490 
491 //*************************************************************************************************
499 template< typename Archive // Type of the archive
500  , typename MT // Type of the matrix
501  , bool SO > // Storage order
503 {
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 matrix
564 {
565  reset( mat );
566 }
567 //*************************************************************************************************
568 
569 
570 //*************************************************************************************************
576 template< typename MT > // Type of the matrix
578 {
579  mat.resize ( rows_, columns_, false );
580  mat.reserve( number_ );
581  reset( mat );
582 }
583 //*************************************************************************************************
584 
585 
586 //*************************************************************************************************
597 template< typename Archive // Type of the archive
598  , typename MT > // Type of the matrix
600 {
601  if( type_ == 1U ) {
602  deserializeDenseRowMatrix( archive, ~mat );
603  }
604  else if( type_ == 5UL ) {
605  deserializeDenseColumnMatrix( archive, ~mat );
606  }
607  else if( type_ == 3UL ) {
608  deserializeSparseRowMatrix( archive, ~mat );
609  }
610  else if( type_ == 7UL ) {
611  deserializeSparseColumnMatrix( archive, ~mat );
612  }
613  else {
614  BLAZE_INTERNAL_ASSERT( false, "Undefined type flag" );
615  }
616 }
617 //*************************************************************************************************
618 
619 
620 //*************************************************************************************************
632 template< typename Archive // Type of the archive
633  , typename MT > // Type of the matrix
636 {
637  if( columns_ == 0UL ) return;
638 
639  for( size_t i=0UL; i<rows_; ++i ) {
640  archive.read( &(~mat)(i,0), columns_ );
641  }
642 
643  if( !archive ) {
644  throw std::runtime_error( "Dense matrix could not be deserialized" );
645  }
646 }
647 //*************************************************************************************************
648 
649 
650 //*************************************************************************************************
662 template< typename Archive // Type of the archive
663  , typename MT // Type of the matrix
664  , bool SO > // Storage order
666 {
667  typedef typename MT::ElementType ET;
668 
669  ET value = ET();
670 
671  for( size_t i=0UL; i<rows_; ++i ) {
672  size_t j( 0UL );
673  while( ( j != columns_ ) && ( archive >> value ) ) {
674  (~mat)(i,j) = value;
675  ++j;
676  }
677  }
678 
679  if( !archive ) {
680  throw std::runtime_error( "Dense matrix could not be deserialized" );
681  }
682 }
683 //*************************************************************************************************
684 
685 
686 //*************************************************************************************************
698 template< typename Archive // Type of the archive
699  , typename MT // Type of the matrix
700  , bool SO > // Storage order
703 {
705  deserializeDenseRowMatrix( archive, tmp );
706  (~mat) = tmp;
707 
708  if( !archive ) {
709  throw std::runtime_error( "Sparse matrix could not be deserialized" );
710  }
711 }
712 //*************************************************************************************************
713 
714 
715 //*************************************************************************************************
727 template< typename Archive // Type of the archive
728  , typename MT // Type of the matrix
729  , bool SO > // Storage order
732 {
733  typedef typename MT::ElementType ET;
734 
735  ET value = ET();
736 
737  const size_t dim1( ( SO == rowMajor )?( rows_ ):( columns_ ) );
738  const size_t dim2( ( SO != rowMajor )?( rows_ ):( columns_ ) );
739 
740  for( size_t i=0UL; i<dim1; ++i ) {
741  (~mat).reserve( i, dim2 );
742  }
743 
744  for( size_t i=0UL; i<rows_; ++i ) {
745  size_t j( 0UL );
746  while( ( j != columns_ ) && ( archive >> value ) ) {
747  (~mat).append( i, j, value, false );
748  ++j;
749  }
750  }
751 
752  if( !archive ) {
753  throw std::runtime_error( "Sparse matrix could not be deserialized" );
754  }
755 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
771 template< typename Archive // Type of the archive
772  , typename MT > // Type of the matrix
775 {
776  if( rows_ == 0UL ) return;
777 
778  for( size_t j=0UL; j<columns_; ++j ) {
779  archive.read( &(~mat)(0,j), rows_ );
780  }
781 
782  if( !archive ) {
783  throw std::runtime_error( "Dense matrix could not be deserialized" );
784  }
785 }
786 //*************************************************************************************************
787 
788 
789 //*************************************************************************************************
801 template< typename Archive // Type of the archive
802  , typename MT // Type of the matrix
803  , bool SO > // Storage order
805 {
806  typedef typename MT::ElementType ET;
807 
808  ET value = ET();
809 
810  for( size_t j=0UL; j<columns_; ++j ) {
811  size_t i( 0UL );
812  while( ( i != rows_ ) && ( archive >> value ) ) {
813  (~mat)(i,j) = value;
814  ++i;
815  }
816  }
817 
818  if( !archive ) {
819  throw std::runtime_error( "Dense matrix could not be deserialized" );
820  }
821 }
822 //*************************************************************************************************
823 
824 
825 //*************************************************************************************************
837 template< typename Archive // Type of the archive
838  , typename MT // Type of the matrix
839  , bool SO > // Storage order
842 {
844  deserializeDenseColumnMatrix( archive, tmp );
845  (~mat) = tmp;
846 
847  if( !archive ) {
848  throw std::runtime_error( "Sparse matrix could not be deserialized" );
849  }
850 }
851 //*************************************************************************************************
852 
853 
854 //*************************************************************************************************
866 template< typename Archive // Type of the archive
867  , typename MT // Type of the matrix
868  , bool SO > // Storage order
871 {
872  typedef typename MT::ElementType ET;
873 
874  ET value = ET();
875 
876  const size_t dim1( ( SO == rowMajor )?( rows_ ):( columns_ ) );
877  const size_t dim2( ( SO != rowMajor )?( rows_ ):( columns_ ) );
878 
879  for( size_t i=0UL; i<dim1; ++i ) {
880  (~mat).reserve( i, dim2 );
881  }
882 
883  for( size_t j=0UL; j<columns_; ++j ) {
884  size_t i( 0UL );
885  while( ( i != rows_ ) && ( archive >> value ) ) {
886  (~mat).append( i, j, value, false );
887  ++i;
888  }
889  }
890 
891  if( !archive ) {
892  throw std::runtime_error( "Sparse matrix could not be deserialized" );
893  }
894 }
895 //*************************************************************************************************
896 
897 
898 //*************************************************************************************************
910 template< typename Archive // Type of the archive
911  , typename MT // Type of the matrix
912  , bool SO > // Storage order
914 {
915  typedef typename MT::ElementType ET;
916 
917  uint64_t number( 0UL );
918  size_t index ( 0UL );
919  ET value = ET();
920 
921  for( size_t i=0UL; i<rows_; ++i ) {
922  archive >> number;
923  size_t j( 0UL );
924  while( ( j != number ) && ( archive >> index >> value ) ) {
925  (~mat)(i,index) = value;
926  ++j;
927  }
928  }
929 
930  if( !archive ) {
931  throw std::runtime_error( "Dense matrix could not be deserialized" );
932  }
933 }
934 //*************************************************************************************************
935 
936 
937 //*************************************************************************************************
949 template< typename Archive // Type of the archive
950  , typename MT > // Type of the matrix
952 {
953  typedef typename MT::ElementType ET;
954 
955  uint64_t number( 0UL );
956  size_t index ( 0UL );
957  ET value = ET();
958 
959  for( size_t i=0UL; i<rows_; ++i )
960  {
961  archive >> number;
962  (~mat).reserve( i, number );
963 
964  size_t j( 0UL );
965  while( ( j != number ) && ( archive >> index >> value ) ) {
966  (~mat).append( i, index, value, false );
967  ++j;
968  }
969  }
970 
971  if( !archive ) {
972  throw std::runtime_error( "Sparse matrix could not be deserialized" );
973  }
974 }
975 //*************************************************************************************************
976 
977 
978 //*************************************************************************************************
990 template< typename Archive // Type of the archive
991  , typename MT > // Type of the matrix
993 {
995  deserializeSparseRowMatrix( archive, tmp );
996  (~mat) = tmp;
997 
998  if( !archive ) {
999  throw std::runtime_error( "Sparse matrix could not be deserialized" );
1000  }
1001 }
1002 //*************************************************************************************************
1003 
1004 
1005 //*************************************************************************************************
1017 template< typename Archive // Type of the archive
1018  , typename MT // Type of the matrix
1019  , bool SO > // Storage order
1021 {
1022  typedef typename MT::ElementType ET;
1023 
1024  uint64_t number( 0UL );
1025  size_t index ( 0UL );
1026  ET value = ET();
1027 
1028  for( size_t j=0UL; j<columns_; ++j ) {
1029  archive >> number;
1030  size_t i( 0UL );
1031  while( ( i != number ) && ( archive >> index >> value ) ) {
1032  (~mat)(index,j) = value;
1033  ++i;
1034  }
1035  }
1036 
1037  if( !archive ) {
1038  throw std::runtime_error( "Dense matrix could not be deserialized" );
1039  }
1040 }
1041 //*************************************************************************************************
1042 
1043 
1044 //*************************************************************************************************
1056 template< typename Archive // Type of the archive
1057  , typename MT > // Type of the matrix
1059 {
1061  deserializeSparseColumnMatrix( archive, tmp );
1062  (~mat) = tmp;
1063 
1064  if( !archive ) {
1065  throw std::runtime_error( "Sparse matrix could not be deserialized" );
1066  }
1067 }
1068 //*************************************************************************************************
1069 
1070 
1071 //*************************************************************************************************
1083 template< typename Archive // Type of the archive
1084  , typename MT > // Type of the matrix
1086 {
1087  typedef typename MT::ElementType ET;
1088 
1089  uint64_t number( 0UL );
1090  size_t index ( 0UL );
1091  ET value = ET();
1092 
1093  for( size_t j=0UL; j<columns_; ++j )
1094  {
1095  archive >> number;
1096  (~mat).reserve( j, number );
1097 
1098  size_t i( 0UL );
1099  while( ( i != number ) && ( archive >> index >> value ) ) {
1100  (~mat).append( index, j, value, false );
1101  ++i;
1102  }
1103  }
1104 
1105  if( !archive ) {
1106  throw std::runtime_error( "Sparse matrix could not be deserialized" );
1107  }
1108 }
1109 //*************************************************************************************************
1110 
1111 
1112 
1113 
1114 //=================================================================================================
1115 //
1116 // MATRIXVALUEMAPPINGHELPER SPECIALIZATIONS
1117 //
1118 //=================================================================================================
1119 
1120 //*************************************************************************************************
1124 template<>
1125 struct MatrixSerializer::MatrixValueMappingHelper<true,true>
1126 {
1127  enum { value = 1 };
1128 };
1130 //*************************************************************************************************
1131 
1132 
1133 //*************************************************************************************************
1137 template<>
1138 struct MatrixSerializer::MatrixValueMappingHelper<true,false>
1139 {
1140  enum { value = 5 };
1141 };
1143 //*************************************************************************************************
1144 
1145 
1146 //*************************************************************************************************
1150 template<>
1151 struct MatrixSerializer::MatrixValueMappingHelper<false,true>
1152 {
1153  enum { value = 3 };
1154 };
1156 //*************************************************************************************************
1157 
1158 
1159 //*************************************************************************************************
1163 template<>
1164 struct MatrixSerializer::MatrixValueMappingHelper<false,false>
1165 {
1166  enum { value = 7 };
1167 };
1169 //*************************************************************************************************
1170 
1171 
1172 
1173 
1174 //=================================================================================================
1175 //
1176 // GLOBAL FUNCTIONS
1177 //
1178 //=================================================================================================
1179 
1180 //*************************************************************************************************
1245 template< typename Archive // Type of the archive
1246  , typename MT // Type of the matrix
1247  , bool SO > // Storage order
1248 void serialize( Archive& archive, const Matrix<MT,SO>& mat )
1249 {
1250  MatrixSerializer().serialize( archive, ~mat );
1251 }
1252 //*************************************************************************************************
1253 
1254 
1255 //*************************************************************************************************
1267 template< typename Archive // Type of the archive
1268  , typename MT // Type of the matrix
1269  , bool SO > // Storage order
1270 void deserialize( Archive& archive, Matrix<MT,SO>& mat )
1271 {
1272  MatrixSerializer().deserialize( archive, ~mat );
1273 }
1274 //*************************************************************************************************
1275 
1276 } // namespace blaze
1277 
1278 #endif
void deserializeHeader(Archive &archive, const MT &mat)
Deserializes all meta information about the given matrix.
Definition: MatrixSerializer.h:527
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
Binary archive for the portable serialization of data.The Archive class implements the functionality ...
Definition: Archive.h:141
EnableIfTrue< MT::vectorizable >::Type deserializeDenseRowMatrix(Archive &archive, DenseMatrix< MT, rowMajor > &mat)
Deserializes a row-major dense matrix from the archive.
Definition: MatrixSerializer.h:635
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
Constraint on the data type.
T Type
The instantiated type.
Definition: EnableIf.h:99
8-bit unsigned integer type of the Blaze library.
Implementation of a compressed MxN matrix.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:176
EnableIfTrue< MT::vectorizable >::Type deserializeDenseColumnMatrix(Archive &archive, DenseMatrix< MT, columnMajor > &mat)
Deserializes a column-major dense matrix from the archive.
Definition: MatrixSerializer.h:774
void serializeHeader(Archive &archive, const MT &mat)
Serializes all meta information about the given matrix.
Definition: MatrixSerializer.h:390
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:104
MatrixSerializer()
The default constructor of the MatrixSerializer class.
Definition: MatrixSerializer.h:337
DisableIf< IsResizable< MT > >::Type prepareMatrix(MT &mat)
Prepares the given non-resizable matrix for the deserialization process.
Definition: MatrixSerializer.h:563
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:1020
void deserializeMatrix(Archive &archive, MT &mat)
Deserializes a matrix from the archive.
Definition: MatrixSerializer.h:599
Header file for the DisableIf class template.
uint8_t type_
The type of the matrix.
Definition: MatrixSerializer.h:314
uint8_t elementType_
The type of an element.
Definition: MatrixSerializer.h:315
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:420
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
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:1248
Header file for the DenseMatrix base class.
uint64_t rows_
The number of rows of the matrix.
Definition: MatrixSerializer.h:317
Header file for the implementation of a dynamic MxN matrix.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
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: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:913
uint64_t columns_
The number of columns of the matrix.
Definition: MatrixSerializer.h:318
void deserialize(Archive &archive, Matrix< MT, SO > &mat)
Deserializes a matrix from the given archive.
Definition: MatrixSerializer.h:502
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
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:1270
Header file for the TypeValueMapping class template.
uint8_t version_
The version of the archive.
Definition: MatrixSerializer.h:313
void serialize(Archive &archive, const Matrix< MT, SO > &mat)
Serializes the given matrix and writes it to the archive.
Definition: MatrixSerializer.h:368
uint8_t elementSize_
The size in bytes of a single element of the matrix.
Definition: MatrixSerializer.h:316
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_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:118
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
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:319
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:138
#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