7 #ifndef IMPEM2D_MATRIX_H
8 #define IMPEM2D_MATRIX_H
10 #include <IMP/em2d/em2d_config.h>
13 #include <Eigen/Dense>
14 #include <cereal/access.hpp>
15 #include <cereal/cereal.hpp>
22 IMPEM2D_BEGIN_NAMESPACE
27 typedef Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
31 typedef Eigen::Array<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
35 IMPEM2DEXPORT
void show(
const DoubleMatrix &m, std::ostream &out = std::cout);
43 IMPEM2D_BEGIN_INTERNAL_NAMESPACE
48 Eigen::Array<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
50 IMPEM2D_END_INTERNAL_NAMESPACE
54 template <
class Archive,
class T>
55 inline void save(Archive &ar,
56 const IMP::em2d::internal::RowMajorArray<T> &m) {
57 std::int64_t rows = m.rows(), cols = m.cols();
59 ar(cereal::binary_data(const_cast<T *>(m.data()), m.size() *
sizeof(T)));
62 template <
class Archive,
class T>
63 inline void load(Archive &ar, IMP::em2d::internal::RowMajorArray<T> &m) {
64 std::int64_t rows, cols;
66 if (rows < 0 || cols < 0 ||
68 rows > std::numeric_limits<Eigen::Index>::max() / cols)) {
69 IMP_THROW(
"Invalid matrix size in serialized data: " << rows <<
"x"
74 ar(cereal::binary_data(m.data(), m.size() *
sizeof(T)));
void write_matrix(const DoubleMatrix &m, std::string name)
Quick and dirty way of writing a matrix to a Spider image.
Exception definitions and assertions.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Eigen::Array< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > IntMatrix
Matrix of ints, used for masks and labels.
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > DoubleMatrix
Matrix of doubles, used to store the data of an image.
An exception for an invalid value being passed to IMP.