9 template <
typename Scalar>
11 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> ReturnType;
12 return ReturnType::Constant(1,
value);
15 template <
typename Scalar>
16 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
matrix1x1(
17 const Scalar&
value) {
18 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> ReturnType;
19 return ReturnType::Constant(1, 1,
value);
22 template <
typename Scalar>
24 std::cout <<
mat << std::endl;
33 Eigen::MatrixXd
emptyMatrix() {
return Eigen::MatrixXd(0, 0); }
36 Eigen::MatrixXd
mat(
R, C);
37 for (
int r = 0;
r <
R; ++
r)
38 for (
int c = 0;
c < C; ++
c)
mat(
r,
c) =
r * C +
c;
40 if (
verbose) std::cout <<
"EigenMat = " <<
mat << std::endl;
45 Eigen::VectorXd
mat(
R);
48 if (
verbose) std::cout <<
"EigenMat = " <<
mat << std::endl;
54 for (
int r = 0;
r < 3; ++
r)
55 for (
int c = 0;
c < 3; ++
c)
mat(
r,
c) =
r * 3 +
c;
57 if (
verbose) std::cout <<
"EigenMat = " <<
mat << std::endl;
61 template <
typename MatType>
63 if (
verbose) std::cout <<
"EigenMat = " <<
M << std::endl;
64 return Eigen::MatrixXd(
M);
67 template <
typename MatrixDerived>
68 MatrixDerived
base(
const Eigen::MatrixBase<MatrixDerived>& m) {
72 template <
typename MatrixDerived>
73 MatrixDerived
plain(
const Eigen::PlainObjectBase<MatrixDerived>& m) {
77 template <
typename Scalar>
79 typedef Eigen::Matrix<Scalar, 6, 6> ReturnType;
80 return ReturnType::Constant(
value);
83 template <
typename Scalar>
84 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
86 const Eigen::DenseIndex
cols) {
87 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
90 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
91 Eigen::Map<Vector>(
A.data(),
A.size()) =
92 Vector::LinSpaced(
A.size(), 1,
static_cast<Scalar
>(
A.size()));
93 std::cout <<
"Matrix values:\n" <<
A << std::endl;
97 template <
typename Scalar>
98 Eigen::Matrix<Scalar, 1, Eigen::Dynamic, Eigen::RowMajor>
100 typedef Eigen::Matrix<Scalar, 1, Eigen::Dynamic, Eigen::RowMajor>
102 RowMajorVector
A(size);
103 A.setLinSpaced(size, 1,
static_cast<Scalar
>(size));
104 std::cout <<
"Vector values: " <<
A.transpose() << std::endl;
108 template <
typename Scalar>
110 const Eigen::DenseIndex
rows,
const Eigen::DenseIndex
cols) {
111 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> ColMajorMatrix;
113 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
114 Eigen::Map<Vector>(
A.data(),
A.size()) =
115 Vector::LinSpaced(
A.size(), 1,
static_cast<Scalar
>(
A.size()));
116 std::cout <<
"Matrix values:\n" <<
A << std::endl;
120 template <
typename Scalar>
122 const Eigen::DenseIndex size) {
123 typedef Eigen::Matrix<Scalar, 1, Eigen::Dynamic> ColMajorVector;
124 ColMajorVector
A(size);
125 A.setLinSpaced(size, 1,
static_cast<Scalar
>(size));
126 std::cout <<
"Vector values: " <<
A.transpose() << std::endl;
130 template <
typename Matrix,
typename ReturnMatrix>
131 ReturnMatrix
copy(
const Eigen::MatrixBase<Matrix>&
mat) {
136 using namespace Eigen;
141 typedef Eigen::Matrix<double, 6, 6> Matrix6;
142 eigenpy::enableEigenPySpecific<Matrix6>();
145 typedef Eigen::Matrix<double, 4, 6> Matrix46;
146 eigenpy::enableEigenPySpecific<Matrix46>();
148 Eigen::MatrixXd (*naturalsXX)(int, int, bool) =
naturals;
149 Eigen::VectorXd (*naturalsX)(int, bool) =
naturals;
150 Eigen::Matrix3d (*naturals33)(bool) =
naturals;
152 bp::def(
"vector1x1", vector1x1<double>);
153 bp::def(
"matrix1x1", matrix1x1<double>);
154 bp::def(
"matrix1x1", matrix1x1_input<double>);
155 bp::def(
"matrix1x1_int", matrix1x1_input<int>);
157 bp::def(
"naturals", naturalsXX);
158 bp::def(
"naturalsX", naturalsX);
159 bp::def(
"naturals33", naturals33);
161 bp::def(
"reflex", reflex<Eigen::MatrixXd>);
162 bp::def(
"reflexV", reflex<Eigen::VectorXd>);
163 bp::def(
"reflex33", reflex<Eigen::Matrix3d>);
164 bp::def(
"reflex3", reflex<Eigen::Vector3d>);
169 bp::def(
"base", base<VectorXd>);
170 bp::def(
"base", base<MatrixXd>);
172 bp::def(
"plain", plain<VectorXd>);
173 bp::def(
"plain", plain<MatrixXd>);
175 bp::def(
"matrix6", matrix6<double>);
177 bp::def(
"generateRowMajorMatrix", generateRowMajorMatrix<double>);
178 bp::def(
"generateRowMajorVector", generateRowMajorVector<double>);
180 bp::def(
"generateColMajorMatrix", generateColMajorMatrix<double>);
181 bp::def(
"generateColMajorVector", generateColMajorVector<double>);
183 typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
185 bp::def(
"asRowMajorFromColMajorMatrix",
186 copy<Eigen::MatrixXd, RowMajorMatrixXd>);
187 bp::def(
"asRowMajorFromColMajorVector",
188 copy<Eigen::VectorXd, Eigen::RowVectorXd>);
189 bp::def(
"asRowMajorFromRowMajorMatrix",
190 copy<RowMajorMatrixXd, RowMajorMatrixXd>);
191 bp::def(
"asRowMajorFromRowMajorVector",
192 copy<Eigen::RowVectorXd, Eigen::RowVectorXd>);