mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 10:09:36 +08:00

1) Eigen2 co-installable with Eigen1 without conflict, without affecting programs including either. 2) #include<Eigen/Core> without the .h without conflict with the Core/ directory 3) Uniformize coding style of the CMakeLists.
26 lines
605 B
C++
26 lines
605 B
C++
#include <Eigen/Core>
|
|
USING_PART_OF_NAMESPACE_EIGEN
|
|
using namespace std;
|
|
|
|
template<typename Scalar, typename Derived>
|
|
const Eigen::Cast<
|
|
typename Eigen::NumTraits<Scalar>::FloatingPoint,
|
|
Derived
|
|
>
|
|
castToFloatingPoint(const MatrixBase<Scalar, Derived>& m)
|
|
{
|
|
return Eigen::Cast<
|
|
typename Eigen::NumTraits<Scalar>::FloatingPoint,
|
|
Derived
|
|
>(m.ref());
|
|
}
|
|
|
|
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;
|
|
}
|