35 #ifndef _BLAZE_MATH_SERIALIZATION_VECTORSERIALIZER_H_
36 #define _BLAZE_MATH_SERIALIZATION_VECTORSERIALIZER_H_
170 template<
bool IsDenseVector >
171 struct VectorValueMappingHelper;
183 template<
typename T >
184 struct VectorValueMapping
186 enum { value = VectorValueMappingHelper< IsDenseVector<T>::value >::value };
212 template<
typename Archive,
typename VT,
bool TF >
220 template<
typename Archive,
typename VT,
bool TF >
229 template<
typename Archive,
typename VT >
232 template<
typename Archive,
typename VT,
bool TF >
235 template<
typename Archive,
typename VT,
bool TF >
243 template<
typename Archive,
typename VT >
246 template<
typename VT,
bool TF >
249 template<
typename VT,
bool TF >
252 template<
typename VT >
255 template<
typename Archive,
typename VT >
258 template<
typename Archive,
typename VT,
bool TF >
262 template<
typename Archive,
typename VT,
bool TF >
266 template<
typename Archive,
typename VT,
bool TF >
269 template<
typename Archive,
typename VT,
bool TF >
272 template<
typename Archive,
typename VT,
bool TF >
363 archive << uint8_t ( VectorValueMapping<VT>::value );
364 archive << uint8_t ( TypeValueMapping<ET>::value );
365 archive << uint8_t (
sizeof( ET ) );
367 archive << uint64_t( IsDenseVector<VT>::value ? vec.size() : vec.nonZeros() );
390 while( ( i < (~vec).
size() ) && ( archive << (~vec)[i] ) ) {
416 ConstIterator element( (~vec).
begin() );
417 while( ( element != (~vec).
end() ) &&
418 ( archive << element->index() << element->value() ) ) {
455 prepareVector( ~vec );
486 else if( (
type_ & 1U ) != 0U || (
type_ & (~3U) ) != 0U ) {
511 template<
typename VT
526 template<
typename VT
542 template<
typename VT >
545 vec.resize (
size_,
false );
568 deserializeDenseVector( archive, vec );
570 else if(
type_ == 2U ) {
603 while( ( i !=
size_ ) && ( archive >> value ) ) {
633 if(
size_ == 0UL )
return;
634 archive.read( &(~vec)[0],
size_ );
665 while( ( i !=
size_ ) && ( archive >> value ) ) {
700 while( ( i !=
number_ ) && ( archive >> index >> value ) ) {
701 (~vec)[index] = value;
735 while( ( i !=
number_ ) && ( archive >> index >> value ) ) {
736 (~vec).append( index, value,
false );
760 struct VectorSerializer::VectorValueMappingHelper<true>
773 struct VectorSerializer::VectorValueMappingHelper<false>
853 template<
typename Archive
875 template<
typename Archive
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
void serialize(Archive &archive, const Vector< VT, TF > &vec)
Serializes the given vector and writes it to the archive.
Definition: VectorSerializer.h:336
uint64_t size_
The size of the vector.
Definition: VectorSerializer.h:284
Binary archive for the portable serialization of data.The Archive class implements the functionality ...
Definition: Archive.h:141
Header file for basic type definitions.
Header file for the SparseVector base class.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
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:250
Serializer for dense and sparse vectors.The VectorSerializer implements the necessary logic to serial...
Definition: VectorSerializer.h:153
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
T Type
The instantiated type.
Definition: EnableIf.h:99
8-bit unsigned integer type of the Blaze library.
Header file for the DenseVector base class.
void deserializeVector(Archive &archive, VT &vec)
Deserializes a vector from the archive.
Definition: VectorSerializer.h:565
void deserializeHeader(Archive &archive, const VT &vec)
Deserializes all meta information about the given vector.
Definition: VectorSerializer.h:476
void serializeVector(Archive &archive, const DenseVector< VT, TF > &vec)
Serializes the elements of a dense vector.
Definition: VectorSerializer.h:387
uint8_t version_
The version of the archive.
Definition: VectorSerializer.h:280
#define BLAZE_THROW_RUNTIME_ERROR(MESSAGE)
Macro for the emission of a std::runtime_error exceptionThis macro encapsulates the default way of Bl...
Definition: Exception.h:379
Header file for the DisableIf class template.
void serializeHeader(Archive &archive, const VT &vec)
Serializes all meta information about the given vector.
Definition: VectorSerializer.h:358
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
void serialize(Archive &archive, const Matrix< MT, SO > &mat)
Serializes the given matrix and writes it to the archive.
Definition: MatrixSerializer.h:1265
uint8_t elementSize_
The size in bytes of a single element of the vector.
Definition: VectorSerializer.h:283
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
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:187
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
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
void deserialize(Archive &archive, Vector< VT, TF > &vec)
Deserializes a vector from the given archive.
Definition: VectorSerializer.h:448
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a N-dimensional vector type...
Definition: Vector.h:79
Header file for run time assertion macros.
VectorSerializer()
The default constructor of the VectorSerializer class.
Definition: VectorSerializer.h:303
Conversion from a data type to a serial representation.This class template converts the given data ty...
Definition: TypeValueMapping.h:163
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
uint64_t number_
The total number of elements contained in the vector.
Definition: VectorSerializer.h:285
uint8_t type_
The type of the vector.
Definition: VectorSerializer.h:281
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Header file for the IsDenseVector type trait.
void deserialize(Archive &archive, Matrix< MT, SO > &mat)
Deserializes a matrix from the given archive.
Definition: MatrixSerializer.h:1287
void deserializeSparseVector(Archive &archive, DenseVector< VT, TF > &vec)
Deserializes a sparse vector from the archive.
Definition: VectorSerializer.h:692
Header file for the TypeValueMapping class template.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:164
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:118
Constraint on the data type.
T Type
The instantiated type.
Definition: DisableIf.h:99
Header file for exception macros.
Header file for the IsResizable type trait.
Header file for the Vector CRTP base class.
#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
uint8_t elementType_
The type of an element.
Definition: VectorSerializer.h:282