// 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; } }
void Munkres::solve(double* icost, int* answer, int m, int n) { rows = m; cols = n; cost = new double*[rows]; starred = new bool*[rows]; primed = new bool*[rows]; covered_rows = new bool[rows]; covered_cols = new bool[cols]; for (int i = 0; i < rows; i++) { covered_rows[i] = false; } for (int i = 0; i < cols; i++) { covered_cols[i] = false; } for (int i = 0; i < rows; i++) { cost[i] = new double[cols]; starred[i] = new bool[cols]; primed[i] = new bool[cols]; for (int j = 0; j < cols; j++) { cost[i][j] = icost[(i * cols) + j]; starred[i][j] = 0; primed[i][j] = 0; } } smallest = std::min(rows, cols); largest = std::max(rows, cols); if (rows > cols) { step0(); } else { k = min_uncovered(); step1(); } int index = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { answer[index] = starred[i][j]; index++; } } for (int i = 0; i < rows; i++) { delete cost[i]; delete primed[i]; delete starred[i]; } delete cost; delete primed; delete starred; delete covered_rows; delete covered_cols; }
static int iclass_scan (pixma_t * s) { int error, n; iclass_t *mf = (iclass_t *) s->subdriver; uint8_t *buf, ignore; unsigned buf_len, ignore2; if (mf->state != state_idle) return PIXMA_EBUSY; /* clear interrupt packets buffer */ while (handle_interrupt (s, 0) > 0) { } mf->raw_width = ALIGN_SUP (s->param->w, 32); PDBG (pixma_dbg (3, "raw_width = %u\n", mf->raw_width)); n = IMAGE_BLOCK_SIZE / s->param->line_size + 1; buf_len = (n + 1) * s->param->line_size + IMAGE_BLOCK_SIZE; if (buf_len > mf->buf_len) { buf = (uint8_t *) realloc (mf->buf, buf_len); if (!buf) return PIXMA_ENOMEM; mf->buf = buf; mf->buf_len = buf_len; } mf->lineptr = mf->buf; mf->blkptr = mf->buf + n * s->param->line_size; mf->blk_len = 0; error = step1 (s); if (error >= 0 && (s->param->adf_pageid == 0 || mf->generation == 1)) { /* single sheet or first sheet from ADF */ PDBG (pixma_dbg (3, "*iclass_scan***** start scanning *****\n")); error = start_session (s); if (error >= 0) mf->state = state_scanning; if (error >= 0) error = select_source (s); } else if (error >= 0) { /* next sheet from ADF */ PDBG (pixma_dbg (3, "*iclass_scan***** scan next sheet from ADF *****\n")); mf->state = state_scanning; } if (error >= 0) error = send_scan_param (s); if (error >= 0) error = request_image_block (s, 0, &ignore, &ignore2, &ignore, &ignore2); if (error < 0) { iclass_finish_scan (s); return error; } mf->last_block = 0; return 0; }
std::vector<std::vector<bool> > Munkres::solve(std::vector< std::vector<double> > icost) { for(int i=0;i<icost.size();i++) { cost.push_back(std::vector<double>()); starred.push_back(std::vector<bool>()); primed.push_back(std::vector<bool>()); covered_rows.push_back(0); covered_cols.push_back(0); for(int j=0;j<icost[i].size();j++){ cost[i].push_back(icost[i][j]); starred[i].push_back(0); primed[i].push_back(0); } } size = icost.size(); k = min_uncovered(); step1(); // for(int i=0;i<icost.size();i++) { // for(int j=0;j<icost[i].size();j++){ // std::cout << starred[i][j] << ' '; // } // std::cout << std::endl; // } return starred; }
// 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; } }
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 = 256; NY = 256; NZ = 256; } else { NX = atoi(argv[1]); NY = atoi(argv[2]); NZ = atoi(argv[3]); } int N[3] = { NX, NY, NZ }; int nthreads = 1; step1(N, nthreads); MPI_Finalize(); return 0; } // end main
// 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; } }
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; }
void testAppendStep() { qrw::pathfinding::Path path; CPPUNIT_ASSERT(path.getLength() == 0); qrw::Coordinates step1(12, 13); path.appendStep(step1); CPPUNIT_ASSERT(path.getLength() == 1); CPPUNIT_ASSERT(path.getMovementCosts() == 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); }
int do_steps() { int result; unit_test(); result=step1(); if(result==IDC_NEXT){ result=step2(); if(result==IDC_NEXT){ result=step3(); } } return 0; }
// Subclasses can override void AccelStepper::step(long step) { switch (_interface) { case FUNCTION: step0(step); break; case DRIVER: step1(step); break; } }
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 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; } }
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; }
static int mp730_scan (pixma_t * s) { int error, n; mp730_t *mp = (mp730_t *) s->subdriver; uint8_t *buf; if (mp->state != state_idle) return PIXMA_EBUSY; /* clear interrupt packets buffer */ while (handle_interrupt (s, 0) > 0) { } mp->raw_width = calc_raw_width (s, s->param); PDBG (pixma_dbg (3, "raw_width = %u\n", mp->raw_width)); n = IMAGE_BLOCK_SIZE / s->param->line_size + 1; buf = (uint8_t *) malloc ((n + 1) * s->param->line_size + IMAGE_BLOCK_SIZE); if (!buf) return PIXMA_ENOMEM; mp->buf = buf; mp->lbuf = buf; mp->imgbuf = buf + n * s->param->line_size; mp->imgbuf_len = 0; error = step1 (s); if (error >= 0) error = start_session (s); if (error >= 0) mp->state = state_scanning; if (error >= 0) error = select_source (s); if (error >= 0) error = send_scan_param (s); if (error < 0) { mp730_finish_scan (s); return error; } mp->last_block = 0; return 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); }
// 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; } }
void main() { restart: clrscr(); cout<<"Enter year : "; unsigned int y,m; cin>>y; int x; x=step1(y); int month[14][12]= {{1,4,4,7,2,5,7,3,6,1,4,6},{2,5,5,1,3,6,1,4,7,2,5,7},{3,6,6,2,4,7,2,5,1,3,6,1},{4,7,7,3,5,1,3,6,2,4,7,2},{5,1,1,4,6,2,4,7,3,5,1,3},{6,2,2,5,7,3,5,1,4,6,2,4},{7,3,3,6,1,4,6,2,5,7,3,5},{1,4,5,1,3,6,1,4,7,2,5,7},{2,5,6,2,4,7,2,5,1,3,6,1},{3,6,7,3,5,1,3,6,2,4,7,2},{4,7,1,4,6,2,4,7,3,5,1,3},{5,1,2,5,7,3,5,1,4,6,2,4},{6,2,3,6,1,4,6,2,5,7,3,5},{7,3,4,7,2,5,7,3,6,1,4,6}}; cout<<"Enter month (1 - 12) : "; month_input: cin>>m; if(m<1 || m>12) { cout<<"Enter a valid month (1 - 12) : "; goto month_input; } cout<<" ";month_name(m); cout<<' '<<y<<"\nMon Tue Wed Thu Fri Sat Sun"; int j=month[x-1][m-1], days=no_days(m,y); for (int i=0; i<j-1; i++) cout<<' '; for(i=1; i<=days; i++) { cout<<i<<' '; if(j==7) { cout<<' '; j=1; } else j++; } cout<<"Try for another month? (y/n) : "; char ch; cin>>ch; if(ch=='y' || ch=='Y') goto restart; }
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; } }
// 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; } }
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; }
String DutchStemmer::stem(const String& term) { // Use lowercase for medium stemming. buffer = StringUtils::toLower(term); if (!isStemmable()) return buffer; if (stemDict && stemDict.contains(term)) return stemDict.get(term); // Stemming starts here... substitute(); storeYandI(); R1 = getRIndex(0); R1 = std::max((int32_t)3, R1); step1(); step2(); R2 = getRIndex(R1); step3a(); step3b(); step4(); reStoreYandI(); return buffer; }
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"); }
void XdgMenuApplinkProcessor::run() { step1(); step2(); }
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; }
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; }
//The function that will call each of step of Munkres' algorithm in turn //We're using this since multiple functions use the algorithm bool munkres::find_a_matching(void) { step1(); step2(); return step3(); }
double do_stuff( double i ) { return step3( step2( step1( i ) ) ); }