// Subclasses can override
void AccelStepper::step(uint8_t step)
{
    switch (_interface)
    {
        case FUNCTION:
            step0();
            break;

	case DRIVER:
	    step1(step);
	    break;
    
	case FULL2WIRE:
	    step2(step);
	    break;
    
	case FULL4WIRE:
	    step4(step);
	    break;  

	case HALF4WIRE:
	    step8(step);
	    break;  
    }
}
Example #2
0
File: stmr.c Project: 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;
}
Example #3
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 #4
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;
}
Example #5
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 #6
0
END_TEST

START_TEST (test_step2)
{
    double d = (double) rand();
    fail_unless( step2(d) == (d + d), "Step 2 does not double" );
}
Example #7
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;
}
Example #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;
    step2(N,nthreads);


    MPI_Finalize();
    return 0;
} // end main
Example #9
0
/**
 * Process the first tree (T1) according to Step 2 and Step 4 given in the slides in the first lecture, i.e. defines
 * the DF-numbering and calculating the intervals in all nodes.
 */
Days::node Days::step2(size_t curNode) {
    graph1NodeInfo[curNode].size = 0;
    graph1NodeInfo[curNode].minLabel = inf;
    graph1NodeInfo[curNode].maxLabel = 0;   //< Note that labeling starts at 1, thus no label can ever be 0
    visited[curNode] = true;

    if(curNode!=root && graph1[curNode].size() == 1) {
        // Set the DF-numbering/labeling at the given leaf
        dfsLabels[curNode] = step2Counter;
        // All leafs have size 1 and their label as minimum and maximum labels
        graph1NodeInfo[curNode].size = 1;
        graph1NodeInfo[curNode].minLabel = step2Counter;
        graph1NodeInfo[curNode].maxLabel = step2Counter;
        // Prepare for next leaf
        step2Counter++;
        return graph1NodeInfo[curNode];
    }


    for(size_t neighbour : graph1[curNode]){
        if(!visited[neighbour]){
            node info = step2(neighbour);
            // Update the current information
            graph1NodeInfo[curNode].minLabel = min(graph1NodeInfo[curNode].minLabel, info.minLabel);
            graph1NodeInfo[curNode].maxLabel = max(graph1NodeInfo[curNode].maxLabel, info.maxLabel);
            graph1NodeInfo[curNode].size += info.size;
        }
    }
    // The current node have now all information added
    return graph1NodeInfo[curNode];
    
}
Example #10
0
File: Task.c Project: akssnsk/Test2
void removeComments(char *str)
{
    // check for empty pointer
    if (str == NULL)
        return;

    // check for empty string
    if (str[0] == '\0')
        return;

    long long iR = 0;     // reading position
    long long iW = 0;     // writing position
    State s = State_Code; // initial state

    while (str[iR] != '\0')
    {
        step2(str, &iR, &iW, &s);
        iR++;
    }

    // cut the string
    str[iW] = 0;

    return;
}
    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;
    }
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;
}
Example #13
0
int do_steps()
{
	int result;
	unit_test();
	result=step1();
	if(result==IDC_NEXT){
		result=step2();
		if(result==IDC_NEXT){
			result=step3();
		}
	}
	return 0;
}
Example #14
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;
}
Example #15
0
		void testGetStep()
		{
			qrw::pathfinding::Path path;

			qrw::Coordinates step1(0, 0);
			qrw::Coordinates step2(1, 0);

			path.appendStep(step1);
			path.appendStep(step2);

			CPPUNIT_ASSERT(path.getStep(0) == step1);
			CPPUNIT_ASSERT(path.getStep(1) == step2);
		}
Example #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 */
}
	 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;
  }
 void DutchStemmer::step3b()
 {
     if (R2 >= (int32_t)buffer.length())
         return;
     
     int32_t index = (int32_t)(buffer.length() - 3);
     if ((boost::ends_with(buffer, L"end") || boost::ends_with(buffer, L"ing")) && index >= R2)
     {
         buffer.erase(index, 3);
         if (buffer[index - 2] == L'i' && buffer[index - 1] == L'g')
         {
             if (buffer[index - 3] != L'e' && index - 2 >= R2)
             {
                 index -= 2;
                 buffer.erase(index, 2);
             }
         }
         else
             unDouble(index);
         return;
     }
     index = (int32_t)(buffer.length() - 2);
     if (boost::ends_with(buffer, L"ig") && index >= R2)
     {
         if (buffer[index - 1] != L'e')
             buffer.erase(index, 2);
         return;
     }
     index = (int32_t)(buffer.length() - 4);
     if (boost::ends_with(buffer, L"lijk") && index >= R2)
     {
         buffer.erase(index, 4);
         step2();
         return;
     }
     index = (int32_t)(buffer.length() - 4);
     if (boost::ends_with(buffer, L"baar") && index >= R2)
     {
         buffer.erase(index, 4);
         return;
     }
     index = (int32_t)(buffer.length() - 3);
     if (boost::ends_with(buffer, L"bar") && index >= R2)
     {
         if (removedE)
             buffer.erase(index, 3);
         return;
     }
 }
Example #19
0
void Munkres::step0() {
	int minimum;
	for (int j = 0; j < cols; j++) {
		minimum = cost[0][j];
		for (int i = 0; i < rows; i++) {
			if (minimum > cost[i][j]) {
				minimum = cost[i][j];
			}
		}
		for (int i = 0; i < rows; i++) {
			cost[i][j] = cost[i][j] - minimum;
		}
	}
	k = min_uncovered();
	step2();
}
Example #20
0
		void testPrependStep()
		{
			qrw::pathfinding::Path path;

			qrw::Coordinates step1(0, 0);
			qrw::Coordinates step2(1, 0);

			path.prependStep(step2);
			path.prependStep(step1);

			int counter = 0;
			for(auto step : path)
			{
				CPPUNIT_ASSERT(step.getX() == counter);
				++counter;
			}
		}
Example #21
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;
}
Example #22
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;
}
Example #23
0
// Subclasses can override
void AccelStepper::step(uint8_t step)
{
    switch (_pins)
    {
        case 0:
            step0();
            break;
	case 1:
	    step1(step);
	    break;
    
	case 2:
	    step2(step);
	    break;
    
	case 4:
	    step4(step);
	    break;  
    }
}
Example #24
0
		void testForEach()
		{
			qrw::pathfinding::Path path;

			qrw::Coordinates step1(0, 10);
			qrw::Coordinates step2(1, 11);

			path.appendStep(step1);
			path.appendStep(step2);

			int counter = 0;
			for(auto step : path)
			{
				CPPUNIT_ASSERT(step.getX() == counter);
				CPPUNIT_ASSERT(step.getY() == (counter + 10));
				++counter;
			}

			CPPUNIT_ASSERT(counter == 2);
		}
Example #25
0
void Munkres::step1() {
	/*
	 * subtract the smallest element of each row from that row.
	 * goto step 2
	 */
	for (int i = 0; i < rows; i++) {
		double * a = cost[i];
		double m = std::numeric_limits<double>::infinity();
		for (int cii = 0; cii < cols; cii++) {
			if (m > a[cii]) {
				m = a[cii];
			}
		}

		for (int cii = 0; cii < cols; cii++) {
			a[cii] = a[cii] - m;
		}

	}
	step2();
}
Example #26
0
void Munkres::step1() {
	/*
	 * subtract the smallest element from each row from that row.
	 * goto step 2
	 */
	for(int i=0; i< size; i++)
	{
		std::vector<double > a = cost[i];
		double m = std::numeric_limits<double>::infinity();
		for(int cii=0; cii<a.size(); cii++){
		      if (m > a[cii]){
		    	  m = a[cii];
		      }
		}

		for(int cii=0; cii<a.size(); cii++){
			a[cii] = a[cii] - m;
		}

		cost[i] = a;
	}
	step2();
}
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;
    }
}
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;
}
 // Subclasses can override
 void EightAccelStepper::step(uint8_t step)
 {
     switch (getPins())
     {
         case 0:
             step0();
             break;
         case 1:
             step1(step);
             break;
             
         case 2:
             step2(step);
             break;
             
         case 4:
             step4(step);
             break; 
             
         case 8:
             step8(step);
             break;   
     }
 }
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");
}