Ejemplo n.º 1
1
task autonomous()
{
    StartTask(descore);

    StartTask(velocitycalculator);

    if(SensorValue[J1]) // blue
    {
        if(SensorValue[J2]) //normal
        {
            // RAM
            ArmWall();

            ForwardTillStop(127);

        }
        else // oppo
        {
            Gamma();
        }
    }
    else // red
    {
        if(SensorValue[J2]) // normal
        {
            Beta();
        }
        else // oppo
        {
            Delta();
        }
    }

    StopTask(velocitycalculator);
}
Ejemplo n.º 2
0
/**
 * Calculate how far tiles can be altered beyond a given paste area bound.
 *
 * When pasting, some tiles around the paste area may be altered (during terraforming).
 * The function return the limit on how far it can happen. Calculations are not exact,
 * the goal is to give a safe range that will include any possible case.
 *
 * Result is based on current and desired heights at neighbour corners of the paste area.
 *
 * @param curr_h1 Current height on the first corner.
 * @param curr_h2 Current height on the second corner.
 * @param new_h1 Desired height on the first corner.
 * @param new_h2 Desired height on the second corner.
 * @param length Distance (in tiles) between corners.
 * @return How far (in tiles) terraforming can reach beyond the given bound.
 *
 * @pre Tile heights and the length can't create an impossible layout, heights can't differ
 *      too much: \n
 *      <tt> Delta(curr_h1, curr_h2) <= length </tt> \n
 *      <tt> Delta(new_h1, new_h2) <= length </tt> \n
 *
 * @see CopyPasteAreasMayColide
 */
static uint CalcMaxPasteRange(uint curr_h1, uint new_h1, uint curr_h2, uint new_h2, uint length)
{
	uint min_curr_h = CeilDiv(max<int>(curr_h1 + curr_h2 - length, 0), 2);
	uint max_curr_h = min((curr_h1 + curr_h2 + length) / 2, MAX_TILE_HEIGHT);
	uint min_new_h = CeilDiv(max<int>(new_h1 + new_h2 - length, 0), 2);
	uint max_new_h = min((new_h1 + new_h2 + length) / 2, MAX_TILE_HEIGHT);

	return max(Delta(max_new_h, min_curr_h), Delta(max_curr_h, min_new_h));
}
Ejemplo n.º 3
0
/* maxbit over |length| integers with provided initial value */
uint32_t simdmaxbitsd1_length(uint32_t initvalue, const uint32_t * in,
                uint32_t length) {
    __m128i newvec;
    __m128i oldvec;
    __m128i initoffset;
    __m128i accumulator;
    const __m128i *pin;
    uint32_t tmparray[4];
    uint32_t k = 1;
    uint32_t acc;

    assert(length > 0);

    pin = (const __m128i *)(in);
    initoffset = _mm_set1_epi32(initvalue);
    switch (length) {
      case 1:
        newvec = _mm_set1_epi32(in[0]);
        break;
      case 2:
        newvec = _mm_setr_epi32(in[0], in[1], in[1], in[1]);
        break;
      case 3:
        newvec = _mm_setr_epi32(in[0], in[1], in[2], in[2]);
        break;
      default:
        newvec = _mm_loadu_si128(pin);
        break;
    }
    accumulator = Delta(newvec, initoffset);
    oldvec = newvec;

    /* process 4 integers and build an accumulator */
    while (k * 4 + 4 <= length) {
        newvec = _mm_loadu_si128(pin + k);
        accumulator = _mm_or_si128(accumulator, Delta(newvec, oldvec));
        oldvec = newvec;
        k++;
    }

    /* extract the accumulator as an integer */
    _mm_storeu_si128((__m128i *)(tmparray), accumulator);
    acc = tmparray[0] | tmparray[1] | tmparray[2] | tmparray[3];

    /* now process the remaining integers */
    for (k *= 4; k < length; k++)
        acc |= in[k] - (k == 0 ? initvalue : in[k - 1]);

    /* return the number of bits */
    return bits(acc);
}
Ejemplo n.º 4
0
unsigned test1(unsigned sx,unsigned sy)
 {
  AlphaFunc func1(sx,sy);
  DrawAlgo::LineAlphaFunc<UInt> func2(sx,sy);

  unsigned ret=0;

  for(unsigned d=0; d<=sx ;d++)
    {
     Replace_max(ret,Delta(func1.alpha0(d,sx,sy),func2.alpha0(d,sx,sy)));
     Replace_max(ret,Delta(func1.alpha1(d,sx,sy),func2.alpha1(d,sx,sy)));
    }

  return ret;
 }
Ejemplo n.º 5
0
/* maxbit over 128 integers (SIMDBlockSize) with provided initial value */
uint32_t simdmaxbitsd1(uint32_t initvalue, const uint32_t * in) {
    __m128i  initoffset = _mm_set1_epi32 (initvalue);
    const __m128i* pin = (const __m128i*)(in);
    __m128i newvec = _mm_loadu_si128(pin);
    __m128i accumulator = Delta(newvec , initoffset);
    __m128i oldvec = newvec;
    uint32_t k = 1;
    for(; 4*k < SIMDBlockSize; ++k) {
        newvec = _mm_loadu_si128(pin+k);
        accumulator = _mm_or_si128(accumulator,Delta(newvec , oldvec));
        oldvec = newvec;
    }
    initoffset = oldvec;
    return maxbitas32int(accumulator);
}
Ejemplo n.º 6
0
void TPZArtDiff::ContributeImplDiff(int dim, TPZFMatrix<REAL> &jacinv, TPZVec<FADREAL> &sol, TPZVec<FADREAL> &dsol, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, REAL weight,  REAL timeStep, REAL deltaX)
{
    TPZVec<STATE> solReal(sol.NElements());
    int i;
    for(i = 0; i < sol.NElements(); i++)
		solReal[i] = sol[i].val();
	
    REAL delta = Delta(deltaX, solReal);
    REAL constant = /*-*/ delta * weight * timeStep;
	
    TPZVec<TPZVec<FADREAL> > TauDiv;
	
    PrepareFastDiff(dim, jacinv, sol, dsol, TauDiv);
	
    TPZVec<FADREAL> Diff;
    TPZVec<REAL> gradv(dim);
	
    int j, k, l;
    int nstate = dim + 2;
    int neq = sol[0].size();
    int nshape = neq/nstate;
	
    for(l=0;l<nshape;l++)
	{
		for(k=0;k<dim;k++)
			gradv[k] = dsol[k].dx/*fastAccessDx*/(/*k+*/l*nstate);// always retrieving this information from the first state variable...
		ODotOperator(gradv, TauDiv, Diff);
		for(i=0;i<nstate;i++)
		{
			ef(i+l*nstate,0) += constant * Diff[i].val();
			for(j=0;j<neq;j++)
				ek(i+l*nstate, j) -= constant * Diff[i].dx/*fastAccessDx*/(j);
		}
	}
}
Ejemplo n.º 7
0
/**
 * Calculates the minimum distance traveled to get from t0 to t1 when only
 * using tracks (ie, only making 45 degree turns). Returns the distance in the
 * NPF scale, ie the number of full tiles multiplied by NPF_TILE_LENGTH to
 * prevent rounding.
 */
static uint NPFDistanceTrack(TileIndex t0, TileIndex t1)
{
	const uint dx = Delta(TileX(t0), TileX(t1));
	const uint dy = Delta(TileY(t0), TileY(t1));

	const uint straightTracks = 2 * min(dx, dy); // The number of straight (not full length) tracks
	/* OPTIMISATION:
	 * Original: diagTracks = max(dx, dy) - min(dx,dy);
	 * Proof:
	 * (dx+dy) - straightTracks  == (min + max) - straightTracks = min + max - 2 * min = max - min */
	const uint diagTracks = dx + dy - straightTracks; // The number of diagonal (full tile length) tracks.

	/* Don't factor out NPF_TILE_LENGTH below, this will round values and lose
	 * precision */
	return diagTracks * NPF_TILE_LENGTH + straightTracks * NPF_TILE_LENGTH * STRAIGHT_TRACK_LENGTH;
}
Ejemplo n.º 8
0
void TPZArtDiff::ContributeFastestImplDiff_dim(TPZFMatrix<REAL> &jacinv, TPZVec<STATE> &sol, TPZFMatrix<STATE> &dsol, TPZFMatrix<REAL> &phi, TPZFMatrix<REAL> &dphi, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, REAL weight, REAL timeStep, REAL deltaX)
{
    REAL delta = Delta(deltaX, sol);
    REAL constant = /*-*/ weight * delta * timeStep;
    REAL buff;
	
    TPZVec<TPZVec<STATE> > TauDiv;
    TPZVec<TPZDiffMatrix<STATE> > dTauDiv;
	
    PrepareFastestDiff<dim>( jacinv, sol, dsol, phi, dphi, TauDiv, dTauDiv);
	
    int i, j, k, l;
    int nshape = dphi.Cols();
    int nstate = dim + 2;
    int neq = nstate * nshape;
	
    // ODotProduct speeded up
	
    for(l=0;l<nshape;l++)
		for(i=0;i<nstate;i++)
			for(k=0;k<dim;k++)
			{
				buff = dphi(k,l) * constant;
				ef(i+l*nstate,0) += buff * TauDiv[k][i];
				for(j=0;j<neq;j++)
					ek(i+l*nstate,j) -= buff * dTauDiv[k](i,j);
			}
}
Ejemplo n.º 9
0
int BMsubst(char *S, char *T)
{
    int n =  mstrlen(S), m =  mstrlen(T), i, k;
    int **del = Delta(S);
    k = i = n - 1;
    for (k = n - 1; k < m; k += del[n - i - 1][(int) T[k]], i = n - 1)
    {
        while (T[k] == S[i])
        {
            if (i == 0)
            {
                for (i = 0; i < n; ++i)
                {
                    free(del[i]);
                }
                free(del);
                return k;
            }
            --i;
            --k;
        }
    }
    for (i = 0; i < n; i++)
    {
        free(del[i]);
    }
    free(del);
    return (k<m)? k:m;
}
Ejemplo n.º 10
0
ulen ScrollShape::delta(uCoord delta,uCoord len,uCoord dlen) const
 {
  if( total<=page ) return 0;
  
  uCoord ext=2*dlen;
  
  if( len<=ext ) return 0;
  
  len-=ext;
  
  if( len<=dlen ) return 0;
  
  if( Delta(total,dlen,len)<page ) return Delta(total,delta,len);
  
  return Delta(total-page,delta,len-dlen);
 }
Ejemplo n.º 11
0
/* readonly attribute float delta; */
NS_IMETHODIMP
nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
{
    NS_ENSURE_ARG_POINTER(aDelta);
    *aDelta = Delta();
    return NS_OK;
}
Ejemplo n.º 12
0
// Update camera
void _Camera::Update(double FrameTime) {
	LastPosition = Position;

	// Cap distance
	if(TargetPosition.z <= 1.0f)
		TargetPosition.z = 1.0f;
	else if(TargetPosition.z >= Far)
		TargetPosition.z = Far;

	// Update position
	glm::vec2 Delta(TargetPosition - Position);
	if(std::abs(Delta.x) > 0.01f)
		Position.x += Delta.x / UpdateDivisor;
	else
		Position.x = TargetPosition.x;

	if(std::abs(Delta.y) > 0.01f)
		Position.y += Delta.y / UpdateDivisor;
	else
		Position.y = TargetPosition.y;

	// Update distance
	float DeltaZ = TargetPosition.z - Position.z;
	if(std::abs(DeltaZ) > 0.01f)
		Position.z += DeltaZ / UpdateDivisor;
	else
		Position.z = TargetPosition.z;
}
Ejemplo n.º 13
0
/** An sample for taylor expansion of logdet(X). */
void taylorSample() {

  std::string ans;
  char rowChar[5];
  int rowTmp = ROW;
  sprintf(rowChar, "%d", rowTmp);
  std::string row = rowChar;
  // Initialize the matrices.
  symbolic_matrix_type X("X", ROW, COL);
  symbolic_matrix_type X0("X0", ROW, COL);
  symbolic_matrix_type Delta("(X-X0)", ROW, COL);
    
  AMD::SymbolicScalarMatlab a2("1/2!");
  AMD::SymbolicScalarMatlab a3("1/3!"); 
  SymbolicSMFunc r2(a2,ROW,COL);
  SymbolicSMFunc r3(a3,ROW, COL);

  // Initialize MatrixMatrixFunction. 
  SymbolicMMFunc fX(X, false);
  SymbolicMMFunc fX0(X0, false);
  SymbolicMMFunc fDelta(Delta, true);

  // Compute Taylor series iteratively. 
  SymbolicSMFunc f0 =  logdet(fX0);
  SymbolicSMFunc f1 = trace(fDelta * transpose(*f0.derivativeFuncVal));
  SymbolicSMFunc f2 = trace(fDelta * transpose(*f1.derivativeFuncVal));
  SymbolicSMFunc f3 = trace(fDelta * transpose(*f2.derivativeFuncVal));
  // Taylor Expansion. 
  SymbolicSMFunc func = f0 + f1 + r2*f2 + r3*f3;

  std::cout<<"The first 4 terms of Taylor Expansion for logdet(X) around X0 is:";
  std::cout << std::endl;
  std::cout << func.functionVal.getString() << std::endl;

}
Ejemplo n.º 14
0
TSIL_COMPLEX Bp (TSIL_REAL X, TSIL_REAL Y, TSIL_COMPLEX S, TSIL_REAL QQ)
{
  if (X < TSIL_TOL) {
    TSIL_Warn("Bp", "B(x',y) is undefined for x=0.");
    return TSIL_Infinity;
  }

  if (TSIL_CABS(1.0L - S/(X+Y+2.0L*TSIL_SQRT(X*Y))) < TSIL_TOL) {
    TSIL_Warn("Bp", "B(x',y) is undefined at s = (sqrt(x) + sqrt(y))^2.");
    return TSIL_Infinity;
  }

  if (TSIL_CABS(S) < TSIL_TOL) {
    if (TSIL_FABS(1.0L - X/Y) < TSIL_TOL)
      return (-0.5L/X);
    else
      return 1.0L/(Y-X) + Y*TSIL_LOG(X/Y)/((Y-X)*(Y-X));
  }

  if (TSIL_CABS(1.0L - (X + Y - 2.0L*TSIL_SQRT(X*Y))/S) < TSIL_TOL) 
    return (1.0L - TSIL_SQRT(Y/X) +0.5L*TSIL_LOG(Y/X))/(X + Y - 2.0L*TSIL_SQRT(X*Y));
  else
    return ((X-Y-S)*B(X,Y,S,QQ) + (X+Y-S)*TSIL_LOG(X/QQ) 
	    -2.0L*A(Y,QQ) + 2.0L*(S-X))/Delta(S,X,Y);
}
Ejemplo n.º 15
0
/**
 * Moves some cargo from one designation to another. You can only move
 * between adjacent designations. E.g. you can keep cargo that was
 * previously reserved (MTA_LOAD) or you can mark cargo to be transferred
 * that was previously marked as to be delivered, but you can't reserve
 * cargo that's marked as to be delivered.
 */
uint VehicleCargoList::Reassign(uint max_move, MoveToAction from, MoveToAction to)
{
	max_move = min(this->action_counts[from], max_move);
	assert(Delta((int)from, (int)to) == 1);
	this->action_counts[from] -= max_move;
	this->action_counts[to] += max_move;
	return max_move;
}
Ejemplo n.º 16
0
TInt DBMLChannel::RequestTimerStampOverhead()
	{
	TBMTicks t1 = PChannel()->TimerStamp();
	TBMTicks t2 = PChannel()->TimerStamp();
	iTime = Delta(t1, t2);
	NKern::ThreadRequestSignal(&iInterruptThread->iNThread);
	return KErrNone;
	}
Ejemplo n.º 17
0
   double DragAlphaBody(double a)
   {
      double delta = Delta(a);
      double eta = Eta(a);

      double c1 = 2 * delta * sqr(a);
      double c2 = 3.6 * cube(a) * eta * ((1.36 * ltr) - (0.55 * ln)) /
         (PI * db);
      return c1 + c2;
   }
Ejemplo n.º 18
0
bool RA::CD2D(const Dim2::Vector &s2, const Dim2::Vector &v2, int D, int B)
{
  if (v2.iszero() && s2.mod < D)
    return true;
  double delta = Delta(s2, v2, D);
  double phi = Phi(s2, v2, D, 1);
  if (!v2.iszero() && delta >= 0 && phi >= B)
    return true;
  return false;
}
Ejemplo n.º 19
0
    // Hash key of the FEN
    Key Zob::compute_fen_key (const string &fen, bool c960) const
    {
        if (fen.empty ()) return U64 (0);
        Key fen_key = U64 (0);
        File king[CLR_NO] = {F_NO};

        istringstream sfen (fen);
        uint8_t ch;

        sfen >> noskipws;

        uint32_t idx;
        Square s = SQ_A8;
        while ((sfen >> ch) && !isspace (ch))
        {
            if (isdigit (ch))
            {
                s += Delta (ch - '0'); // Advance the given number of files
            }
            else if (isalpha (ch) && (idx = CharPiece.find (ch)) != string::npos)
            {
                Piece p = Piece (idx);
                fen_key ^= _.psq_k[_color (p)][_ptype (p)][s];
                ++s;
            }
            else if (ch == '/')
            {
                s += DEL_SS;
            }
        }

        sfen >> ch;
        if ('w' == ch) fen_key ^= _.mover_side;

        sfen >> ch;
        if (c960)
        {
            while ((sfen >> ch) && !isspace (ch))
            {
                Color c = isupper (ch) ? WHITE : BLACK;
                uint8_t sym = tolower (ch);
                if ('a' <= sym && sym <= 'h')
                {
                    fen_key ^= _.castle_right[c][(king[c] < to_file (sym)) ? CS_K : CS_Q];
                }
                else
                {
                    return U64 (0);
                }
            }
        }
        else
        {
            while ((sfen >> ch) && !isspace (ch))
Ejemplo n.º 20
0
void WalkRegion::setPos(int x, int y) {
	// Calculate the difference between old and new position
	Vertex Delta(x - _position.x, y - _position.y);

	// Move all the nodes
	for (uint i = 0; i < _nodes.size(); i++)
		_nodes[i] += Delta;

	// Move regions
	Region::setPos(x, y);
}
Ejemplo n.º 21
0
	virtual void OnTick()
	{
		/* Scroll up newsmessages from the bottom in steps of 4 pixels */
		int y = max(this->top - 4, _screen.height - this->height - this->status_height - this->chat_height);
		if (y == this->top) return;

		if (this->viewport != NULL) this->viewport->top += y - this->top;

		int diff = Delta(this->top, y);
		this->top = y;

		SetDirtyBlocks(this->left, this->top, this->left + this->width, this->top + this->height + diff);
	}
Ejemplo n.º 22
0
static void GetAvailableVideoMode(uint *w, uint *h)
{
	/* All modes available? */
	if (_all_modes || _num_resolutions == 0) return;

	/* Is the wanted mode among the available modes? */
	for (int i = 0; i != _num_resolutions; i++) {
		if (*w == _resolutions[i].width && *h == _resolutions[i].height) return;
	}

	/* Use the closest possible resolution */
	int best = 0;
	uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
	for (int i = 1; i != _num_resolutions; ++i) {
		uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
		if (newdelta < delta) {
			best = i;
			delta = newdelta;
		}
	}
	*w = _resolutions[best].width;
	*h = _resolutions[best].height;
}
Ejemplo n.º 23
0
static void GetAvailableVideoMode(uint *w, uint *h)
{
	/* No video modes, so just try it and see where it ends */
	if (_num_resolutions == 0) return;

	/* is the wanted mode among the available modes? */
	for (int i = 0; i != _num_resolutions; i++) {
		if (*w == _resolutions[i].width && *h == _resolutions[i].height) return;
	}

	/* use the closest possible resolution */
	int best = 0;
	uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
	for (int i = 1; i != _num_resolutions; ++i) {
		uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
		if (newdelta < delta) {
			best = i;
			delta = newdelta;
		}
	}
	*w = _resolutions[best].width;
	*h = _resolutions[best].height;
}
Ejemplo n.º 24
0
double RK4_adaptive_step(               // returns adapted time step
    Matrix<double,1>& x,                // solution vector
    double dt,                          // initial time step
    Matrix<double,1> flow(Matrix<double,1>&),  // derivative vector
    double accuracy)                    // desired accuracy
{
    // from Numerical Recipes
    const double SAFETY = 0.9, PGROW = -0.2, PSHRINK = -0.25,
                 ERRCON = 1.89E-4, TINY = 1.0E-30;
    int n = x.size();
    Matrix<double,1> scale = flow(x), x_half(n), Delta(n);
    for (int i = 0; i < n; i++)
        scale[i] = abs(x[i]) + abs(scale[i] * dt) + TINY;
    double error = 0;
    while (true) {
        dt /= 2;
        x_half = x;
        RK4_step(x_half, dt, flow);
        RK4_step(x_half, dt, flow);
        dt *= 2;
        Matrix<double,1> x_full = x;
        RK4_step(x_full, dt, flow);
        for (int i = 0; i < n; i++)
            Delta[i] = x_half[i] - x_full[i];
        error = 0;
        for (int i = 0; i < n; i++)
            error = max(abs(Delta[i] / scale[i]), error);
        error /= accuracy;
        if (error <= 1)
            break;
        double dt_temp = SAFETY * dt * pow(error, PSHRINK);
        if (dt >= 0)
            dt = max(dt_temp, 0.1 * dt);
        else
            dt = min(dt_temp, 0.1 * dt);
        if (abs(dt) == 0.0) {
            cerr << " step size underflow" << endl;
            exit(1);
        }
    }
    if (error > ERRCON)
        dt *= SAFETY * pow(error, PGROW);
    else
        dt *= 5.0;
    for (int i = 0; i < n; i++)
        x[i] = x_half[i] + Delta[i] / 15.0;
    return dt;
}
Ejemplo n.º 25
0
void generate_steps(const GameState& gs, std::vector<Delta> *steps)
{
  const Board& not_frozen = ~frozen_pieces(gs, gs.get_color());

  for (unsigned int dir_empty = NORTH; dir_empty < num_directions(); ++dir_empty) {

    Board pieces_with_step = adj_step(gs, gs.get_color(), dir_empty) & not_frozen;

    assert((pieces_with_step & gs.get_color_board(gs.get_color())) == pieces_with_step);

    while(!pieces_with_step.is_empty()) {
      uint8_t mobile_idx = pieces_with_step.idx_and_reset();
      assert(gs.get_all_const().contains(mobile_idx));
      steps->push_back(Delta(step_from_gs(gs, mobile_idx, dir_empty)));
    }
  }
}
Ejemplo n.º 26
0
void generate_pushes(const GameState& gs, std::vector<Delta> *pushes)
{
  const uint8_t pushing_color = gs.get_color();
  const uint8_t pushed_color = other_color(gs.get_color());
  const Board& pushing_mobile = ~frozen_pieces(gs, gs.get_color());

  Board pushed_with_adj_empty[4];

  // The body of generate_pushes() takes the perspective of the pushed piece.  
  // dir_pushed_from is the direction from which the pushing piece comes from.
  // dir_pushed is the direction the pushed piece is pushed to.

  for (unsigned int dir = NORTH; dir < num_directions(); ++dir) {
    pushed_with_adj_empty[dir] = adj_empty(gs, pushed_color, dir);
  }

  for (unsigned int dir_pushed_from = NORTH; dir_pushed_from < num_directions(); ++dir_pushed_from) {

    // the mobile pushing pieces with an adjacent weaker piece.
    // We use the opp_dir(dir_pushed_from) here since we are talking about the pushing piece.
    const Board& pushing_pieces_with_adj_lt = 
      adj_enemy_lt(gs, pushing_color, opp_dir(dir_pushed_from)) & pushing_mobile;

    for (unsigned int dir_pushed = NORTH; dir_pushed < num_directions(); ++dir_pushed) {
      if (dir_pushed_from == dir_pushed) continue;

      // TODO: Try and make symmetric with generate_pulls() -- simplify inner loop here...
      Board pushing_pieces = 
        is_adjacent(pushing_pieces_with_adj_lt, pushed_with_adj_empty[dir_pushed],
            opp_dir(dir_pushed_from));

      Board pushed_pieces = 
        is_adjacent(pushed_with_adj_empty[dir_pushed], pushing_pieces_with_adj_lt, dir_pushed_from);

      while(!pushed_pieces.is_empty()) {
        assert(!pushing_pieces.is_empty());
        uint8_t pushed_idx = pushed_pieces.idx_and_reset();
        uint8_t pusher_idx = pushing_pieces.idx_and_reset();
        assert(gs.get_all_const().contains(pushed_idx));
        assert(gs.get_all_const().contains(pusher_idx));
        pushes->push_back(Delta(step_from_gs(gs, pushed_idx, dir_pushed),
              step_from_gs(gs, pusher_idx, opp_dir(dir_pushed_from))));
      }
    }
  }
}
Ejemplo n.º 27
0
int main(int argc, char* argv[ ]) {
	double v, w, x, y, z;
	double timer = omp_get_wtime();
	int thread_count = 1;
	if (argc>1)
		thread_count = strtol(argv[1], NULL, 10);

#	pragma omp parallel num_threads(thread_count)
  	{
#		pragma omp sections
		{
#			pragma omp section
			{
				v = Alpha( );
				printf("v = %lf\n", v);
			}
#			pragma omp section
			{
				w = Beta( );
				printf("w = %lf\n", w);
			}
		}

#		pragma omp sections
		{
#			pragma omp section
			{
				x = Gamma(v, w);
				printf("x = %lf\n", x);
			}
#			pragma omp section
			{
				y = Delta( );
				printf("y = %lf\n", y);
			}
		}
	}

	z = Epsilon(x, y);
	printf("z = %lf\n", z);

	timer = omp_get_wtime() - timer;
	printf("timer = %lf\n", timer);

	return 0;
}
Ejemplo n.º 28
0
	bool PointsGroup::CheckAdjacence(DoubleList* list) const
	{
		auto cit = list->begin();
		if (list->size() < 2) return true;
		double max = -DBL_MAX, min = DBL_MAX;
		while (cit != list->end())
		{
			if(max < *cit)
				max = *cit;
			if(min > *cit)
				min = *cit;
			cit++;
		}
		double delta = std::fabs((max - min)/(max + min));
		
		return delta < Delta();
	}
Ejemplo n.º 29
0
SimplePropertySet<string, double> propertylist() 
{

	SimplePropertySet<string, double> result;

	result.add (Property<string, double> ("Option Value", Price() ) );
	result.add (Property<string, double> ("Delta",Delta() ) );
	result.add (Property<string, double> ("Gamma",Gamma() ) );
	result.add (Property<string, double> ("Vega",Vega() ) );
	result.add (Property<string, double> ("Vega",Theta() ) );
	result.add (Property<string, double> ("Rho",Rho() ) );
	result.add (Property<string, double> ("Cost of Carry",Coc() ) );										// Cost of carry
	
	cout << "counbt " << result.Count();
	return result;

}
Ejemplo n.º 30
0
/** 
 * Convert wave data to MFCC.  Also does spectral subtraction
 * if @a ssbuf specified.
 * 
 * @param wave [in] waveform data
 * @param mfcc [out] buffer to store the resulting MFCC parameter vector [t][0..veclen-1], should be already allocated
 * @param para [in] configuration parameters
 * @param nSamples [in] length of waveform data
 * @param w [i/o] MFCC calculation work area
 * 
 * @return the number of processed frames.
 */
int
Wav2MFCC(SP16 *wave, float **mfcc, Value *para, int nSamples, MFCCWork *w, CMNWork *c)
{
  int i, k, t;
  int end = 0, start = 1;
  int frame_num;                    /* Number of samples in output file */

  /* set noise spectrum if any */
  if (w->ssbuf != NULL) {
    /* check ssbuf length */
    if (w->ssbuflen != w->bflen) {
      jlog("Error: mfcc-core: noise spectrum length not match\n");
      return FALSE;
    }
  }

  frame_num = (int)((nSamples - para->framesize) / para->frameshift) + 1;
  
  for(t = 0; t < frame_num; t++){
    if(end != 0) start = end - (para->framesize - para->frameshift) - 1;

    k = 1;
    for(i = start; i <= start + para->framesize; i++){
      w->bf[k] = (float)wave[i - 1];  k++;
    }
    end = i;
    
    /* Calculate base MFCC coefficients */
    WMP_calc(w, mfcc[t], para);
  }
  
  /* Normalise Log Energy */
  if (para->energy && para->enormal) NormaliseLogE(mfcc, frame_num, para);
  
  /* Delta (consider energy suppress) */
  if (para->delta) Delta(mfcc, frame_num, para);

  /* Acceleration */
  if (para->acc) Accel(mfcc, frame_num, para);

  /* Cepstrum Mean and/or Variance Normalization */
  if (para->cmn && ! para->cvn) CMN(mfcc, frame_num, para->mfcc_dim + (para->c0 ? 1 : 0), c);
  else if (para->cmn || para->cvn) MVN(mfcc, frame_num, para, c);

  return(frame_num);
}