34template<
typename T,REM_NAN MA_t>
36removing_nan<T,MA_t>::row_removal(Eigen::Block<Eigen::Matrix<T,-1,-1>,1>& row,
MAT<REM_NAN::MR>)
39 const auto n_not_nan = std::count_if(row.begin(),row.end(),[](T el){return !std::isnan(el);});
40 std::vector<T> el_not_nan;
41 el_not_nan.reserve(n_not_nan);
43 std::copy_if(row.begin(),row.end(),std::back_inserter(el_not_nan),[](T el){return !std::isnan(el);});
45 const T mean = std::accumulate(el_not_nan.begin(),el_not_nan.end(),
static_cast<T
>(0),std::plus{})/
static_cast<T
>(n_not_nan);
48 std::replace_if(row.begin(),row.end(),[](T el){return std::isnan(el);},mean);
56template<
typename T,REM_NAN MA_t>
58removing_nan<T,MA_t>::row_removal(Eigen::Block<Eigen::Matrix<T,-1,-1>,1>& row,
MAT<REM_NAN::ZR>)
60 std::replace_if(row.begin(),row.end(),[](T el){return std::isnan(el);},
static_cast<T
>(0));
Contains the class to remove (dummy and not dummy) NaNs.
std::integral_constant< REM_NAN, MA_t > MAT
Definition removing_nan.hpp:53