35 #ifndef _BLAZE_MATH_SERIALIZATION_VECTORSERIALIZER_H_
36 #define _BLAZE_MATH_SERIALIZATION_VECTORSERIALIZER_H_
171 template<
bool IsDenseVector >
172 struct VectorValueMappingHelper;
184 template<
typename T >
185 struct VectorValueMapping
187 enum { value = VectorValueMappingHelper< IsDenseVector<T>::value >::value };
213 template<
typename Archive,
typename VT,
bool TF >
221 template<
typename Archive,
typename VT,
bool TF >
230 template<
typename Archive,
typename VT >
233 template<
typename Archive,
typename VT,
bool TF >
236 template<
typename Archive,
typename VT,
bool TF >
244 template<
typename Archive,
typename VT >
247 template<
typename VT,
bool TF >
250 template<
typename VT,
bool TF >
253 template<
typename VT >
256 template<
typename Archive,
typename VT >
259 template<
typename Archive,
typename VT,
bool TF >
263 template<
typename Archive,
typename VT,
bool TF >
267 template<
typename Archive,
typename VT,
bool TF >
270 template<
typename Archive,
typename VT,
bool TF >
273 template<
typename Archive,
typename VT,
bool TF >
364 archive << uint8_t ( VectorValueMapping<VT>::value );
365 archive << uint8_t ( TypeValueMapping<ET>::value );
366 archive << uint8_t (
sizeof( ET ) );
368 archive << uint64_t( IsDenseVector<VT>::value ? vec.size() : vec.nonZeros() );
391 while( ( i < (~vec).
size() ) && ( archive << (~vec)[i] ) ) {
417 ConstIterator element( (~vec).
begin() );
418 while( ( element != (~vec).
end() ) &&
419 ( archive << element->index() << element->value() ) ) {
487 else if( (
type_ & 1U ) != 0U || (
type_ & (~3U) ) != 0U ) {
512 template<
typename VT
527 template<
typename VT
543 template<
typename VT >
546 vec.resize (
size_,
false );
569 deserializeDenseVector( archive, vec );
571 else if(
type_ == 2U ) {
604 while( ( i !=
size_ ) && ( archive >> value ) ) {
634 if(
size_ == 0UL )
return;
635 archive.read( &(~vec)[0],
size_ );
666 while( ( i !=
size_ ) && ( archive >> value ) ) {
701 while( ( i !=
number_ ) && ( archive >> index >> value ) ) {
702 (~vec)[index] = value;
736 while( ( i !=
number_ ) && ( archive >> index >> value ) ) {
737 (~vec).append( index, value,
false );
761 struct VectorSerializer::VectorValueMappingHelper<true>
774 struct VectorSerializer::VectorValueMappingHelper<false>
854 template<
typename Archive
876 template<
typename Archive
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
void serialize(Archive &archive, const Vector< VT, TF > &vec)
Serializes the given vector and writes it to the archive.
Definition: VectorSerializer.h:337
Header file for auxiliary alias declarations.
uint64_t size_
The size of the vector.
Definition: VectorSerializer.h:285
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) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
Serializer for dense and sparse vectors.The VectorSerializer implements the necessary logic to serial...
Definition: VectorSerializer.h:154
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:188
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
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:566
void deserializeHeader(Archive &archive, const VT &vec)
Deserializes all meta information about the given vector.
Definition: VectorSerializer.h:477
void serializeVector(Archive &archive, const DenseVector< VT, TF > &vec)
Serializes the elements of a dense vector.
Definition: VectorSerializer.h:388
uint8_t version_
The version of the archive.
Definition: VectorSerializer.h:281
#define BLAZE_THROW_RUNTIME_ERROR(MESSAGE)
Macro for the emission of a std::runtime_error exception.This macro encapsulates the default way of B...
Definition: Exception.h:379
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:359
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
void serialize(Archive &archive, const Matrix< MT, SO > &mat)
Serializes the given matrix and writes it to the archive.
Definition: MatrixSerializer.h:1268
uint8_t elementSize_
The size in bytes of a single element of the vector.
Definition: VectorSerializer.h:284
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Header file for the exception macros of the math module.
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:254
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
typename EnableIfTrue< Condition, T >::Type EnableIfTrue_
Auxiliary type for the EnableIfTrue class template.The EnableIfTrue_ alias declaration provides a con...
Definition: EnableIf.h:138
void deserialize(Archive &archive, Vector< VT, TF > &vec)
Deserializes a vector from the given archive.
Definition: VectorSerializer.h:449
#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:61
Header file for run time assertion macros.
VectorSerializer()
The default constructor of the VectorSerializer class.
Definition: VectorSerializer.h:304
Conversion from a data type to a serial representation.This class template converts the given data ty...
Definition: TypeValueMapping.h:163
uint64_t number_
The total number of elements contained in the vector.
Definition: VectorSerializer.h:286
uint8_t type_
The type of the vector.
Definition: VectorSerializer.h:282
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
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:1290
void deserializeSparseVector(Archive &archive, DenseVector< VT, TF > &vec)
Deserializes a sparse vector from the archive.
Definition: VectorSerializer.h:693
Header file for the TypeValueMapping class template.
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
DisableIf_< IsResizable< VT > > prepareVector(DenseVector< VT, TF > &vec)
Prepares the given non-resizable dense vector for the deserialization process.
Definition: VectorSerializer.h:514
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:154
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
Constraint on the data type.
T Type
The instantiated type.
Definition: DisableIf.h:99
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:283