Ejemplo n.º 1
0
inline RC TPCCTxnManager::run_payment_0(uint64_t w_id, uint64_t d_id, uint64_t d_w_id, double h_amount, row_t *& r_wh_local) {

	uint64_t key;
	itemid_t * item;
/*====================================================+
    	EXEC SQL UPDATE warehouse SET w_ytd = w_ytd + :h_amount
		WHERE w_id=:w_id;
	+====================================================*/
	/*===================================================================+
		EXEC SQL SELECT w_street_1, w_street_2, w_city, w_state, w_zip, w_name
		INTO :w_street_1, :w_street_2, :w_city, :w_state, :w_zip, :w_name
		FROM warehouse
		WHERE w_id=:w_id;
	+===================================================================*/


  RC rc;
	key = w_id;
	INDEX * index = _wl->i_warehouse; 
	item = index_read(index, key, wh_to_part(w_id));
	assert(item != NULL);
	row_t * r_wh = ((row_t *)item->location);
	if (g_wh_update)
		rc = get_row(r_wh, WR, r_wh_local);
	else 
		rc = get_row(r_wh, RD, r_wh_local);

  return rc;
}
Ejemplo n.º 2
0
/**
   * @brief Determines row and column of key press then returns value from map
   * @retval Returns exact key pressed
   */
int get_key(void) {
	
	int i = 0;
	
	uint8_t key;
	uint8_t row, column;
	
	// Interupt handling, and debouncing;
	if((column = get_column()) == 9) return -1;
	if((row = get_row()) == 9) return -1;
	
	// Hold code in wait state until button released/held long enough
	key = keypad_map[row][column];
	while(1){
		
		// Wait state
		while(keypad_map[get_row()][get_column()] == key){ 
			i++;
			//printf("Key:%d\n", key);
			delay(25); 
		}
		
		// Key held long enough and isn't noise
		if(i > 2) break;
		else return get_key();
		
	}

	printf("%d made it dad!\n", key);
	return key;		
	
}
Ejemplo n.º 3
0
Archivo: svd.c Proyecto: Rainwin2015/C
MAT	*bifactor(MAT *A, MAT *U, MAT *V)
#endif
{
	int	k;
	STATIC VEC	*tmp1=VNULL, *tmp2=VNULL, *w=VNULL;
	Real	beta;

	if ( ! A )
		error(E_NULL,"bifactor");
	if ( ( U && ( U->m != U->n ) ) || ( V && ( V->m != V->n ) ) )
		error(E_SQUARE,"bifactor");
	if ( ( U && U->m != A->m ) || ( V && V->m != A->n ) )
		error(E_SIZES,"bifactor");
	tmp1 = v_resize(tmp1,A->m);
	tmp2 = v_resize(tmp2,A->n);
	w    = v_resize(w,   max(A->m,A->n));
	MEM_STAT_REG(tmp1,TYPE_VEC);
	MEM_STAT_REG(tmp2,TYPE_VEC);
	MEM_STAT_REG(w,   TYPE_VEC);

	if ( A->m >= A->n )
	    for ( k = 0; k < A->n; k++ )
	    {
		get_col(A,k,tmp1);
		hhvec(tmp1,k,&beta,tmp1,&(A->me[k][k]));
		_hhtrcols(A,k,k+1,tmp1,beta,w);
		if ( U )
		    _hhtrcols(U,k,0,tmp1,beta,w);
		if ( k+1 >= A->n )
		    continue;
		get_row(A,k,tmp2);
		hhvec(tmp2,k+1,&beta,tmp2,&(A->me[k][k+1]));
		hhtrrows(A,k+1,k+1,tmp2,beta);
		if ( V )
		    _hhtrcols(V,k+1,0,tmp2,beta,w);
	    }
	else
	    for ( k = 0; k < A->m; k++ )
	    {
		get_row(A,k,tmp2);
		hhvec(tmp2,k,&beta,tmp2,&(A->me[k][k]));
		hhtrrows(A,k+1,k,tmp2,beta);
		if ( V )
		    _hhtrcols(V,k,0,tmp2,beta,w);
		if ( k+1 >= A->m )
		    continue;
		get_col(A,k,tmp1);
		hhvec(tmp1,k+1,&beta,tmp1,&(A->me[k+1][k]));
		_hhtrcols(A,k+1,k+1,tmp1,beta,w);
		if ( U )
		    _hhtrcols(U,k+1,0,tmp1,beta,w);
	    }

#ifdef	THREADSAFE
	V_FREE(tmp1);	V_FREE(tmp2);
#endif

	return A;
}
Ejemplo n.º 4
0
int g3_fastMove(const struct connect4 *game, int *movesToExplore) {
    const char me = game->whoseTurn;

    struct connect4 tempGame;

    // Clear space for wins
    int wins[NUM_COLS];
    memset(wins, 0, sizeof(wins));

    int i, count;
    for (i = 0; i < NUM_COLS; i++) {
        if (movesToExplore[i] == 0)
            continue;

        // Run a bunch of sims for this column
        for (count = 0; count < g3_FAST_SIMULATIONS; count++) {
            memcpy(&tempGame, game, sizeof(struct connect4));

            // Play a move in the ith column
            tempGame.board[get_row(&tempGame, i)][i] = tempGame.whoseTurn;
            tempGame.whoseTurn = other(tempGame.whoseTurn);

            char winner = 0;
            while (winner == 0 && g3_movesAvailable(&tempGame)) {
                int nextMove = g3_has3Wins(&tempGame);
                // Try again if move is invalid
                while (not_valid(&tempGame, nextMove))
                    nextMove = rand() % NUM_COLS; // Try again

                // If the move would result in a winner or the game is CATS, break the loop
                int validRow = get_row(&tempGame, nextMove);
                if (g3_is3Win(&tempGame, validRow, nextMove, tempGame.whoseTurn)) {
                    winner = tempGame.whoseTurn;
                } else {
                    // Otherwise, play the move and keep playing
                    move(&tempGame, nextMove, tempGame.whoseTurn);
                    tempGame.whoseTurn = other(tempGame.whoseTurn);
                }
            }

            wins[i] += (winner == me);
        }
    }

    int greatest = -1, greatestMove = -1;
    for (i = 0; i < NUM_COLS; i++) {
        if (wins[i] > greatest) {
            greatest = wins[i];
            greatestMove = i;
        }
    }

    return greatestMove;
}
Ejemplo n.º 5
0
//minmax algorithm with alpha-beta pruning. I understand how to code the minmax part but needed some help with the pruning.
int minmaxAB(int depth,struct connect4 *game, char playerPiece, int alpha, int beta){
    if(depth == 0 || check_status(game) != NOT_OVER){
        return evaluate(game, playerPiece);
    }

    if(playerPiece == game->whoseTurn){
        int minScore = -999999999;
        int i;
        for (i = 0; i < 7; ++i) {
            if(game->board[NUM_ROWS-1][i] == '_' ){
                move(game,i,playerPiece); //will probably need to be fixed?
                int currentScore = minmaxAB(depth-1, game, other(playerPiece), alpha, beta);
                //printf("score set to %d\n", currentScore);
                int rowIndex = get_row(game, i);
                game->board[rowIndex-1][i] = '_';
                if(currentScore > minScore){
                    minScore = currentScore;
                }
                if(alpha < minScore){
                    alpha = minScore;
                }
                if(beta <= alpha){
                    break;
                }
            }
        }
        return minScore;
    }
    else{
        int maxScore = 999999999;
        int i;
        for (i = 0; i < 7; ++i) {
            if(game->board[NUM_ROWS-1][i] == '_' ){
                move(game,i,playerPiece); //will probably need to be fixed?
                int currentScore = minmaxAB(depth-1, game, other(playerPiece), alpha,beta);
                int rowIndex = get_row(game, i);
                game->board[rowIndex-1][i] = '_';
                if(currentScore < maxScore){
                    maxScore = currentScore;
                }
                if(beta > maxScore){
                    beta = maxScore;
                }
                if(beta <= alpha){
                    break;
                }
            }
        }
        return maxScore;
    }
}
Ejemplo n.º 6
0
int jon_move(struct connect4 *game, int secondsleft){
    char playerPiece = game->whoseTurn;
    int i;

    //creates a copy of the current gamestate so that it can safely modify it
    struct connect4 *safeCopy = copy(game);
    //checks to see if it needs to prevent a loss or claim a win before wasting time with the deep recursion
    int moveIndex = amIAboutToLose(safeCopy);
    if(moveIndex == -1){
        moveIndex = amIAboutToWin(safeCopy);
    }
    if(moveIndex == -1)
        minmaxAB(6,safeCopy,playerPiece,-999999,999999);
    //if the AI cannot win or lose in this turn, it starts at each possible move and recursively checks boards from there
    if(moveIndex == -1){
    int bestVal = -9999999;
    for (i = 0; i < 7; ++i) {
        if(game->board[NUM_ROWS-1][i] == '_' ){
            //temporarily places a piece on the board
            move(safeCopy,i,playerPiece);
            int val = minmaxAB(8, safeCopy,other(playerPiece),-999999,999999);
            int rowIndex = get_row(safeCopy, i);
            //removes the temp piece from the board
            safeCopy->board[rowIndex-1][i] = '_';
            //If we got a better value, make this our move.
            if(val >= bestVal){
                bestVal = val;
                moveIndex = i;
            }
            }
        }
    }
    return moveIndex;
}
Ejemplo n.º 7
0
TraceViewRecord *
trace_view_store_get_row(TraceViewStore *store, gint row)
{
	g_return_val_if_fail(TRACE_VIEW_IS_LIST(store), NULL);

	return get_row(store, row);
}
Ejemplo n.º 8
0
// new_order 2
inline RC TPCCTxnManager::new_order_8(uint64_t w_id,uint64_t  d_id,bool remote, uint64_t ol_i_id, uint64_t ol_supply_w_id, uint64_t ol_quantity,uint64_t  ol_number,uint64_t  o_id, row_t *& r_stock_local) {
		uint64_t key;
		itemid_t * item;

		/*===================================================================+
		EXEC SQL SELECT s_quantity, s_data,
				s_dist_01, s_dist_02, s_dist_03, s_dist_04, s_dist_05,
				s_dist_06, s_dist_07, s_dist_08, s_dist_09, s_dist_10
			INTO :s_quantity, :s_data,
				:s_dist_01, :s_dist_02, :s_dist_03, :s_dist_04, :s_dist_05,
				:s_dist_06, :s_dist_07, :s_dist_08, :s_dist_09, :s_dist_10
			FROM stock
			WHERE s_i_id = :ol_i_id AND s_w_id = :ol_supply_w_id;
		EXEC SQL UPDATE stock SET s_quantity = :s_quantity
			WHERE s_i_id = :ol_i_id
			AND s_w_id = :ol_supply_w_id;
		+===============================================*/

		key = stockKey(ol_i_id, ol_supply_w_id);
		INDEX * index = _wl->i_stock;
		item = index_read(index, key, wh_to_part(ol_supply_w_id));
		assert(item != NULL);
		row_t * r_stock = ((row_t *)item->location);
    RC rc = get_row(r_stock, WR, r_stock_local);
    return rc;
}
Ejemplo n.º 9
0
Datum
get_next_row(FunctionCallInfo fcinfo)
{
    PlxResult       *plx_result;
    FuncCallContext *funcctx;
    int              call_cntr;

    plx_result = get_plx_result_or_due(fcinfo);
    /* code below will be never executed if pg_result not find */
    if (SRF_IS_FIRSTCALL())
    {
        funcctx = SRF_FIRSTCALL_INIT();
        funcctx->max_calls = PQntuples(plx_result->pg_result);
    }
    funcctx = SRF_PERCALL_SETUP();
    call_cntr = funcctx->call_cntr;
    if (call_cntr < funcctx->max_calls)
        SRF_RETURN_NEXT(funcctx, get_row(fcinfo, plx_result, call_cntr));
    else
    {
        plx_result_cache_delete(fcinfo);
        PQclear(plx_result->pg_result);
        pfree(plx_result);
        SRF_RETURN_DONE(funcctx);
    }
}
Ejemplo n.º 10
0
 sf::IntRect Spritesheet::_get_rect(int frame)
 {
     return sf::IntRect(
         get_col(frame, _cols) * _tile_width,
         get_row(frame, _cols) * _tile_height,
         _tile_width, _tile_height);
 }
Ejemplo n.º 11
0
std::vector<OrderData> OrderData::select_all_by_id(int id, sqlite3* db, std::string table_name, std::string& error_msg)
{
  error_msg = "OK";
  std::vector<OrderData> orders;
  std::string query = std::string("SELECT * FROM ") + table_name + " WHERE order_id = " + std::to_string(id);
  int result = 0;
  sqlite3_stmt* stmt;

  if ((result = sqlite3_prepare_v2(db, query.c_str(), query.size(), &stmt, NULL)) != SQLITE_OK)
  {
    error_msg = std::string("sqlite3_prepare_v2 failed. Error code: ") + std::to_string(result);
    return orders;
  }
  BOOST_SCOPE_EXIT_ALL(stmt)
  {
    sqlite3_finalize(stmt);
  };


  while ((result = sqlite3_step(stmt)) == SQLITE_ROW)
  {
    OrderData order_data = get_row(stmt);
    orders.push_back(order_data);
  }

  return orders;
}
Ejemplo n.º 12
0
bool OrderData::select_last_modified_by_id(int order_id, sqlite3* db, std::string table_name, std::string& error_msg)
{
  error_msg = "OK";
  std::vector<OrderData> orders;
  std::string query = std::string("SELECT * FROM ") + table_name + " WHERE order_id = " + std::to_string(order_id) + " ORDER BY internal_id DESC LIMIT 1";
  int result = 0;
  sqlite3_stmt* stmt;

  if ((result = sqlite3_prepare_v2(db, query.c_str(), query.size(), &stmt, NULL)) != SQLITE_OK)
  {
    error_msg = std::string("sqlite3_prepare_v2 failed. Error code: ") + std::to_string(result);
    return false;
  }
  BOOST_SCOPE_EXIT_ALL(stmt)
  {
    sqlite3_finalize(stmt);
  };

  if ((result = sqlite3_step(stmt)) == SQLITE_ROW)
  {
    OrderData order_data = get_row(stmt);
    memcpy(this, &order_data, sizeof(OrderData));
  }
  else
  {
    error_msg = std::string("0 results on SELECT. Error code: ") + std::to_string(result);
    return false;
  }

  return true;
}
Ejemplo n.º 13
0
/**
  \brief Roznasobeni dvou matic, jen pro testovaci ucely. Velmi pomaly zpusob. Doma nezkouset.
  Projede radky a roznasobi hodnotu leve matice v danem sloupci c s c-tym radkem prave matice
*/
void MTX::multiply_matrices(MTX& B, MTX& R)
{
    long i,j,ac; // ac - actual column
    double v;//value for multiplication of row
    ROW l;//row of actual left matrix
    ROW r;//row of right matrix
    ROW b;//resultant row - will write into this
    R = B;

    for (i=0;i<row_number;i++){//projdi kazdy radek
//        printf("\nRadek: %li\.n",i);
        j=0;
        l = get_row(i,0);
        while(j < l.value_number){//projdi vsechny nenulove hodnoty v radku
            if(j==0){
                ac = l.index[j];
                r = B.get_row(ac,0);
                v = l.values[j];
                b = r*v;
            }else{
                ac = l.index[j];
                r = B.get_row(ac,0);
                v = l.values[j];
                b += r*v;
            }
            j++;
        }
        R.set_row(b,i);
    }
}
Ejemplo n.º 14
0
// returns 0 if solved > 0 otherwise
int unsolved(oku_sod* sod){
	int i,j,size = sod->size, score=0;
	//occurance counters
	int row[size+1][size+1],col[size+1][size+1],blk[size+1][size+1];
	//initialize counters
	for(i=0;i<size+1;i++)
		for(j=1;j<size+1;j++){
			row[i][j] = 0;
			col[i][j] = 0;
			blk[i][j] = 0;
		}
	// count occurances
	for(i=0;i<size;i++)
		for(j=0;j<size;j++){
			row[i][get_row(sod,i,j)]++;
			col[i][get_col(sod,i,j)]++;
			blk[i][get_blk(sod,i,j)]++;
		}
	for(i=0;i<size;i++)
		for(j=1;j<size+1;j++){
			score += row[i][j] > 1 ? 1 : 0;
			score += col[i][j] > 1 ? 1 : 0;
			score += blk[i][j] > 1 ? 1 : 0;
		 }
	return score;
}
Ejemplo n.º 15
0
void * _create_int_hashtable_on_column(struct Block * block, const char * column_name)
{
  int row_id, column_id = get_column_id_by_name_or_exit(block, column_name);
  struct hashtable * ht = create_hashtable(16, hash_from_int_fn, ints_equal_fn);
  
  num_metas++;
  metas = (struct hashtable_meta *)realloc(metas, sizeof(struct hashtable_meta)*num_metas);
  struct hashtable_meta * meta = &metas[num_metas-1];
  
  meta->ht = ht;
  meta->block = block;
  meta->row_ids = NULL;
  
  int dups = 0;
  for (row_id = 0 ; row_id < block->num_rows ; row_id++)
  {
    if (hashtable_search(ht, get_cell(block, row_id, column_id)) == NULL)
    {
      hashtable_insert(ht, get_cell(block, row_id, column_id), get_row(block, row_id));
    }
    else dups++;
  }
  if (dups > 0) fprintf(stderr, "%s('%s'), there are %d duplicate rows (ignored) of total: %d\n", __func__, column_name, dups, block->num_rows);
  return (void*)ht;
}
Ejemplo n.º 16
0
/**************************************************************************
 *
 *N  vpf_binary_search
 *
 *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *    This function performs a binary search on a VPF table for the
 *    specified integer value.  Only VPF data type 'I' is supported.
 *    The table must be sorted on the specified field, or this function
 *    will give unpredictable results.  The table must have been
 *    successfully opened.  If more than one row matches the search
 *    value, only the first encountered will be returned.
 *E
 *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    srchval <input> == (long int) specified search value.
 *    field   <input> == (int) table sort field.
 *    table   <input> == (vpf_table_type) VPF table.
 *    vpf_binary_search <output> == (long int) first matching row.
 *E
 *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels  DOS Turbo C
 *E
 *************************************************************************/
long int vpf_binary_search( long int srchval,
			    int field,
			    vpf_table_type table )
{
   long int left,right, ival, rowid, n;
   row_type row;

   left = 1;
   right = table.nrows;

   do {
      rowid = (left+right)/2;
      row = get_row(rowid,table);
      get_table_element(field,row,table,&ival,&n);
      free_row(row,table);
      if (ival < srchval)
	 right = rowid-1;
      else
	 left = rowid+1;
   } while ((srchval != ival) && (left <= right));

   if (srchval != ival) rowid = 0;

   return rowid;
}
Ejemplo n.º 17
0
// --------------------------------------------------------------------------
int DecoderPE::get_data(BlockStore &bs)
{
	int postamble_rows = 0;
	int row_count = 0;
	quint16 data = 0x01ff; // we start with all ones, as last row of preamble is all ones

	while (1) {
		int res = get_row(&data);
		if (res < 0) {
			return res;
		}

		buf[row_count++] = data;

		// start of postamble
		if ((postamble_rows <= 0) && (data == 0b0000000111111111)) {
			postamble_rows++;
		// inside postamble
		} else if ((postamble_rows >= 1) && (data == 0)) {
			postamble_rows++;
		// false positive
		} else {
			postamble_rows = 0;
		}
		if (postamble_rows >= td->cfg.pe_sync_pulses_min+1) {
			// cut postamble
			row_count -= postamble_rows;
			break;
		}
	}

	return row_count;
}
Ejemplo n.º 18
0
/**
 * get_row_values - reads the row values from the read buffer
 *
 * This method is used to read the row column values
 * from the read buffer and store them in the row structure
 * in the class.
 *
*/
boolean Connector::get_row_values() {
  int res = 0;
  int offset = 0;

  // It is an error to try to read rows before columns
  // are read.
  if (!columns_read) {
    Serial.println("ERROR: You must read the columns first!");
    return true;
  }
  // Drop any row data already read
  free_row_buffer();

  // Read a row
  res = get_row();
  if (res != EOF_PACKET) {
    offset = 4;
    for (int f = 0; f < num_cols; f++) {
      row.values[f] = read_string(&offset);
    }
  }
  else {
    return res;
  }
  return true;
}
Ejemplo n.º 19
0
VectorXd SparseSystem::solve() const {
  requireDebug(num_rows() >= num_cols(), "SparseSystem::solve: cannot solve system, not enough constraints");
  requireDebug(num_rows() == num_cols(), "SparseSystem::solve: system not triangular");
  int n = num_cols();
  VectorXd result(n);
  for (int row=n-1; row>=0; row--) {
    const SparseVector& rowvec = get_row(row);
    // start with rhs...
    double terms = _rhs(row);
    double diag;

    // ... and subtract already solved variables multiplied with respective coefficient from R
    // We assume that the SpareSystem is triangular
    SparseVectorIter iter(rowvec);
    iter.get(diag); // we can check return value it should be == row
    iter.next();
    for (; iter.valid(); iter.next()) {
      double v;
      int col = iter.get(v);
      terms = terms - result(col)*v;
    }
    // divide result by diagonal entry of R
    result(row) = terms / diag;
  }
  return result;
}
Ejemplo n.º 20
0
std::vector<OrderData> OrderData::select_unique_last_modified_in_time_interval_by_user(long long from, long long to, int login, sqlite3* db, std::string table_name, std::string& error_msg)
{
  error_msg = "OK";
  std::vector<OrderData> orders;
  std::string query = "SELECT * FROM " + table_name + " WHERE account_id = " + std::to_string(login) + " AND modify_time > " + std::to_string(from) + " AND modify_time < " + std::to_string(to) + " GROUP BY order_id";

  int result = 0;
  sqlite3_stmt* stmt;

  if ((result = sqlite3_prepare_v2(db, query.c_str(), query.size(), &stmt, NULL)) != SQLITE_OK)
  {
    error_msg = std::string("sqlite3_prepare_v2 failed. Error code: ") + std::to_string(result);
    return orders;
  }
  BOOST_SCOPE_EXIT_ALL(stmt)
  {
    sqlite3_finalize(stmt);
  };

  while ((result = sqlite3_step(stmt)) == SQLITE_ROW)
  {
    OrderData order_data = get_row(stmt);
    orders.push_back(order_data);
  }

  return orders;
}
Ejemplo n.º 21
0
// build a row of the GLM deign matrix
// in
//  current image
vnl_vector<double> RtDesignMatrix::getRow(unsigned int timepoint) {

  // bounds check
  if (timepoint >= numMeas) {
    return vnl_vector<double>(0);
  }

  return get_row(timepoint);
}
Ejemplo n.º 22
0
/**************************************************************************
 *
 *N  related_row
 *
 *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *    Return the related row of table2 based upon the value of table 1's key
 *    Table 2 must be the '1' side of an n:1 relationship  --  If it isn't,
 *    use 'related_rows()'.
 *    Supported data types - I and T<n>.
 *    Binary search supported only for data type I. (column must be sorted)
 *E
 *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels  DOS Turbo C
 *E
 *************************************************************************/
long int related_row( void *keyval1,
		      vpf_table_type table2, char *key2,
		      int sort_flag )
{
   long int rowid, i, ival, kval, n;
   row_type row;
   int KEY2_;
   char cval, *tval;

   if (ossim_strcasecmp(key2,"ID")==0) {
      memcpy( &rowid, keyval1, sizeof(rowid) );
      return rowid;
   }

   rowid = 0;

   KEY2_ = table_pos(key2,table2);

   if ((table2.header[KEY2_].type != 'I')&&
       (table2.header[KEY2_].type != 'T')) return rowid;

   if ((table2.header[KEY2_].type == 'I')&&
       (table2.header[KEY2_].count != 1)) return rowid;

   if ((table2.header[KEY2_].type == 'T')&&(sort_flag)) sort_flag = 0;

   if (table2.header[KEY2_].type == 'I') memcpy(&kval,keyval1,sizeof(kval));

   if (!sort_flag) {   /* Sequential search */

      for (i=1;i<=table2.nrows;i++) {
	 row = get_row(i,table2);
	 if (table2.header[KEY2_].type == 'I') {
	    get_table_element(KEY2_,row,table2,&ival,&n);
	    if (ival == kval) rowid = i;
	 } else {
	    if (table2.header[KEY2_].count==1) {
	       get_table_element(KEY2_,row,table2,&cval,&n);
	       if (memcmp(&cval,keyval1,sizeof(ival))==0) rowid = i;
	    } else {
	       tval = (char*)get_table_element(KEY2_,row,table2,NULL,&n);
	       if (strcmp(tval,(char *)keyval1)==0) rowid = i;
	    }
	 }
	 free_row(row,table2);
	 if (rowid > 0) break;
      }

   } else {   /* Binary search */

      memcpy(&kval,keyval1,sizeof(kval));
      rowid = vpf_binary_search( kval, KEY2_, table2 );

   }

   return rowid;
}
Ejemplo n.º 23
0
/*************************************************************************
 *
 *N  draw_text
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function draws annotation for a given row number in the text
 *     pseudo-primitive table.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *     rownum      <input>==(ossim_int32) row number of the text table.
 *     table       <input>==(vpf_table_type) text primitive table.
 *     return     <output>==(int) 0 if the user escapes, 1 upon successful
 *                          completion.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels   August 1991                        DOS Turbo C
 *E
 *************************************************************************/
int draw_text( ossim_int32 rownum, vpf_table_type table )
{
   int stat;
   row_type row;

   row = get_row( rownum, table );
   stat = draw_text_row(row,table);
   free_row(row,table);
   return stat;
}
Ejemplo n.º 24
0
/* Checks if the current player has 3wins available */
int g3_has3Wins(const struct connect4 *game) {
    int col;
    for (col = 0; col < NUM_COLS; col++) {
        int validRow = get_row(game, col);
        if (g3_is3Win(game, validRow, col, game->whoseTurn))
            return col;
    }

    return -1;
}
Ejemplo n.º 25
0
/**
  \brief
*/
const VTR MTX::multiply(const VTR& b)
{
    ROW a;
    double* r = new double[row_number];//return vektor

    for(long i=0;i<row_number;i++){
        a = get_row(i,0);
        r[i] = a*b;
    }
    return VTR(r,row_number);
}
Ejemplo n.º 26
0
    void set_pixel(uint32_t row_idx, uint32_t col_idx, BYTE r, BYTE g, BYTE b, BYTE a)
    {
        my_assert(_bytes_per_pixel == 4);
        auto ptr = get_row(row_idx);
        ptr += col_idx * 4;

        ptr[0] = r;
        ptr[1] = g;
        ptr[2] = b;
        ptr[3] = a;
    }
Ejemplo n.º 27
0
inline RC TPCCTxnManager::new_order_2(uint64_t w_id, uint64_t d_id, uint64_t c_id, bool remote, uint64_t  ol_cnt,uint64_t  o_entry_d, uint64_t * o_id, row_t *& r_cust_local) {
	uint64_t key;
	itemid_t * item;
	key = custKey(c_id, d_id, w_id);
	INDEX * index = _wl->i_customer_id;
	item = index_read(index, key, wh_to_part(w_id));
	assert(item != NULL);
	row_t * r_cust = (row_t *) item->location;
  RC rc = get_row(r_cust, RD, r_cust_local);
  return rc;
}
Ejemplo n.º 28
0
int main(int argc, char *argv[]) {
  db_row_t row = get_row("Select query");
  double res = 0.0;
  db_row_t::const_iterator it = row.begin(), end = row.end();
  for (; it != end; ++it) {
    res += boost::apply_visitor(db_sum_visitor(), *it);
  }
  std::cout << res << std::endl;

  return 0;
}
Ejemplo n.º 29
0
	FMatrix FMatrix::Transp() const
	{
		FMatrix d( col, row );
		FVector s( col );
		for ( int i = 1;i <= row;i++ )
		{
			s = get_row( i );
			d.set_col( i, s );
		}
		return d;
	}
Ejemplo n.º 30
0
Archivo: windll.c Proyecto: ks6g10/CA
/* fill row with the row row_nr from the problem */
long __declspec(dllexport) WINAPI _get_row(lprec *lp, long row_nr, double *row)
 {
  long ret;

  if (lp != NULL) {
   freebuferror();
   ret = get_row(lp, row_nr, row);
  }
  else
   ret = 0;
  return(ret);
 }