Пример #1
0
void CSetDlgColors::ColorSetEdit(HWND hWnd2, WORD c)
{
	_ASSERTE(hWnd2!=NULL);
	// Hook ctrl procedure
	if (!gColorBoxMap.Initialized())
		gColorBoxMap.Init(128);
	HWND hBox = GetDlgItem(hWnd2, c);
	if (!gColorBoxMap.Get(hBox, NULL))
	{
		WNDPROC pfnOld = (WNDPROC)SetWindowLongPtr(hBox, GWLP_WNDPROC, (LONG_PTR)ColorBoxProc);
		gColorBoxMap.Set(hBox, pfnOld);
	}
	// text box ID
	WORD tc = (tc0-c0) + c;
	// Well, 11 chars are enough for "255 255 255"
	// But sometimes it is interesting to copy/paste/cut when editing palettes, so x2
	SendDlgItemMessage(hWnd2, tc, EM_SETLIMITTEXT, 23, 0);
	COLORREF cr = 0;
	GetColorById(c, &cr);
	wchar_t temp[16];
	switch (gpSetCls->m_ColorFormat)
	{
	case CSettings::eRgbHex:
		_wsprintf(temp, SKIPLEN(countof(temp)) L"#%02x%02x%02x", getR(cr), getG(cr), getB(cr));
		break;
	case CSettings::eBgrHex:
		_wsprintf(temp, SKIPLEN(countof(temp)) L"0x%02x%02x%02x", getB(cr), getG(cr), getR(cr));
		break;
	default:
		_wsprintf(temp, SKIPLEN(countof(temp)) L"%i %i %i", getR(cr), getG(cr), getB(cr));
	}
	SetDlgItemText(hWnd2, tc, temp);
}
Пример #2
0
bool
Stokhos::JacobiBasis<ordinal_type, value_type>::
computeRecurrenceCoefficients(ordinal_type n,
			      Teuchos::Array<value_type>& alpha,
			      Teuchos::Array<value_type>& beta,
			      Teuchos::Array<value_type>& delta,
			      Teuchos::Array<value_type>& gamma) const
{
  value_type a = alphaIndex_;
  value_type b = betaIndex_;

  if (a==0.0 && b==0.0)
  {
    alpha[0] = 0.0;
    beta[0] = 1.0;
    delta[0] = 1.0;
    gamma[0] = 1.0;
  }
  else
  {
    alpha[0] = getB(0)/getA(0);
    beta[0] = 1.0;
    delta[0] = getC(0)/getA(0);
    gamma[0] = 1.0;
  }
  for (ordinal_type i=1; i<n; i++) 
  {
    alpha[i] = getB(i)/getA(i);
    beta[i] = getD(i)/getA(i);
    delta[i] = getC(i)/getA(i);
    gamma[i] = 1.0;
  }

  return false;
}
Пример #3
0
int main() {
    E e;
    D d;
    int e_B = getB( &e );
    int d_B = getB( &d );
    if( e_B <= d_B ) fail(__LINE__);
    if(( e_B - d_B ) != 3 ) fail(__LINE__);
    _PASS;
}
Пример #4
0
void initActivationRecord(problem* problem, int* partial, int plant, int used_mask, int cur_cost, volatile int* best_known, call_record** pos, int* partial_store, int* partial_store_index, int cut) {
	
	// cut-off here
	if (cut == 0) {

		// reserve memory in partial solution store
		int partial_pos = *partial_store_index;
		*partial_store_index += problem->size;

		// copy partial solution to store
		memcpy(&(partial_store[partial_pos]), partial, problem->size * sizeof(int));
		
		// add call record
		(**pos) = (call_record){partial_pos, plant, used_mask, cur_cost};
		(*pos)++;
		return;
	}

	// standard body for the rest
	
	// terminal case
	if (plant >= problem->size) {
		return;
	}

	if (cur_cost >= *best_known) {
		return;
	}


	// fix current position
	for(int i=0; i<problem->size; i++) {
		// check whether current spot is a free spot
		if(!(1<<i & used_mask)) {
			// extend solution
			int tmp[problem->size];
			memcpy(tmp, partial, problem->size*sizeof(int));
			tmp[plant] = i;

			// compute additional cost of current assignment
			int new_cost = 0;
			
			for(int j=0; j<plant; j++) {
				int other_pos = tmp[j];

				// add costs between current pair of plants
				new_cost += getA(problem, plant, j) * getB(problem, i, other_pos);
				new_cost += getA(problem, j, plant) * getB(problem, other_pos, i);
			}

			// fill recoreds recursively
			initActivationRecord(problem, tmp, plant+1, used_mask | (1<<i), cur_cost + new_cost, best_known, pos, partial_store, partial_store_index, cut-1);

		}
	}
}
Пример #5
0
bool WindowBitmap::rgbEqual(int x1, int y1, int x2, int y2)
{
   int r1 = getR(x1, y1);
   int g1 = getG(x1, y1);
   int b1 = getB(x1, y1);

   int r2 = getR(x2, y2);
   int g2 = getG(x2, y2);
   int b2 = getB(x2, y2);

   return (r1 == r2) && (g1 == g2) && (b1 == b2);
}
Пример #6
0
vector<double> CIEColor::getCseg(vector<double> p0, vector<double> p1, vector<double> p2, vector<double> q0, vector<double> q1, vector<double> q2, double t)
{
	vector<double> output;
	if(t<=0.5)
	{
		output = getB( p0, q0, q1, 2*t);	
	}
	else
	{
	    output = getB( q1, q2, p2, 2*(t-0.5));	
	}	
	return output;
}
Пример #7
0
int solve_rec(problem* problem, int* partial, int plant, int used_mask, int cur_cost, volatile int* best_known) {
	// terminal case
	if (plant >= problem->size) {
		return cur_cost;
	}

	if (cur_cost >= *best_known) {
		return *best_known;
	}


	// fix current position
	for(int i=0; i<problem->size; i++) {
		// check whether current spot is a free spot
//		#pragma omp task
		if(!(1<<i & used_mask)) {
			// extend solution
			int tmp[problem->size];
			memcpy(tmp, partial, problem->size*sizeof(int));
			tmp[plant] = i;

			// compute additional cost of current assignment
			int new_cost = 0;
			
			for(int j=0; j<plant; j++) {
				int other_pos = tmp[j];

				// add costs between current pair of plants
				new_cost += getA(problem, plant, j) * getB(problem, i, other_pos);
				new_cost += getA(problem, j, plant) * getB(problem, other_pos, i);
			}

			// compute recursive rest
			int cur_best = solve_rec(problem, tmp, plant+1, used_mask | (1<<i), cur_cost + new_cost, best_known);

			// update best known solution
			if (cur_best < *best_known) {
				int best;
				//   |--- read best ---|          |--- check ---|    |------------ update if cur_best is better ------------|
				do { best = *best_known; } while (cur_best < best && __sync_bool_compare_and_swap(best_known, best, cur_best));
			}
		}
	}

//	#pragma omp taskwait

	return *best_known;
}
Пример #8
0
void G2::restore(char *bytes)
{
	int i,j,n=(1<<WINDOW_SIZE);
	int bytes_per_big=(MIRACL/8)*(get_mip()->nib-1);
	int len=n*2*bytes_per_big;
	Big x,y,B;
	if (mtable!=NULL) return;

	mtable=new ECn[1<<WINDOW_SIZE];
	B=getB();
	B=-B;
	ecurve((Big)-3,B,get_modulus(),MR_PROJECTIVE);  // move to twist	
	for (i=j=0;i<n;i++)
	{
		x=from_binary(bytes_per_big,&bytes[j]);
		j+=bytes_per_big;
		y=from_binary(bytes_per_big,&bytes[j]);
		j+=bytes_per_big;

		mtable[i].set(x,y);

	}
	B=-B;
	ecurve((Big)-3,B,get_modulus(),MR_PROJECTIVE);  // move back
	delete [] bytes;
}
Пример #9
0
int main()
{
	unsigned long atomicValue = 4;
	unsigned long retValue = atomic(&atomicValue, 7);

	A fourAs[4] = {1, 2, 3, 4};

	a.inc();
	a.get();

	ptrA = getNewA();
	ptrA = getNewA();

	ptrA->inc();

	toBSS++;

	/* StackCopy Objekt wird aus lokalem Stack-Frame von getStackCopy in den aktuellen Stack-Frame kopiert */
	/* ab 3 Rückgabewerte erfolgt die Rückgabe über den Stack und nicht mehr über Register */
	/* ab dem 8. Parameter werden diese ebenfalls über den Stack übergeben und nicht mehr ausschließlich über Register */
	const StackCopy& stackCopy = getStackCopy();
	/* Error --> Veränderung eines temporären Objekts ist fehleranfällig und deshalb verboten */
	// StackCopy& stackCopy = getStackCopy();
	const RegCopy& regCopy = getRegCopy();
	int ret4 = return4();
	B b = getB();

	int terminator = 0x1234567;

	return 0;
}
	// get the status string
	string R34HC22::statusString(){
		stringstream stream;
		stream << "Current Program Counter location: " << hex << getProgCounter() << endl;
		stream << "A register value: " << hex << (int)getA() << endl;
		stream << "B register value: " << hex << (int)getB();
		return stream.str();
	}
Пример #11
0
JNIEXPORT void JNICALL Java_jp_dego_sample_ipcv_MainActivity_getGrayScale(JNIEnv *env, jobject obj, jintArray pix,
        jint w, jint h)
{
    unsigned char r, g, b, gray;
    jint* pixels = (*env)->GetIntArrayElements(env, pix, 0);

    int i;
    for (i = 0; i < w * h; i++) {
        // rgb 抽出
        // r = (pixels[i] & 0x00FF0000) >> 16;
        // g = (pixels[i] & 0x0000FF00) >> 8;
        // b = (pixels[i] & 0x000000FF);
        r = getR(pixels[i]);
        g = getG(pixels[i]);
        b = getB(pixels[i]);

        // グレイスケールの輝度値を計算
        gray = (r + g + b) / 3;
        if (gray > 255)
            gray = 255;

        // 色データ組み換え
        pixels[i] = 0xFF000000 | (gray << 16) | (gray << 8) | gray;
        // pixels[i] = gray;
    }

    // 確保したメモリを開放
    (*env)->ReleaseIntArrayElements(env, pix, pixels, 0);
}
	// 0x5B
	// Branch if A < B
	void R34HC22::branchIfALessThanB(int address)
	{
		if((address + 3) < getMemSize())
		{
			// compare the value of A and B
			if(getA() < getB())
			{
				if(getLocation(address,1,2) != -1)
				{
					// set the program counter to the new address
					setProgCounter(getLocation(address,1,2));
					executeFromLocation(getLocation(address,1,2));
					cout << complete_mess << endl;
				} else {
					cout << invalid_mem << endl;
					haltOpcode();
				}
			} else {
				// set the program counter to the third byte after the opcode
				setProgCounter(address + 3);
				executeFromLocation(address + 3);
				cout << complete_mess << endl;
			}
		} else {
			cerr << error_mess << endl;
			haltOpcode();
		}
	}
Пример #13
0
	void MCNeuronSim::setupSingleNeuronParms(int grpRowId, int neurId, bool coupledComp){
			for(unsigned int c = 0; c < compCount; c++) // each neuron has compCount compartments
			{
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "C", getCm(neurId, c));
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "k", getK(neurId, c));
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "vr", getVr(neurId));
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "vt", getVt(neurId, c));
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "a", getA(neurId, c));
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "b", getB(neurId, c));
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "vpeak", getVpeak(neurId, c));
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "c", getVmin(neurId, c));
				network->setIzhikevichParameter(excGroup[grpRowId][c], neurId, "d", getD(neurId, c));

				if(coupledComp){
					if(c>0){
						double G = getG(neurId, c); //parameters[neurId][G_idx[c-1]];
						double P = getP(neurId, c);//parameters[neurId][P_idx[c-1]];
						float fwd = G * P;
						float bwd = G * (1-P);
						/*
						 * generally, fwd is carlsim 'down', bwd is carlsim 'up' for the purpose of coupling constant assignment, but,
						 * when there is a dendrite 'below' soma: ****cases 3c2 and 4c2***
						 * up and down are reversed.
						 */
						if(compCount>2 && c==1 && connLayout[c]==connLayout[c+1]){ //meaning 2 dendrites (dend 1 and dend2 ) connecting to the same point
							network->setCouplingConstant(excGroup[grpRowId][connLayout[c]], neurId, "down", bwd);
							network->setCouplingConstant(excGroup[grpRowId][c], neurId, "up", fwd);
						}else{
							network->setCouplingConstant(excGroup[grpRowId][c], neurId, "down", fwd);
							network->setCouplingConstant(excGroup[grpRowId][connLayout[c]], neurId, "up", bwd);
						}
					}
				}
			}
		}
Пример #14
0
LabColour const LabColour::withMultipliedColour (float amount) const
{
  return LabColour (
    getL (),
    getA () * amount,
    getB () * amount,
    getAlpha ());
}
Пример #15
0
bool WindowBitmap::rgbEqual(int x1, int y1, BYTE r, BYTE g, BYTE b)
{
   int r1 = getR(x1, y1);
   int g1 = getG(x1, y1);
   int b1 = getB(x1, y1);

   return (r1 == r) && (g1 == g) && (b1 == b);
}
Пример #16
0
bool WindowBitmap::rgbNear(int x1, int y1, BYTE r, BYTE g, BYTE b)
{
   int r1 = getR(x1, y1);
   int g1 = getG(x1, y1);
   int b1 = getB(x1, y1);

   return (abs(r1-r)<=10) && (abs(g1-g)<=10) && (abs(b1-b)<=10);
}
Пример #17
0
bool WindowBitmap::rgbLess(int x1, int y1, BYTE r, BYTE g, BYTE b)
{
   int r1 = getR(x1, y1);
   int g1 = getG(x1, y1);
   int b1 = getB(x1, y1);

   return (r1 < r) && (g1 < g) && (b1 < b);
}
Пример #18
0
bool WindowBitmap::rgbLarger(int x1, int y1, BYTE r, BYTE g, BYTE b)
{
   int r1 = getR(x1, y1);
   int g1 = getG(x1, y1);
   int b1 = getB(x1, y1);

   return (r1 > r) && (g1 > g) && (b1 > b);
}
Пример #19
0
vector<double>* OutputFile::getRhoPerSite()
{
  int L=getL();
  int b=getB();
  vector<double>*v=new vector<double>();
  for (unsigned int i=0; i<rhos.size(); i++) v->push_back(rhos[i]/(deltas[i]*b+L-b));
  return v;
}
Пример #20
0
LabColour const LabColour::withAddedLuminance (float amount) const
{
  return LabColour (
    jlimit (0.f, 100.f, getL() + amount * 100),
    getA (),
    getB (),
    getAlpha ());
}
Пример #21
0
LabColour const LabColour::withLuminance (float L) const
{
  return LabColour (
    jlimit (0.f, 100.f, L),
    getA (),
    getB (),
    getAlpha ());
}
Пример #22
0
bool Pyramid::isInside(Point3D point) const {
	return point.getP().getX() >= 0 &&
		   point.getP().getY() >= 0 &&
		   point.getZ() >= 0 &&
		   point.getP().getX() / getA() +
		   point.getP().getY() / getB() +
		   point.getZ() / getC() <= 1;
}
Пример #23
0
 std::string WeibullDeviate::make_repr(bool incl_seed)
 {
     std::ostringstream oss(" ");
     oss << "galsim.WeibullDeviate(";
     if (incl_seed) oss << seedstring(split(serialize(), ' ')) << ", ";
     oss << "a="<<getA()<<", ";
     oss << "b="<<getB()<<")";
     return oss.str();
 }
Пример #24
0
Vector Quaternion::derivative(const Vector &w)
{
#ifdef QUATERNION_ASSERT
	ASSERT(w.getRows() == 3);
#endif
	float dataQ[] = {
		getA(), -getB(), -getC(), -getD(),
		getB(),  getA(), -getD(),  getC(),
		getC(),  getD(),  getA(), -getB(),
		getD(), -getC(),  getB(),  getA()
	};
	Vector v(4);
	v(0) = 0.0f;
	v(1) = w(0);
	v(2) = w(1);
	v(3) = w(2);
	Matrix Q(4, 4, dataQ);
	return Q * v * 0.5f;
}
Пример #25
0
void main(){
  int a,s,b,n;
  a = getInt();
  s = getS(a);
  b = getB(a);
  a = getN(a);
  n = getN(a);
  putB(b);
  putS(s);
  putN(n);
}
Пример #26
0
static int py_anal(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAnalOpMask mask) {
	PyObject *tmpreg = NULL;
	int size = 0;
	int seize = -1;
	int i = 0;
	if (!op) return -1;
	if (py_anal_cb) {
		memset(op, 0, sizeof (RAnalOp));
		// anal(addr, buf) - returns size + dictionary (structure) for RAnalOp
		Py_buffer pybuf = {
			.buf = (void *) buf, // Warning: const is lost when casting
			.len = len,
			.readonly = 1,
			.ndim = 1,
			.itemsize = 1,
		};
		PyObject *memview = PyMemoryView_FromBuffer (&pybuf);
		PyObject *arglist = Py_BuildValue ("(NK)", memview, addr);
		PyObject *result = PyEval_CallObject (py_anal_cb, arglist);
		if (result && PyList_Check (result)) {
			PyObject *len = PyList_GetItem (result, 0);
			PyObject *dict = PyList_GetItem (result, 1);
			if (dict && PyDict_Check (dict)) {
				seize = PyNumber_AsSsize_t (len, NULL);
				op->type = getI (dict, "type");
				op->cycles = getI (dict, "cycles");
				op->size = seize;
				op->addr = getI (dict, "addr");
				op->jump = getI (dict, "jump");
				op->fail = getI (dict, "fail");
				op->stackop = getI (dict, "stackop");
				op->stackptr = getI (dict, "stackptr");
				op->ptr = getI (dict, "ptr");
				op->eob = getB (dict, "eob");
				// Loading 'src' and 'dst' values
				// SRC is is a list of 3 elements
				PyObject *tmpsrc = getO (dict, "src");
				if (tmpsrc && PyList_Check (tmpsrc)) {
					for (i = 0; i < 3; i++) {
						PyObject *tmplst = PyList_GetItem (tmpsrc, i);
						// Read value and underlying regs
						READ_VAL(tmplst, op->src[i], tmpreg)
					}
				}
				PyObject *tmpdst = getO (dict, "dst");
				// Read value and underlying regs
				READ_VAL(tmpdst, op->dst, tmpreg)
				// Loading 'var' value if presented
				r_strbuf_set (&op->esil, getS (dict, "esil"));
				// TODO: Add opex support here
				Py_DECREF (dict);
			}
			Py_DECREF (result);
		} else {
Пример #27
0
realkind FieldDataCPU::BFieldEnergy(void)
{
	double Bx_t, By_t, Bz_t, Bmag;

	Bmag = 0;
	for(int k=0;k<nz;k++)
	{
		for(int j=0;j<ny;j++)
		{
			for(int i=0;i<nx;i++)
			{

				Bx_t = getB(i,j,k,0);
				By_t = getB(i,j,k,1);
				Bz_t = getB(i,j,k,2);

				Bmag += (Bx_t*Bx_t + By_t*By_t + Bz_t*Bz_t);

			}
		}
	}

	Bmag *= 0.5*pdata->dxdi*pdata->bobzeta;
	if(pdata->ndimensions == 1)
		Bmag /= pdata->ny*pdata->nz;

	if(pdata->ndimensions > 1)
		Bmag *= pdata->dydi/(pdata->nz*pdata->Lx*pdata->Ly);


	if(pdata->ndimensions > 2)
		Bmag *= pdata->dzdi;

//	Bmag *= pdata->q0*pdata->q0*pdata->m0/(pdata->L0*pdata->L0*mu_0_p);

	realkind energy = Bmag/pdata->Lx;

	return energy;


}
Пример #28
0
/*
 * By working with the problem, we can express the numbers b and c based on a.
 * So we go through numbers and try to find an a that makes all other
 * restrictions fall into place.
 */
long solution() {
    //natural numbers, so a=0 isn't an accepted solution.
    for(long a = 1; ; ++a) {
        long b = getB(a);
        long c = getC(a, b);
        if(isSolution(a, b, c))
            return a*b*c;
    }

    //if it didn't find a solution return -1 as an indication of error
    return -1;
}
Пример #29
0
Vect Triangle::surfaceNormal(Vect dir, Vect pt) {
    (void) pt;

    Vect v = getB() - getA();
    Vect w = getC() - getA();
    Vect N = v.crossProduct(w);
    N.normalize();

    if (N.dotProduct(dir) > 0)
        N = N.linearMult(-1);
    
    return N;
}
Пример #30
0
    void DistanceConstraint::solve(const float dt)
    {
        // get some information that we need
		sf::Vector2f axis = getB()->getPosition() - getA()->getPosition();
		float currentDistance = length(axis);
		sf::Vector2f unitAxis = axis * (1.f/currentDistance);

		// calculate relative velocity in the axis, we want to remove this
		float relVel = dot(getB()->getVelocity() - getA()->getVelocity(), unitAxis);

		float relDist = currentDistance-distance;

		// calculate impulse to solve
		float remove = relVel+relDist/dt;
		float impulse = remove / (getA()->getInverseMass() + getB()->getInverseMass());

		// generate impulse vector
		sf::Vector2f I = unitAxis*impulse;

		// apply
		applyImpulse(I);
    }