mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-21 17:19:36 +08:00

- compatible with current STL's functors as well as with the extention proposal (TR1) * thanks to the above, Cast and ScalarMultiple have been removed * benchmark_suite is more flexible (compiler and matrix size)
23 lines
610 B
C++
23 lines
610 B
C++
#include <Eigen/Core>
|
|
USING_PART_OF_NAMESPACE_EIGEN
|
|
using namespace std;
|
|
|
|
template<typename Scalar, typename Derived>
|
|
const Eigen::CwiseUnaryOp<
|
|
Eigen::ScalarCastOp<typename Eigen::NumTraits<Scalar>::FloatingPoint>,
|
|
Derived
|
|
>
|
|
castToFloatingPoint(const MatrixBase<Scalar, Derived>& m)
|
|
{
|
|
return m.template cast<typename Eigen::NumTraits<Scalar>::FloatingPoint>();
|
|
}
|
|
|
|
int main(int, char**)
|
|
{
|
|
Matrix2i m = Matrix2i::random();
|
|
cout << "Here's the matrix m. It has coefficients of type int."
|
|
<< endl << m << endl;
|
|
cout << "Here's m/20:" << endl << castToFloatingPoint(m)/20 << endl;
|
|
return 0;
|
|
}
|