Previous: Vector Serialization
The serialization of matrices works in the same manner as the serialization of vectors. The following example demonstrates the (de-)serialization of dense and sparse matrices:
{
archive << D << S;
}
{
archive >> D1;
archive >> D2
}
Note that also in case of matrices it is possible to (de-)serialize matrices with vector or matrix elements:
{
archive << mat;
}
{
archive >> mat;
}
Note that just as the vector serialization, the matrix serialization is restricted by a few important rules:
- matrices cannot be reconstituted as vectors (and vice versa)
- the element type of the serialized and reconstituted matrix must match, which means that on the source and destination platform the general type (signed/unsigned integral or floating point) and the size of the type must be exactly the same
- when reconstituting a StaticMatrix, the number of rows and columns must match those of the serialized matrix
In case an error is encountered during (de-)serialization, a std::runtime_exception is thrown.
Previous: Vector Serialization