51 #ifndef ULIB_DENSEMATRIX_H
52 #define ULIB_DENSEMATRIX_H
56 #include <Eigen/Dense>
64 #include <boost/algorithm/string.hpp>
65 #include <boost/algorithm/string/split.hpp>
66 #include <boost/algorithm/string/trim.hpp>
67 #include <boost/lexical_cast.hpp>
68 #include <boost/serialization/string.hpp>
69 #include <boost/serialization/array.hpp>
73 namespace serialization {
75 template<
class Archive,
class Scalar,
int RowsAtCompileTime,
int ColsAtCompileTime>
76 void serialize(Archive & ar, ::Eigen::Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> & m,
const unsigned int ) {
77 ar & boost::serialization::make_array(m.data(), RowsAtCompileTime * ColsAtCompileTime);
89 template <
typename T,
int size>
90 std::istream &
operator >> (std::istream &is, Eigen::Matrix<T,size,1> &vec) {
92 for(
unsigned int i=0; i<size; i++) {
95 if(is.fail()) vec(i) = 0;
96 else vec(i) = boost::lexical_cast<T>(str);
100 template <
typename T,
int size>
101 std::ostream & operator << (std::ostream &os, const Eigen::Matrix<T,size,1> &vec) {
102 os << vec.transpose();
158 template <
typename T,
int size>
159 void VectorxT_StringTo(Eigen::Matrix<T,size,1> &vec, std::string str,
const char *delim =
" ,;\t\n") {
160 std::vector<std::string> strvec;
162 boost::algorithm::trim_if( str, boost::algorithm::is_any_of(delim));
163 boost::algorithm::split(strvec,str,boost::algorithm::is_any_of(delim), boost::algorithm::token_compress_on);
165 for(
unsigned int i=0; i<size; i++) {
166 vec(i) = boost::lexical_cast<T>(strvec[i]);
170 template <
typename T,
int size>
172 std::stringstream sst;
173 sst << vec.transpose();
182 template <
typename T,
int size>
183 void operator>> (std::string& str, Eigen::Matrix<T,size,1> &vec){
201 void operator delete(
void* _p,
size_t _s) {}
204 template<
typename OtherDerived>
210 template<
typename OtherDerived>
213 this->BaseClass::operator=(other);
238 stream <<
"HLine3f(" <<
"pt[" << line.
origin.transpose() <<
"] , dr[" << line.
direction.transpose() <<
"]) ";
280 #endif // U_DENSEMATRIX_H
void operator>>(std::string &str, Eigen::Matrix< T, size, 1 > &vec)
Definition: Dense.h:183
Eigen::Matrix3f Matrix3f
Definition: Dense.h:129
Eigen::Matrix< float, 1, 1 > Matrix1f
Definition: Dense.h:127
long Scalarl
Definition: Dense.h:115
Eigen::Matrix< Scalarf, 4, 1 > BaseClass
Definition: Dense.h:195
std::string VectorxT_ToString(const Eigen::Matrix< T, size, 1 > &vec)
Definition: Dense.h:171
Eigen::Matrix3i Matrix3i
Definition: Dense.h:124
unsigned long Scalarul
Definition: Dense.h:116
Eigen::Vector4f Vector4f
Definition: Dense.h:140
Eigen::Vector3i Vector3i
Definition: Dense.h:134
HVector3f position_error
Definition: Dense.h:247
unsigned int Scalarui
Definition: Dense.h:114
struct _HLine3f HLine3f
Definition: Dense.h:234
#define ULIB_SERIALIZABLE(_Ob)
Definition: Serializable.h:173
HVector3f direction
Definition: Dense.h:232
Eigen::Vector3f Vector3f
Definition: Dense.h:139
HPoint3f origin
Definition: Dense.h:231
std::istream & operator>>(std::istream &is, Eigen::Matrix< T, size, 1 > &vec)
Definition: Dense.h:90
Eigen::Matrix2i Matrix2i
Definition: Dense.h:123
void serialize(Archive &ar,::Eigen::Matrix< Scalar, RowsAtCompileTime, ColsAtCompileTime > &m, const unsigned int)
Definition: Dense.h:76
struct _HError3f HError3f
Definition: Dense.h:250
double Scalard
Definition: Dense.h:118
_HPoint3f< true > HPoint3f
Definition: Dense.h:219
HVector3f direction_error
Definition: Dense.h:248
Eigen::Matrix4f Matrix4f
Definition: Dense.h:130
float Scalarf
Definition: Dense.h:117
std::ostream & operator<<(std::ostream &stream, const MuonEventData &mu)
Definition: MuonEvent.h:58
Eigen::Matrix< float, 1, 1 > Vector1f
Definition: Dense.h:137
Eigen::Vector4i Vector4i
Definition: Dense.h:135
Eigen::Matrix2f Matrix2f
Definition: Dense.h:128
Eigen::Vector2i Vector2i
Definition: Dense.h:133
void VectorxT_StringTo(Eigen::Matrix< T, size, 1 > &vec, std::string str, const char *delim=" ,;\t\n")
Definition: Dense.h:159
_HPoint3f< false > HVector3f
Definition: Dense.h:218
#define p()
Definition: ObjectProps.h:59
_HPoint3f< p > & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: Dense.h:211
Eigen::Vector2f Vector2f
Definition: Dense.h:138
Eigen::Matrix< int, 1, 1 > Vector1i
Definition: Dense.h:132
int Scalari
Definition: Dense.h:113
Eigen::Matrix4i Matrix4i
Definition: Dense.h:125
Eigen::Matrix< int, 1, 1 > Matrix1i
Definition: Dense.h:122