ADD: added other eigen lib

This commit is contained in:
Henry Winkel
2022-12-21 16:19:04 +01:00
parent a570766dc6
commit 9e56c7f2c0
832 changed files with 36586 additions and 20006 deletions

View File

@@ -1,27 +1,25 @@
#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
template<typename Derived>
Eigen::Block<Derived>
topLeftCorner(MatrixBase<Derived>& m, int rows, int cols)
topLeftCorner(Eigen::MatrixBase<Derived>& m, int rows, int cols)
{
return Eigen::Block<Derived>(m.derived(), 0, 0, rows, cols);
}
template<typename Derived>
const Eigen::Block<const Derived>
topLeftCorner(const MatrixBase<Derived>& m, int rows, int cols)
topLeftCorner(const Eigen::MatrixBase<Derived>& m, int rows, int cols)
{
return Eigen::Block<const Derived>(m.derived(), 0, 0, rows, cols);
}
int main(int, char**)
{
Matrix4d m = Matrix4d::Identity();
cout << topLeftCorner(4*m, 2, 3) << endl; // calls the const version
Eigen::Matrix4d m = Eigen::Matrix4d::Identity();
std::cout << topLeftCorner(4*m, 2, 3) << std::endl; // calls the const version
topLeftCorner(m, 2, 3) *= 5; // calls the non-const version
cout << "Now the matrix m is:" << endl << m << endl;
std::cout << "Now the matrix m is:" << std::endl << m << std::endl;
return 0;
}