Esempio n. 1
0
IGL_INLINE void igl::mat_min(
  const Eigen::DenseBase<DerivedX> & X,
  const int dim,
  Eigen::PlainObjectBase<DerivedY> & Y,
  Eigen::PlainObjectBase<DerivedI> & I)
{
  assert(dim==1||dim==2);

  // output size
  int n = (dim==1?X.cols():X.rows());
  // resize output
  Y.resize(n);
  I.resize(n);

  // loop over dimension opposite of dim
  for(int j = 0;j<n;j++)
  {
    typename DerivedX::Index PHONY,i;
    typename DerivedX::Scalar  m;
    if(dim==1)
    {
      m = X.col(j).minCoeff(&i,&PHONY);
    }else
    {
      m = X.row(j).minCoeff(&PHONY,&i);
    }
    Y(j) = m;
    I(j) = i;
  }
}
Esempio n. 2
0
 Label posterior(const Eigen::DenseBase<Derived>& observations,
                 bool normalize = true) const {
   assert(observations.cols() == num_features());
   Label result = prior_;
   for (std::size_t i = 0; i < num_features(); ++i) {
     result *= feature(i).restrict_head(observations.col(i));
     if (normalize) {
       result.normalize();
     }
   }
   return result;
 }