Skip to content
Snippets Groups Projects
Commit dafd83e8 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Put operator<< in Eigen namespace

parent d874a3b3
No related branches found
No related tags found
2 merge requests!358WIP: Resolve "Complete state vector new data structure?",!343WIP: Resolve "Complete state vector new data structure?"
...@@ -26,6 +26,17 @@ typedef std::unordered_map < std::string, StateBlockPtr > StateBlockMap; ...@@ -26,6 +26,17 @@ typedef std::unordered_map < std::string, StateBlockPtr > StateBlockMap;
typedef std::unordered_map < std::string, Eigen::VectorXd > VectorComposite; typedef std::unordered_map < std::string, Eigen::VectorXd > VectorComposite;
typedef StateBlockMap::const_iterator StateBlockMapCIter; typedef StateBlockMap::const_iterator StateBlockMapCIter;
typedef std::unordered_map < std::string, Eigen::VectorXd > VectorComposite;
}
namespace Eigen
{
std::ostream& operator <<(std::ostream &_os, const wolf::VectorComposite &_x);
}
namespace wolf{
class StateBlockComposite class StateBlockComposite
{ {
public: public:
...@@ -139,8 +150,6 @@ inline unsigned int MatrixComposite::count(const std::string &_row, const std::s ...@@ -139,8 +150,6 @@ inline unsigned int MatrixComposite::count(const std::string &_row, const std::s
return (matrix_composite_.at(_row).count(_col)); return (matrix_composite_.at(_row).count(_col));
} }
std::ostream& operator <<(std::ostream &_os, const VectorComposite &_x);
template<typename SB, typename ... Args> template<typename SB, typename ... Args>
inline std::shared_ptr<SB> wolf::StateBlockComposite::emplace(const std::string &_sb_type, inline std::shared_ptr<SB> wolf::StateBlockComposite::emplace(const std::string &_sb_type,
......
...@@ -4,6 +4,19 @@ ...@@ -4,6 +4,19 @@
#include "core/state_block/state_composite.h" #include "core/state_block/state_composite.h"
#include "core/state_block/state_block.h" #include "core/state_block/state_block.h"
namespace Eigen{
std::ostream& operator <<(std::ostream &_os, const wolf::VectorComposite &_x)
{
for (const auto &pair_key_vec : _x)
{
const auto &key = pair_key_vec.first;
const auto &vec = pair_key_vec.second;
_os << "\n block(" << key << ") = \n" << vec;
}
return _os;
}
}
namespace wolf namespace wolf
{ {
...@@ -135,18 +148,6 @@ std::ostream& operator <<(std::ostream &_os, const MatrixComposite &_M) ...@@ -135,18 +148,6 @@ std::ostream& operator <<(std::ostream &_os, const MatrixComposite &_M)
return _os; return _os;
} }
std::ostream& operator <<(std::ostream &_os, const VectorComposite &_x)
{
for (const auto &pair_row_blk : _x)
{
const auto &row = pair_row_blk.first;
const auto &vec = pair_row_blk.second;
_os << "\n block(" << row << ") = \n" << vec;
}
return _os;
}
const StateBlockMap& StateBlockComposite::getStateBlockMap() const const StateBlockMap& StateBlockComposite::getStateBlockMap() const
{ {
......
...@@ -5,14 +5,11 @@ ...@@ -5,14 +5,11 @@
* Author: jsola * Author: jsola
*/ */
#include "core/utils/utils_gtest.h"
#include "core/utils/logging.h"
#include "core/common/wolf.h"
#include "core/state_block/state_composite.h" #include "core/state_block/state_composite.h"
#include "core/state_block/state_quaternion.h" #include "core/state_block/state_quaternion.h"
#include "core/utils/utils_gtest.h"
using namespace wolf; using namespace wolf;
using namespace std; using namespace std;
...@@ -215,6 +212,8 @@ TEST(VectorComposite, operatorStream) ...@@ -215,6 +212,8 @@ TEST(VectorComposite, operatorStream)
cout << "x = " << x << endl; cout << "x = " << x << endl;
WOLF_DEBUG("X = ", x);
} }
TEST(MatrixComposite, emplace_operatorStream) TEST(MatrixComposite, emplace_operatorStream)
...@@ -330,7 +329,9 @@ TEST(MatrixComposite, productVector) ...@@ -330,7 +329,9 @@ TEST(MatrixComposite, productVector)
x.emplace("P", Vector2d(1,1)); x.emplace("P", Vector2d(1,1));
x.emplace("O", Vector3d(2,2,2)); x.emplace("O", Vector3d(2,2,2));
WOLF_DEBUG("x = " , x); cout << "x= " << x << endl;
// WOLF_DEBUG("x = " , x);
MatrixComposite M; MatrixComposite M;
...@@ -350,7 +351,7 @@ TEST(MatrixComposite, productVector) ...@@ -350,7 +351,7 @@ TEST(MatrixComposite, productVector)
y = M * x; y = M * x;
WOLF_DEBUG("y = M * x = " , y); // WOLF_DEBUG("y = M * x = " , y);
/* M * x = y /* M * x = y
* p o * p o
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment