Use smaller eigen imports
Many files so far include <Eigen/Dense>
or <Eigen/Eigen>
.
But according to the Eigen website these headers include large parts of the Eigen library, which is seldom needed.
Instead <Eigen/Core>
is usually sufficient.
This MR replaces the includes of <Eigen/Dense>
and <Eigen/Eigen>
with <Eigen/Core>
and adds the necessary additional Eigen headers where they are needed.
That might save a bit compile time, but I didn't measure that.
One disadvantage is that cross
, determinant
and inverse
(among others) are not fully implemented in <Eigen/Core>
, but need <Eigen/LU>
or <Eigen/Geometry>
, and sometimes only the linker will tell if the definition is missing:
ld.lld: error: lib/libMeshLib.so: undefined reference to Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross_product_return_type<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::type Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&) const [--no-allow-shlib-undefined]
ld.lld: error: lib/libGeoLib.so: undefined reference to Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross_product_return_type<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::type Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&) const [--no-allow-shlib-undefined]
ld.lld: error: lib/libMathLib.so: undefined reference to Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross_product_return_type<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::type Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&) const [--no-allow-shlib-undefined]
collect2: error: ld returned 1 exit status
Edited by Christoph Lehmann