2007-12-28 16:20:00 +00:00
|
|
|
#include <Eigen/Core>
|
2007-12-24 11:14:25 +00:00
|
|
|
USING_PART_OF_NAMESPACE_EIGEN
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
2008-03-10 17:23:11 +00:00
|
|
|
template<typename Derived>
|
2008-03-06 11:36:27 +00:00
|
|
|
const Eigen::CwiseUnaryOp<
|
2008-03-10 17:23:11 +00:00
|
|
|
Eigen::ScalarCastOp<
|
2008-03-12 17:25:14 +00:00
|
|
|
typename Eigen::NumTraits<typename Derived::Scalar>::FloatingPoint
|
2008-03-10 17:23:11 +00:00
|
|
|
>, Derived
|
2007-12-26 09:25:00 +00:00
|
|
|
>
|
2008-03-10 17:23:11 +00:00
|
|
|
castToFloatingPoint(const MatrixBase<Derived>& m)
|
2007-12-24 11:14:25 +00:00
|
|
|
{
|
2008-03-12 17:25:14 +00:00
|
|
|
return m.template cast<
|
|
|
|
|
typename Eigen::NumTraits<
|
|
|
|
|
typename Derived::Scalar
|
|
|
|
|
>::FloatingPoint
|
2008-03-10 17:23:11 +00:00
|
|
|
>();
|
2007-12-24 11:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int, char**)
|
|
|
|
|
{
|
|
|
|
|
Matrix2i m = Matrix2i::random();
|
|
|
|
|
cout << "Here's the matrix m. It has coefficients of type int."
|
|
|
|
|
<< endl << m << endl;
|
2007-12-26 09:25:00 +00:00
|
|
|
cout << "Here's m/20:" << endl << castToFloatingPoint(m)/20 << endl;
|
2007-12-24 11:14:25 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|