void F4GB::process_column(int c) { /* If this column has been handled before, return. Otherwise, find a GB element whose lead term divides this monomial, and either mark this colum as not an initial element, OR append a row */ column_elem &ce = mat->columns[c]; if (ce.head >= -1) return; int32_t which; bool found = lookup->find_one_divisor_packed(M, ce.monom, which); if (found) { packed_monomial n = next_monom; M->unchecked_divide(ce.monom, gb[which]->f.monoms, n); B.intern(1+M->monomial_size(n)); next_monom = B.reserve(1+M->max_monomial_size()); next_monom++; //M->set_component(which, n); ce.head = INTSIZE(mat->rows); load_row(n,which); } else ce.head = -1; }
void load_offset_row (frameT *frame, off_t off, off_t end) { csvT *csv = frame->csv; char buf[CSV_BUF_SIZE]; unsigned char c; if (off == 0) { // skip the header fseek(csv->fp, 0L, SEEK_SET); fgets (buf, CSV_BUF_SIZE, csv->fp); off = ftell(csv->fp); if (off >= end) return; } if (off >= csv->size) { // don't go past the end of the file return; } // we go to off - 1 to check and see whether the previous // character is '\n', if so we happen to be aligned to a // row. fseek (csv->fp, off - 1, SEEK_SET); c = fgetc (csv->fp); if (c == '\n') { load_row (frame); return; } // need to align to the next '\n'; fgets (buf, CSV_BUF_SIZE, csv->fp); if (ftell(csv->fp) >= end) { // Beyond the end of where we should be looking, so don't look return; } load_row (frame); }
void load_person(Epic::Config::Config & cnf) { std::vector< std::string > header; std::vector< std::string > row; load_header(header); load_row(row); for(size_t pos=0; pos < header.size(); ++pos) { cnf.insert(header.at(pos),row.at(pos),true); } }
void F4GB::process_s_pair(spair *p) { int c; switch (p->type) { case F4_SPAIR_SPAIR: { packed_monomial n = next_monom; M->unchecked_divide(p->lcm, gb[p->i]->f.monoms, n); B.intern(1+M->monomial_size(n)); next_monom = B.reserve(1+M->max_monomial_size()); next_monom++; load_row(n, p->i); c = mat->rows[mat->rows.size()-1].comps[0]; if (mat->columns[c].head >= -1) n_lcmdups++; else { // In this situation, we load the other half as a reducer n = next_monom; M->unchecked_divide(p->lcm, gb[p->j]->f.monoms, n); B.intern(1+M->monomial_size(n)); next_monom = B.reserve(1+M->max_monomial_size()); next_monom++; load_row(n, p->j); mat->columns[c].head = INTSIZE(mat->rows)-1; } break; } case F4_SPAIR_GEN: load_gen(p->i); break; default: break; } }
void load_all_rows (frameT *frame) { csvT *csv = frame->csv; char buf[CSV_BUF_SIZE]; fseek (csv->fp, 0L, SEEK_SET); // Skip header fgets (buf, CSV_BUF_SIZE, csv->fp); while (ftell (csv->fp) < csv->size) { load_row (frame); } update_all_stats (frame); }
/** 'file' is a relative\full path to a xml file. * the funciton returns '1' if 'file' does not exists, * and '0' if no problem occured. the function loads the settings * from 'file' and sets the relevant values. */ int parse_line(char *line, int cnt) { char words[BUFF_SIZE]; // will be a copy of the input. char *word; strcpy(words, line); word = strtok(words, " \t<>"); if ( cnt < 2 ) return 1; if ( strcmp(word, "/game") == 0 ) return 0; else if ( strcmp(word, "next_turn") == 0 ) { word = strtok(NULL, " \t<>"); // word is either white or black or '/next_turn' if ( strcmp(word, "/next_turn") == 0 ) return 1; for ( int i = 0; word[i]; i++ ) word[i] = tolower(word[i]); // lower case the word if ( strcmp(word, "black") == 0 ) WHITE_TURN = 0; if ( strcmp(word, "white") == 0 ) WHITE_TURN = 1; return 1; } else if ( strcmp(word, "game_mode") == 0 ) { word = strtok(NULL, " \t<>"); // word is either white or black if ( strcmp(word, "/game_mode") == 0 ) return 1; TWO_PLAYERS_MODE = (atoi(word) == 2) ? 0 : 1; return 1; } else if ( strcmp(word, "difficulty") == 0 ) { word = strtok(NULL, " \t<>"); // word is either white or black or '/next_turn' if ( strcmp(word, "/difficulty") == 0 ) return 1; if ( strcmp(word, "best") == 0 ) { MINIMAX_DEPTH = BEST_DEPTH_VALUE; return 1; } int x = atoi(word); // returns '0' if not valid set_minmax_depth(x); return 1; } else if ( strcmp(word, "user_color") == 0 ) { word = strtok(NULL, " \t<>"); // word is either white or black or '/next_turn' if ( strcmp(word, "/user_color") == 0 ) return 1; for ( int i = 0; word[i]; i++ ) word[i] = tolower(word[i]); // lower case the word set_user_color(word); return 1; } else if ( strcmp(word, "board") == 0 ) return 1; // word is either white or black or '/next_turn' else if ( strcmp(word, "row_8") == 0 ) { load_row(strtok(NULL, " \t<>"), 7); // send the row to 'load_row' return 1; } else if ( strcmp(word, "row_7") == 0 ) { load_row(strtok(NULL, " \t<>"), 6); return 1; } else if ( strcmp(word, "row_6") == 0 ) { load_row(strtok(NULL, " \t<>"), 5); return 1; } else if ( strcmp(word, "row_5") == 0 ) { load_row(strtok(NULL, " \t<>"), 4); return 1; } else if ( strcmp(word, "row_4") == 0 ) { load_row(strtok(NULL, " \t<>"), 3); return 1; } else if ( strcmp(word, "row_3") == 0 ) { load_row(strtok(NULL, " \t<>"), 2); return 1; } else if ( strcmp(word, "row_2") == 0 ) { load_row(strtok(NULL, " \t<>"), 1); return 1; } else if ( strcmp(word, "row_1") == 0 ) { load_row(strtok(NULL, " \t<>"), 0); return 1; } else if ( strcmp(word, "/board") == 0 ) return 1; else return 2; }