Ejemplo n.º 1
0
/**
 * Construct Domain Iterator using domain of a given function.
 * This is more efficient that creating from sratch.
 * @param[in] fun Function whose domain should be copied.
 */
DomainIterator::DomainIterator(const DiscreteFunction& fun)
   : vars_i(fun.varBegin(),fun.varEnd()),    // copy variables
     subInd_i(fun.noVars(),0),               // set all subindices to zero
     ind_i(0),                               // set linear index to zero
     fixed_i(fun.noVars(),false),            // all variables are initially free
     sizes_i(fun.sizeBegin(),fun.sizeEnd()), // copy variable sizes
     finished_i(false)                       // iterator is not done yet
   {}                   // nothing left to do in constructor body
Ejemplo n.º 2
0
/**
 * Check that two maxsum::DiscreteFunction objects have the same domain.
 * Two functions have the same domain, if they depend on the same set of
 * variables.
 * @param[in] f1 First function to compare
 * @param[in] f2 Second functions to compare
 * @returns true if both function have the same domain.
 */
bool maxsum::sameDomain(const DiscreteFunction& f1, const DiscreteFunction& f2)
{
   if(f1.noVars()!=f2.noVars())
   {
      return false;
   }

   return std::equal(f1.varBegin(),f1.varEnd(),f2.varBegin());

} // function sameDomain