For example, assuming we have a matrix type T
, can we create a new type that has only 1 cols like Matrix<..., ..., 1 ,...>
and keep other options exactly the same in type T
?
CodePudding user response:
In this particular case, this should be the simplest form:
using Matrix = Eigen::Matrix<...>; // your type
using Vector = typename Matrix::ColXpr::PlainObject;
CodePudding user response:
After some research I give following solution:
template<typename T1>
auto fun(const Eigen::MatrixBase<T1>& _X)
{
using T = typename T1::PlainObject;
using T2 = Eigen::Matrix<typename T::Scalar,
T::RowsAtCompileTime, T::ColsAtCompileTime,
T::Options, T::MaxRowsAtCompileTime, T::MaxColsAtCompileTime>;
if constexpr (std::is_same_v<T2, T>)
{
std::cout << "True" << std::endl;
}
return T();
}