7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for Eigen"
10 #include <boost/test/unit_test.hpp>
14 #include <Eigen/Dense>
19 using namespace Eigen;
28 va << 1.0, 2.0, 3.0, 5.0, 7.0;
30 vb = VectorXd::LinSpaced(5, 2.0, 10.0);
32 vc = VectorXd::Constant(5, 7.0);
35 ma << 1.0 , 2.5 , 3.0 , 4.5 , 5.0 ,
36 3.0 , 4.5 , 5.0 , 6.5 , 7.0 ,
37 5.0 , 6.5 , 7.0 , 8.5 , 5.0 ,
38 7.0 , 8.5 , 9.0 ,10.5 , 5.0 ,
39 9.0 ,10.5 ,11.0 ,12.5 ,13.0 ;
41 mb = MatrixXd::Identity(5,5);
43 mc = MatrixXd::Zero(5,5);
54 template <
typename Derived>
55 void modify(Eigen::MatrixBase<Derived>
const& m)
57 const_cast< MatrixBase<Derived>&
>(m).setConstant(2);
84 vc = va.array() * vb.array();
86 vc = va.array() / vb.array();
110 std::vector<int>
v(9);
111 for (
int i=0; i<9; ++i)
114 typedef Eigen::Matrix<int,3,3,Eigen::RowMajor> Matrix3x3_t;
115 typedef Eigen::Matrix<int,1,9,Eigen::RowMajor> Matrix1x9_t;
118 Eigen::Map< Matrix3x3_t > em1(&v.front());
120 Matrix3x3_t::MapType em2(&v.front());
123 Eigen::Map< Matrix1x9_t > ev1(&v.front());
125 Matrix1x9_t::MapType ev2(&v.front());
140 std::vector<int> array(nb_pts*nb_vars);
141 for(
int i = 0; i < array.size(); ++i) array[i] = i;
146 typedef Map< Matrix<int,Dynamic,Dynamic,Eigen::RowMajor> , Unaligned, Stride<Dynamic,Dynamic> > VariableMapT;
147 VariableMapT var (&array.front()+var_idx, nb_pts, var_size, Stride<Dynamic,Dynamic>(nb_vars, var_size-1));
150 cout << var.transpose()*var << endl;
152 var.array() = var.array()*var.array();
156 Array<double,2,2,RowMajor>
test;
159 std::stringstream ss; ss <<
test;
160 cout << ss.str() << endl;
167 BOOST_AUTO_TEST_SUITE_END()
169
void modify(Eigen::MatrixBase< Derived > const &m)
fixture for each test of Eigen
BOOST_AUTO_TEST_CASE(VectorCoeffWiseOps)