[eigen] How can I improve this function

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi all,

I have below function and I would like to improve it using Eigen's way. Any suggestion?

Thanks a lot
Hung

  template<typename T>
  void combine(Eigen::Matrix<T, Eigen::Dynamic, 1> & x, const T xval,
           const Eigen::Matrix<T, Eigen::Dynamic, 1> & y, const T yval) {
    const size_t len = x.rows();
    for (size_t idx = 0; idx < len; idx ++) {
      if (x(idx,0) > 0) {
    x(idx,0) = xval;
      } else {
    if (y(idx,0) > 0) x(idx,0) = yval;
      }
    }
  }




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/