.. _program_listing_file__tmp_ws_src_ecl_core_ecl_linear_algebra_include_ecl_linear_algebra_eigen_plugin.hpp: Program Listing for File plugin.hpp =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/ecl_core/ecl_linear_algebra/include/ecl/linear_algebra/eigen/plugin.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /***************************************************************************** ** Ifdefs *****************************************************************************/ #ifndef ECL_LINEAR_ALGEBRA_EIGEN_PLUGIN_HPP_ #define ECL_LINEAR_ALGEBRA_EIGEN_PLUGIN_HPP_ /***************************************************************************** ** Includes *****************************************************************************/ #include "formatters.hpp" /***************************************************************************** ** Code *****************************************************************************/ typedef MatrixFormatter Formatter; inline void conservativeResize(int rows, int cols) { PlainObject tmp(rows, cols); // alternatively: PlainObject::Zero(rows,cols) const int common_rows = std::min(rows, this->rows()); const int common_cols = std::min(cols, this->cols()); tmp.block(0,0,common_rows,common_cols) = this->block(0,0,common_rows,common_cols); this->derived().swap(tmp); } inline void conservativeResize(int size) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) if (RowsAtCompileTime == 1) { PlainObject tmp(1,size); // alternatively: PlainObject::Zero(1,size) const int common_size = std::min(cols(),size); tmp.block(0,0,1,common_size) = this->block(0,0,1,common_size); this->derived().swap(tmp); } else { PlainObject tmp(size,1); // alternatively: PlainObject::Zero(size,1) const int common_size = std::min(rows(),size); tmp.block(0,0,common_size,1) = this->block(0,0,common_size,1); this->derived().swap(tmp); } } #endif /* ECL_LINEAR_ALGEBRA_EIGEN_PLUGIN_HPP_ */