#pragma once #include #ifdef HAVE_EIGEN # include #endif namespace pangolin { // Scalar / Vector agnostic static_cast-like thing // // e.g. Promote float to double: // ComponentCast::cast(0.14f); // // e.g. Promote Eigen::Vector2f to Eigen::Vector2d: // ComponentCast::cast(Eigen::Vector2f(0.1,0.2); template struct ComponentCast { PANGO_HOST_DEVICE static To cast(const From& val) { return static_cast(val); } }; #ifdef HAVE_EIGEN template struct ComponentCast > { PANGO_HOST_DEVICE static To cast(const Eigen::MatrixBase& val) { return val.template cast(); } }; #endif }