Ejemplo n.º 1
0
static size_t stem(char *p, size_t i, size_t j) {

    b  = p;
    k  = j;
    k0 = i; /* copy the parameters into statics */

    /*
     * DEPARTURE: This next 'if' statement prevents strings of length 1 or 2 from
     * going through the stemming process, although no mention is made of this in the
     * published algorithm. Remove the line to match the publishedalgorithm.
     */

    if (k <= k0 + 1)
        return k;

    step1ab();
    if (k > k0) {
        step1c();
        step2();
        step3();
        step4();
        step5();
    }

    return k;
}
Ejemplo n.º 2
0
// Subclasses can override
void step(Stepper_t* motor, long step)
{
    switch (motor->_interface)
    {
        case FUNCTION:
            step0(motor, step);
            break;

		case DRIVER:
			step1(motor, step);
			break;

		case FULL2WIRE:
			step2(motor, step);
			break;

		case FULL3WIRE:
			step3(motor, step);
			break;

		case FULL4WIRE:
			step4(motor, step);
			break;

		case HALF3WIRE:
			step6(motor, step);
			break;

		case HALF4WIRE:
			step8(motor, step);
			break;
    }
}
Ejemplo n.º 3
0
Archivo: stmr.c Proyecto: wooorm/stmr.c
/* In `stem(p, i, j)`, `p` is a `char` pointer, and the
 * string to be stemmed is from `p[i]` to
 * `p[j]` (inclusive).
 *
 * Typically, `i` is zero and `j` is the offset to the
 * last character of a string, `(p[j + 1] == '\0')`.
 * The stemmer adjusts the characters `p[i]` ... `p[j]`
 * and returns the new end-point of the string, `k`.
 *
 * Stemming never increases word length, so `i <= k <= j`.
 *
 * To turn the stemmer into a module, declare 'stem' as
 * extern, and delete the remainder of this file. */
int
stem(char *p, int index, int position) {
  /* Copy the parameters into statics. */
  b = p;
  k = position;
  k0 = index;

  if (k <= k0 + 1) {
    return k; /* --DEPARTURE-- */
  }

  /* With this line, strings of length 1 or 2 don't
   * go through the stemming process, although no
   * mention is made of this in the published
   * algorithm. Remove the line to match the published
   * algorithm. */
  step1ab();

  if (k > k0) {
    step1c();
    step2();
    step3();
    step4();
    step5();
  }

  return k;
}
Ejemplo n.º 4
0
END_TEST

START_TEST (test_step3)
{
    double d = (double) rand();
    fail_unless( step3(d) == pow(d, d), "Step 3 does not exponentiate" );
}
Ejemplo n.º 5
0
/* In stem(p,i,j), p is a char pointer, and the string to be stemmed is from
   p[i] to p[j] inclusive. Typically i is zero and j is the offset to the last
   character of a string, (p[j+1] == '\0'). The stemmer adjusts the
   characters p[i] ... p[j] and returns the new end-point of the string, k.
   Stemming never increases word length, so i <= k <= j. To turn the stemmer
   into a module, declare 'stem' as extern, and delete the remainder of this
   file.
*/
static ssize_t
stem(char *s, size_t z)
{
	/* copy the parameters into statics */
	b = s;
	k = z - 1;
	k0 = 0;

	if (k <= k0 + 1) {
		/*-DEPARTURE-*/
		return k;
	}

	/* With this line, strings of length 1 or 2 don't go through the
	   stemming process, although no mention is made of this in the
	   published algorithm. Remove the line to match the published
	   algorithm. */
	step1ab();
	step1c();
	step2();
	step3();
	step4();
	step5();
	return k;
}
Ejemplo n.º 6
0
void step5(double *assignment, double *distMatrix, char *starMatrix, char *newStarMatrix, char *primeMatrix, char *coveredColumns, char *coveredRows, int nOfRows, int nOfColumns, int minDim)
{
	double h, value;
	int row, col;

	/* find smallest uncovered element h */
	h = INFINITY;
	for(row=0; row<nOfRows; row++)
		if(!coveredRows[row])
			for(col=0; col<nOfColumns; col++)
				if(!coveredColumns[col])
				{
					value = distMatrix[row + nOfRows*col];
					if(value < h)
						h = value;
				}

	/* add h to each covered row */
	for(row=0; row<nOfRows; row++)
		if(coveredRows[row])
			for(col=0; col<nOfColumns; col++)
				distMatrix[row + nOfRows*col] += h;

	/* subtract h from each uncovered column */
	for(col=0; col<nOfColumns; col++)
		if(!coveredColumns[col])
			for(row=0; row<nOfRows; row++)
				distMatrix[row + nOfRows*col] -= h;

	/* move to step 3 */
	step3(assignment, distMatrix, starMatrix, newStarMatrix, primeMatrix, coveredColumns, coveredRows, nOfRows, nOfColumns, minDim);
}
Ejemplo n.º 7
0
// Subclasses can override
void AccelStepper::step(long step)
{
    switch (_interface)
    {
        case FUNCTION:
            step0(step);
            break;

	case DRIVER:
	    step1(step);
	    break;
    
	case FULL2WIRE:
	    step2(step);
	    break;
    
	case FULL3WIRE:
	    step3(step);
	    break;  

	case FULL4WIRE:
	    step4(step);
	    break;  

	case HALF3WIRE:
	    step6(step);
	    break;  
		
	case HALF4WIRE:
	    step8(step);
	    break;  
    }
}
Ejemplo n.º 8
0
int main(int argc, char **argv)
{

  int NX,NY,NZ;
  MPI_Init (&argc, &argv);
  int nprocs, procid;
  MPI_Comm_rank(MPI_COMM_WORLD, &procid);
  MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

  /* Parsing Inputs  */
  if(argc==1){
    NX=128;NY=128;NZ=128;
  }
  else{
    NX=atoi(argv[1]); NY=atoi(argv[2]); NZ=atoi(argv[3]);
  }
  int N[3]={NX,NY,NZ};

  int nthreads=1;
  step3(N,nthreads);

  MPI_Finalize();
  return 0;

} // end main
Ejemplo n.º 9
0
    String BrazilianStemmer::stem(const String& term)
    {
        // creates CT
        createCT(term);

        if (!isIndexable(CT))
            return L"";
        if (!isStemmable(CT))
            return CT;

        R1 = getR1(CT);
        R2 = getR1(R1);
        RV = getRV(CT);
        TERM = term + L";" + CT;

        bool altered = step1();
        if (!altered)
            altered = step2();

        if (altered)
            step3();
        else
            step4();

        step5();

        return CT;
    }
Ejemplo n.º 10
0
void Munkres::step5(int i, int j) {
	/* take a primed zero, and construct a list of...
	 * 1. a starred zero in it's column (if it exists)
	 * 2. if there's a starred zero there will be a primed zero in its row.
	 *
	 * then
	 * unstar the starred,
	 * star all the primes
	 * erase all primes
	 * uncover everything
	 * return to step 3.
	 */
	std::vector<path_item> path;
	path.push_back(path_item(i, j, PRIMED));
	bool done = false;
	int row = 0;
	int col = j;
	while (!done) {
		row = find_starred_zero_in_col(col);
		if (row != -1) {
			path.push_back(path_item(row, col, STARRED));
			col = find_primed_zero_in_row(row);
			path.push_back(path_item(row, col, PRIMED));
		} else {
			done = true;
		}
	}

	for (unsigned int i = 0; i < path.size(); i++) {
		path_item item = path[i];
		if (item.type == PRIMED) // primed so we star
		{
			starred[item.row][item.col] = 1;
		} else { // we're starred so we unstar
			starred[item.row][item.col] = 0;
		}
	}
	// remove all primes
	for (unsigned int i = 0; i < rows; i++) {
		for (unsigned int j = 0; j < cols; j++) {
			primed[i][j] = 0;
		}
	}
	for (unsigned int i = 0; i < rows; i++) {
		covered_rows[i] = 0;
	}
	// uncover all covered lines
	for (unsigned int i = 0; i < rows; i++) {
		covered_rows[i] = 0;
	}
	for (unsigned int i = 0; i < cols; i++) {
		covered_cols[i] = 0;
	}
	step3();
}
Ejemplo n.º 11
0
int stem(char * p, int i, int j)
{  b = p; k = j; k0 = i; /* copy the parameters into statics */
   if (k <= k0+1) return k; /*-DEPARTURE-*/

   /* With this line, strings of length 1 or 2 don't go through the
      stemming process, although no mention is made of this in the
      published algorithm. Remove the line to match the published
      algorithm. */

   step1ab(); step1c(); step2(); step3(); step4(); step5();
   return k;
}
Ejemplo n.º 12
0
int do_steps()
{
	int result;
	unit_test();
	result=step1();
	if(result==IDC_NEXT){
		result=step2();
		if(result==IDC_NEXT){
			result=step3();
		}
	}
	return 0;
}
Ejemplo n.º 13
0
extern int stem_ts(struct stemmer * z, char * b, int k)
{
   if (k <= 1) return k; /*-DEPARTURE-*/
   z->b = b; z->k = k; /* copy the parameters into z */

   /* With this line, strings of length 1 or 2 don't go through the
      stemming process, although no mention is made of this in the
      published algorithm. Remove the line to match the published
      algorithm. */

   step1ab(z); step1c(z); step2(z); step3(z); step4(z); step5(z);
   return z->k;
}
// --------------------------------------------------------------------------
// Function Name : step5
// Auther : chen chen
// Data : 2016-02-15
// --------------------------------------------------------------------------
void AssignmentProblemSolver::step5(int *assignment, double *distMatrix, bool *starMatrix, bool *newStarMatrix, bool *primeMatrix, bool *coveredColumns, bool *coveredRows, int nOfRows, int nOfColumns, int minDim)
{
    double h, value;
    int row, col;
    /* find smallest uncovered element h */
    h = DBL_MAX;
    for(row = 0; row < nOfRows; row++)
    {
        if(!coveredRows[row])
        {
            for(col = 0; col < nOfColumns; col++)
            {
                if(!coveredColumns[col])
                {
                    value = distMatrix[row + nOfRows*col];
                    if(value < h)
                    {
                        h = value;
                    }
                }
            }
        }
    }

    /* add h to each covered row */
    for(row=0; row<nOfRows; row++)
    {
        if(coveredRows[row])
        {
            for(col = 0; col < nOfColumns; col++)
            {
                distMatrix[row + nOfRows*col] += h;
            }
        }
    }

    /* subtract h from each uncovered column */
    for(col = 0; col < nOfColumns; col++)
    {
        if(!coveredColumns[col])
        {
            for(row=0; row<nOfRows; row++)
            {
                distMatrix[row + nOfRows*col] -= h;
            }
        }
    }

    /* move to step 3 */
    step3(assignment, distMatrix, starMatrix, newStarMatrix, primeMatrix, coveredColumns, coveredRows, nOfRows, nOfColumns, minDim);
}
Ejemplo n.º 15
0
	 bool PorterStemmer::stem() {
    //i = strlen(b);
		 k = i -1;
    k0 = 0;
    if (k > k0+1) {
      step1(); step2(); step3(); step4(); step5(); step6();
    }
    // Also, a word is considered dirty if we lopped off letters
    // Thanks to Ifigenia Vairelles for pointing this out.
    if (i != k+1)
      dirty = true;
    i = k+1;
    return dirty;
  }
Ejemplo n.º 16
0
/* nml: this function slightly modified to not require external stemmer 
 * structure or length count (accepts NUL-terminated term) */
void stem_porters(void *opaque, char *term) {
   struct stemmer z;

   z.b = term; z.k = str_len(term) - 1; /* copy the parameters into z */
   if (z.k <= 1) return; /*-DEPARTURE-*/

   /* With this line, strings of length 1 or 2 don't go through the
      stemming process, although no mention is made of this in the
      published algorithm. Remove the line to match the published
      algorithm. */

   step1ab(&z); step1c(&z); step2(&z); step3(&z); step4(&z); step5(&z);
   term[z.k + 1] = '\0';  /* zero-terminate string */
}
Ejemplo n.º 17
0
static void step5(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
		  mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
		  int dmin)
{
	int h = 0, value;
	int row, col, found = 0;

	/* find smallest uncovered element h */
	for (row = 0; row < nrows; row++) {
		if (GET1(crow, row))
			continue;
		for (col = 0; col < ncols; col++) {
			if (GET1(ccol, col))
				continue;
			value = mdist[row + nrows * col];
			if (!found || value < h) {
				h = value;
				found = 1;
			}
		}
	}

	/* where to go if nothing uncovered? */
	if (!found)
		return;

	/* add h to each covered row */
	for (row = 0; row < nrows; row++) {
		if (!GET1(crow, row))
			continue;
		for (col = 0; col < ncols; col++)
			mdist[row + nrows * col] += h;
	}

	/* subtract h from each uncovered column */
	for (col = 0; col < ncols; col++) {
		if (GET1(ccol, col))
			continue;
		for (row = 0; row < nrows; row++)
			mdist[row + nrows * col] -= h;
	}

	/* move to step 3 */
	step3(ix, mdist, mstar, nmstar,
	      mprime, ccol, crow, nrows, ncols,
	      dmin);
}
Ejemplo n.º 18
0
wchar_t*
s_stem(wchar_t *word) {
	wchar_t* copy;

	copy = malloc(sizeof(*copy) * (wcslen(word)+1));
	wcscpy(copy, word);	
	
	step1a(copy);
	step1b(copy);
	step1c(copy);
	step2(copy);
	step3(copy);
	step4(copy);
	step5(copy);
	
	return copy;
}
Ejemplo n.º 19
0
KuhnMunkres::Indexes KuhnMunkres::calculate(const Grid &grid)
{
    grid_ = grid;
    const Dimensions dimensions = ensure_grid_is_square();
    size = static_cast<int>(grid_.size());
#ifdef USE_STL
    row_covered.resize(size, false);
    column_covered.resize(size, false);
#else
    row_covered.fill(false, size);
    column_covered.fill(false, size);
#endif
    z0_row = 0;
    z0_column = 0;
    path = make_grid(size * 2, static_cast<int>(ZERO));
    marked = make_grid(size, static_cast<int>(ZERO));

    int step = 1;
    while (step) {
        switch (step) {
            case 1: step = step1(); break;
            case 2: step = step2(); break;
            case 3: step = step3(); break;
            case 4: step = step4(); break;
            case 5: step = step5(); break;
            case 6: step = step6(); break;
            default: break;
        }
    }

    Indexes indexes;
    for (int row = 0; row < size; ++row) {
        for (int column = 0; column < size; ++column) {
            if ((row < dimensions.first) &&
                (column < dimensions.second) &&
                marked.at(row).at(column) == STAR)
#ifdef USE_STL
                indexes.push_back(std::make_pair(row, column));
#else
                indexes.push_back(qMakePair(row, column));
#endif
        }
    }
    return indexes;
}
Ejemplo n.º 20
0
void Munkres::step2() {
	/*
	 * find a zero, if now starred zeros in row or column star z
	 * repeat for each element.
	 *
	 * goto step 3
	 */
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols; j++) {

			if (cost[i][j] == 0) {
				if (!is_starred_in_row_col(i, j)) {
					starred[i][j] = 1;
				}
			}
		}
	}
	step3();
}
Ejemplo n.º 21
0
void step2b(double *assignment, double *distMatrix, char *starMatrix, char *newStarMatrix, char *primeMatrix, char *coveredColumns, char *coveredRows, int nOfRows, int nOfColumns, int minDim)
{
	int col, nOfCoveredColumns;

	/* count covered columns */
	nOfCoveredColumns = 0;
	for(col=0; col<nOfColumns; col++)
		if(coveredColumns[col])
			nOfCoveredColumns++;

	if(nOfCoveredColumns == minDim)
	{
		/* algorithm finished */
		buildassignmentvector(assignment, starMatrix, nOfRows, nOfColumns);
	}
	else
	{
		/* move to step 3 */
		step3(assignment, distMatrix, starMatrix, newStarMatrix, primeMatrix, coveredColumns, coveredRows, nOfRows, nOfColumns, minDim);
	}

}
Ejemplo n.º 22
0
    String FrenchStemmer::stem(const String& term)
    {
        if (!isStemmable(term))
            return term;
        
        // Use lowercase for medium stemming.
        stringBuffer = StringUtils::toLower(term);

        // reset the booleans
        modified = false;
        suite = false;

        treatVowels(stringBuffer);

        setStrings();

        step1();

        if (!modified || suite)
        {
            if (!RV.empty())
            {
                suite = step2a();
                if (!suite)
                    step2b();
            }
        }

        if (modified || suite)
            step3();
        else
            step4();

        step5();

        step6();

        return stringBuffer;
    }
Ejemplo n.º 23
0
static void step2b(int *ix, int *mdist, mat_t mstar, mat_t nmstar,
		   mat_t mprime, col_t ccol, col_t crow, int nrows, int ncols,
		   int dmin)
{
	int col, ncc;

	/* count covered columns */
	ncc = 0;
	for (col = 0; col < ncols; col++)
		if (GET1(ccol, col))
			ncc++;

	if (ncc == dmin) {
		/* algorithm finished */
		buildixvector(ix, mstar, nrows, ncols);
	} else {
		/* move to step 3 */
		step3(ix, mdist, mstar, nmstar,
		      mprime, ccol, crow, nrows, ncols,
		      dmin);
	}

}
Ejemplo n.º 24
0
void DifferentialStepper::step(Motor *motor) {
    switch (_interface)
    {
        case DRIVER:
            step1(motor);
            break;
        case FULL2WIRE:
            step2(motor);
            break;
        case FULL3WIRE:
            step3(motor);
            break;
        case FULL4WIRE:
            step4(motor);
            break;
        case HALF3WIRE:
            step6(motor);
            break;
        case HALF4WIRE:
            step8(motor);
            break;
    }
}
// --------------------------------------------------------------------------
// Function Name : step2b
// Auther : chen chen
// Data : 2016-02-15
// --------------------------------------------------------------------------
void AssignmentProblemSolver::step2b(int *assignment, double *distMatrix, bool *starMatrix, bool *newStarMatrix, bool *primeMatrix, bool *coveredColumns, bool *coveredRows, int nOfRows, int nOfColumns, int minDim)
{
    /* count covered columns */
    int col, nOfCoveredColumns;
    nOfCoveredColumns = 0;

    for(col = 0; col < nOfColumns; col++)
    {
        if(coveredColumns[col])
        {
            nOfCoveredColumns++;
        }
    }
    if(nOfCoveredColumns == minDim)
    {
        /* algorithm finished */
        buildassignmentvector(assignment, starMatrix, nOfRows, nOfColumns);
    }
    else
    {
        /* move to step 3 */
        step3(assignment, distMatrix, starMatrix, newStarMatrix, primeMatrix, coveredColumns, coveredRows, nOfRows, nOfColumns, minDim);
    }
}
void	ProcessingStepTest::testDependency() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testDependency() begin");
	ProcessingStepPtr	step1(new ProcessingStep());
	ProcessingStepPtr	step2(new ProcessingStep());
	ProcessingStepPtr	step3(new ProcessingStep());
	ProcessingStepPtr	step4(new ProcessingStep());
	step1->add_successor(step2);
	step1->add_successor(step3);
	step4->add_precursor(step2);
	step4->add_precursor(step3);
	step1->status(ProcessingStep::needswork);
	CPPUNIT_ASSERT(step2->status() == ProcessingStep::idle);
	CPPUNIT_ASSERT(step3->status() == ProcessingStep::idle);
	CPPUNIT_ASSERT(step4->status() == ProcessingStep::idle);
	step1->work();
	CPPUNIT_ASSERT(step1->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step2->status() == ProcessingStep::needswork);
	CPPUNIT_ASSERT(step3->status() == ProcessingStep::needswork);
	CPPUNIT_ASSERT(step4->status() == ProcessingStep::idle);
	step2->work();
	CPPUNIT_ASSERT(step1->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step2->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step3->status() == ProcessingStep::needswork);
	CPPUNIT_ASSERT(step4->status() == ProcessingStep::idle);
	step3->work();
	CPPUNIT_ASSERT(step1->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step2->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step3->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step4->status() == ProcessingStep::needswork);
	step4->work();
	CPPUNIT_ASSERT(step1->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step2->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step3->status() == ProcessingStep::complete);
	CPPUNIT_ASSERT(step4->status() == ProcessingStep::complete);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testDependency() end");
}
assignment_set navigational_formula_eval(parser::pattern& pattern,
    const string& document, vector<pair<string, span>>& prefix_assignment,
    bool benchmark) {
  // Check for backreferences
  bool alternate_algorithm = pattern.has_backreference();

  // Transform to normal form
  normal_pattern normal = pattern_normal_form(pattern);

  // Match prefix
  auto prefix_end = prefix_step(normal.prefix, prefix_assignment,
      document.begin(), document.end());
  size_t offset = distance(document.begin(), prefix_end);

  // Quit if there are no groups
  if (normal.groups.empty())
    return assignment_set(0);

  logger l(benchmark);

  auto B = step1(normal.groups, prefix_end, document.end());
  l.log("Step 1");

  auto C = step2(B, prefix_end, document.end());
  l.log("Step 2");

  auto R = step3(C, prefix_end, document.end());
  l.log("Step 3");

  auto ans = alternate_algorithm
    ? step4alt(C, R, offset, document)
    : step4(C, R, offset);
  l.log("Step 4");

  return ans;
}
Ejemplo n.º 28
0
void _HungarianAlgorithm<VAL>::solve(std::map<int,int>& o_result)
{
	for(int i=0; i<m_size; i++)
		m_mask[i] = 0;

	int step = 1;
	int nbOps = 0;
	while(step > 0)
	{
		//std::cout << "===== step " << step << " =====" << std::endl;

		if(nbOps%5000 == 0 && nbOps != 0)
			std::cout << "still alive ! (nbOps = " << nbOps << ")" << std::endl;

		switch(step)
		{
			case 1:
				step = step1();
				break;
			case 2:
				step = step2();
				break;
			case 3:
				step = step3();
				break;
			case 4:
				step = step4();
				break;
			case 5:
				step = step5();
				break;
			default:
				step = 0;
		}

		nbOps++;

//		 for(int j=0; j<m_height; j++)
//		 {
//			 for(int i=0; i<m_width; i++)
//			 {
//				 std::cout << m_matrix[j*m_height+i] << "\t";
//			 }
//			 std::cout << std::endl;
//		 }
//		 for(int j=0; j<m_height; j++)
//		 {
//			 for(int i=0; i<m_width; i++)
//			 {
//				 std::cout << m_mask[j*m_height+i] << "\t";
//			 }
//			 std::cout << std::endl;
//		}
//		std::cout<<"row : ";
//		for(int j=0; j<m_height; j++)
//			std::cout<<m_mask_row[j]<<" ";
//		std::cout<<std::endl<<"col : ";
//		for(int j=0; j<m_width; j++)
//			std::cout<<m_mask_col[j]<<" ";
//		std::cout<<std::endl;
	}

	for(int j=0; j<m_height; j++)
		for(int i=0; i<m_width; i++)
			if(m_mask[j*m_height+i] == 1)
				o_result[i] = j;
}
Ejemplo n.º 29
0
void 
Munkres::solve(Matrix<double> &m) {
  // Linear assignment problem solution
  // [modifies matrix in-place.]
  // matrix(row,col): row major format assumed.

  // Assignments are remaining 0 values
  // (extra 0 values are replaced with -1)
#ifdef DEBUG
  std::cout << "Munkres input matrix:" << std::endl;
  for ( int row = 0 ; row < m.rows() ; row++ ) {
    for ( int col = 0 ; col < m.columns() ; col++ ) {
      std::cout.width(8);
      std::cout << m(row,col) << ",";
    }
    std::cout << std::endl;
  }
  std::cout << std::endl;
#endif

  double highValue = 0;
  for ( int row = 0 ; row < m.rows() ; row++ ) {
    for ( int col = 0 ; col < m.columns() ; col++ ) {
      if ( m(row,col) != INFINITY && m(row,col) > highValue )
        highValue = m(row,col);
    }
  }
  highValue++;
  
  for ( int row = 0 ; row < m.rows() ; row++ )
    for ( int col = 0 ; col < m.columns() ; col++ )
      if ( m(row,col) == INFINITY )
        m(row,col) = highValue;

  bool notdone = true;
  int step = 1;

  this->matrix = m;
  // STAR == 1 == starred, PRIME == 2 == primed
  mask_matrix.resize(matrix.rows(), matrix.columns());

  row_mask = new bool[matrix.rows()];
  col_mask = new bool[matrix.columns()];
  for ( int i = 0 ; i < matrix.rows() ; i++ ) {
    row_mask[i] = false;
  }

  for ( int i = 0 ; i < matrix.columns() ; i++ ) {
    col_mask[i] = false;
  }

  while ( notdone ) {
    switch ( step ) {
      case 0:
        notdone = false;
        break;
      case 1:
        step = step1();
        break;
      case 2:
        step = step2();
        break;
      case 3:
        step = step3();
        break;
      case 4:
        step = step4();
        break;
      case 5:
        step = step5();
        break;
    }
  }

  // Store results
  for ( int row = 0 ; row < matrix.rows() ; row++ )
    for ( int col = 0 ; col < matrix.columns() ; col++ )
      if ( mask_matrix(row,col) == STAR )
        matrix(row,col) = 0;
      else
        matrix(row,col) = -1;

#ifdef DEBUG
  std::cout << "Munkres output matrix:" << std::endl;
  for ( int row = 0 ; row < matrix.rows() ; row++ ) {
    for ( int col = 0 ; col < matrix.columns() ; col++ ) {
      std::cout.width(1);
      std::cout << matrix(row,col) << ",";
    }
    std::cout << std::endl;
  }
  std::cout << std::endl;
#endif

  m = matrix;

  delete [] row_mask;
  delete [] col_mask;
}
Ejemplo n.º 30
0
double do_stuff( double i ) { return step3( step2( step1( i ) ) ); }