Example #1
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;  
    }
}
Example #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;
    }
}
Example #3
0
void Munkres::step4() {
	/* find an uncovered zero and prime it
	 * if now starred zeros in row goto step 5
	 * else cover row and uncover colum of starred zero
	 *
	 * once no uncovered exist goto step 6.
	 */
	bool done = false;
	int i = 0;
	int j = 0;
	int a;
	while (!done) {
		if (find_zero(&i, &j)) {
			if (!is_covered(i, j)) {
				prime(i, j);
				a = starred_in_row(i);
				if (a == -1) // if no starred zeros
				{
					done = true;
					step5(i, j);
				} else {
					uncover_col(a);
					cover_row(i);
				}

			}
		} else {
			done = true;
			step6( min_uncovered());
		}
	}
}
	 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;
  }
Example #5
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;
}
    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;
    }
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;
    }
}
//Find a noncovered zero and prime it
//if there isn't a starred zero in its row then goto step 5
//if there is then cover the current row and uncover the column with the starred zero
//then look for more uncovered zeros
//if there are no uncovered zeros we go to step 6
bool munkres::step4(void)
{
	//To find the smallest uncovered value
	int smallest = 0;
	
	//iterate through rows
	for (int i = 0; i < num_rows; i++)
	{
		//if the current row isn't covered
		if (!row_cov[i])
		{
			
			//set smallest = first element in the current row
			while (smallest == 0){
				smallest = cell_array[i][0].weight;
				//if the first element is 0 then increase the row
				if (smallest == 0)
				{
					if (i < num_rows-1)
						i++;
					else
						break;
				}
			}
			
			//iterate through columns
			for (int j = 0; j < num_columns; j++)
			{
				//if the column and row aren't covered, the current index is zero,
				//and there isn't a star in the current row,
				//then prime the current index and go to step 5
				if (!column_cov[j] && !row_cov[i] && cell_array[i][j].weight == 0 && !row_starred[i])
				{
					//prime current index
					cell_array[i][j].primed = true;
					
					//if a primed zero with no star in the row exists
					//goto step 5
					if (diag_on)
					{
					std::cerr << "Step 4: " << i << ",  " << j <<std::endl;
					diagnostic(6);
					}
					return step5(i, j);
					
					
					
				}
				
				//if the column and row aren't covered, the current index is zero,
				//and there is a star in the current row,
				//then prime the current index, cover the current row,
				//and uncover the column with the starred zero
				//also reset indeces to 0 to look for zeros that may have been uncovered
				else if (!column_cov[j] && !row_cov[i] && cell_array[i][j].weight == 0)
				{
					//prime current index
					cell_array[i][j].primed = true;
					//cover current row
					row_cov[i] = true;
					//uncover column with starred zero
					column_cov[find_star_row(i)] = false;
					i = 0;
					j = 0;
				}
				
				//if the column isn't covered, the current index isn't zero,
				//and the current index is smaller than smallest so far,
				//then set smallest == current index
				else if (!column_cov[j] && cell_array[i][j].weight != 0 && cell_array[i][j].weight < smallest)
				{
					//set smallest == current index
					smallest = cell_array[i][j].weight;
				}
			}
		}
	}
	
	if (diag_on)
	{
		std::cerr << "Step 4" << std::endl;
		diagnostic(6);
	}
	
	//if we don't go to step 5 then go to step 6
	return step6(smallest);
}