Beispiel #1
0
void AntObject::stun()
{
    _stun = 8;
    if(hasFood())
        pManager->food[getP().y][getP().x]++;
    chFood() = false;
}
Beispiel #2
0
double CMesh::getFOSSST() {
	for (int i=mXSize; i> 0; i--) {
		double mT = getT(0,i-1,0);
		if ( mT > mFOTemp) {
			double v1 =  ( getPixy(0,i-1,0,1,1) + getPixy(0,i-1,0,2,2))	/( getE(0,i-1,0) + getP(0,i-1,0));
			double v2 =  ( getPixy(0,i,0,1,1) + getPixy(0,i,0,2,2))	/( getE(0,i,0) + getP(0,i,0));
			return (1./JHBARC) * (v1 + (v2- v1) * ((mFOTemp - mT) /(getT(0,i,0) - mT)));
		}
	}
	return 0.;
}
Beispiel #3
0
 bool isRectangleCover(vector<vector<int>>& rectangles) {
     int n = rectangles.size();
     if (n == 0) {
         return false;
     }
     vector<Rect> rects;
     for (int i = 0; i < n; ++i) {
         rects.emplace_back(rectangles[i]);
     }
     Rect r = rects[0];
     for (int i = 1; i < n; ++i) {
         r.bottom = min(r.bottom, rects[i].bottom);
         r.left = min(r.left, rects[i].left);
         r.top = max(r.top, rects[i].top);
         r.right = max(r.right, rects[i].right);
     }
     unordered_map<u64, int> hit_map;
     for (auto& a : rects) {
         hit_map[getP(a.bottom, a.left)]++;
         hit_map[getP(a.bottom, a.right)]++;
         hit_map[getP(a.top, a.left)]++;
         hit_map[getP(a.top, a.right)]++;
     }
     for (auto& pair : hit_map) {
         int y, x;
         getPos(pair.first, &y, &x);
         if ((y == r.bottom || y == r.top) && (x == r.left || x == r.right)) {
             if (pair.second != 1) {
                 printf("y = %d, x = %d, count = %d\n", y, x, pair.second);
                 return false;
             }
         } else {
             if (pair.second != 2 && pair.second != 4) {
                 printf("t2, y = %d, x = %d, count = %d\n", y, x, pair.second);
                 return false;
             }
         }
     }
     u64 total_area = (u64)(r.top - r.bottom) * (r.right - r.left);
     u64 sum_area = 0;
     for (auto& r : rects) {
         u64 a = (u64)(r.top - r.bottom) * (r.right - r.left);
         if (a + sum_area < sum_area) {
             return false;
         }
         sum_area += a;
     }
     printf("sum_area = %lld, total_area = %lld\n", sum_area, total_area);
     return sum_area == total_area;
 }
Beispiel #4
0
void Bola::desenhaBola(BITMAP *buffer){//, Ponto p){
	int r, g, b;
	int d = getD();
	Ponto p = getP();
	Cor_bola c = getCor();
	switch(c){
		case AMARELO:
			r = 255;
			g = 255;
			b = 0;
			break;
		case VERDE:
			r = 0;
			g = 255;
			b = 0;
			break;
		case AZUL:
			r = 0;
			g = 0;
			b = 255;
			break;
		default: // VERMELHO:
			r = 255;
			g = 0;
			b = 0;
			break;
	}
	circlefill(buffer, p.x, p.y, d/2, makecol(r, g, b));

}
Beispiel #5
0
std::vector< double >& Population::getChromosome(unsigned i) {
	#ifdef RANGECHECK
		if(i >= getP()) { throw std::range_error("Invalid individual identifier."); }
	#endif
	
	return population[ fitness[i].second ];
}
Beispiel #6
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);
						}
					}
				}
			}
		}
Beispiel #7
0
float PID :: getPID (const float pv, const float sp)
{
	m_previousError = m_error;
	m_error = sp - pv;

	return (m_p * getP()) + (m_i * getI(1.0)) + (m_d * getD());
}
Beispiel #8
0
FFElement FiniteField::makeElement(const Polynomial& p) const {
    assert(p.getMod() == getP());
    if (p.getDomain() == domain) return FFElement(p, this);
    std::vector<FieldElement> coeffs;
    for (auto& c : p.getCoeffs()) coeffs.push_back(domain->getField()->makeElement(c.getVal()));
    return FFElement(domain->makeElement(coeffs), this);
}
void KalmanFilter::updateKalman() {
  double** K = getK();

  getP(K);
  getX(K);

  freeMatrix(K,3);
}
Beispiel #10
0
void Pid::postState(TunerStudioOutputChannels *tsOutputChannels) {
	tsOutputChannels->debugFloatField2 = getIntegration();
	tsOutputChannels->debugFloatField3 = getPrevError();
	tsOutputChannels->debugFloatField4 = getI();
	tsOutputChannels->debugFloatField5 = getD();
	tsOutputChannels->debugIntField1 = getP();
	tsOutputChannels->debugIntField2 = getOffset();
}
Beispiel #11
0
 std::string BinomialDeviate::make_repr(bool incl_seed)
 {
     std::ostringstream oss(" ");
     oss << "galsim.BinomialDeviate(";
     if (incl_seed) oss << seedstring(split(serialize(), ' ')) << ", ";
     oss << "N="<<getN()<<", ";
     oss << "p="<<getP()<<")";
     return oss.str();
 }
Beispiel #12
0
int isPentagonal(int p)
{
	int i;
	int n = (int)(0.5 + sqrt(0.25 + 6.0*p))/3.0;
	for (i = n-1; i <= n+1; ++i) {
		if (i >= 1 && p == getP(i))
			return TRUE;
	}
	return FALSE;
}
Beispiel #13
0
int main() {
    {
        using T = hana::tuple<int>;
        T t(3);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 3);
        hana::at_c<0>(t) = 2;
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2);
    }
    {
        using T = hana::tuple<std::string, int>;
        T t("high", 5);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "high");
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 5);
        hana::at_c<0>(t) = "four";
        hana::at_c<1>(t) = 4;
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "four");
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 4);
    }
    {
        using T = hana::tuple<double&, std::string, int>;
        double d = 1.5;
        T t(d, "high", 5);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1.5);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high");
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5);
        hana::at_c<0>(t) = 2.5;
        hana::at_c<1>(t) = "four";
        hana::at_c<2>(t) = 4;
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2.5);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "four");
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 4);
        BOOST_HANA_RUNTIME_CHECK(d == 2.5);
    }
    // get on a rvalue tuple
    {
        static_assert(hana::at_c<0>(hana::tuple<float, int, double, long>{0.0f, 1, 2.0, 3L}) == 0, "" );
        static_assert(hana::at_c<1>(hana::tuple<float, int, double, long>{0.0f, 1, 2.0, 3L}) == 1, "" );
        static_assert(hana::at_c<2>(hana::tuple<float, int, double, long>{0.0f, 1, 2.0, 3L}) == 2, "" );
        static_assert(hana::at_c<3>(hana::tuple<float, int, double, long>{0.0f, 1, 2.0, 3L}) == 3, "" );
        static_assert(S().k == 1, "");
        static_assert(hana::at_c<1>(getP()) == 4, "");
    }
    {
        // make sure get<> returns the right types
        struct T { };
        struct U { };
        struct V { };

        hana::tuple<T, U, V> xs{};
        (void)static_cast<T>(hana::at_c<0>(xs));
        (void)static_cast<U>(hana::at_c<1>(xs));
        (void)static_cast<V>(hana::at_c<2>(xs));
    }
}
Beispiel #14
0
peano::applications::faxen::records::RegularGridCell peano::applications::faxen::records::RegularGridCellPacked::convert() const{
   return RegularGridCell(
      getP(),
      getU(),
      getV(),
      getF(),
      getG(),
      getRhs(),
      getRes(),
      getIsInside()
   );
}
Beispiel #15
0
void FopVob::animate(Frame *f)
{
	STACKTRACE;
	// animate the ship, as usual:
	Ship::animate(f);

	// animate the queued shots:
	int i;
	for ( i = 0; i < Nshots; ++i ) {
		Vector2 P;
		P = pos + getP(i);
		data->spriteWeapon->animate(P, sprite_index, f);
	}
}
	string longestPalindrome(string s) {
		string str = init(s);
		vector<int> p = getP(str);
		int index = 0;
		int len = 1;
		for(int i=1;i<p.size();++i){
			if(p[i]>len){
				index = i;
				len = p[i];
			}
		}
		index = (index-len+2)/2-1;
		return s.substr(index,len-1);
	}
Beispiel #17
0
 bool LUDiv<T>::checkDecomp(const BaseMatrix<T>& m, std::ostream* fout) const
 {
     Matrix<T> mm = m;
     if (fout) {
         *fout << "LUDiv:\n";
         *fout << "M = "<<
             (pimpl->istrans?mm.transpose():mm.view())<<std::endl;
         *fout << "L = "<<getL()<<std::endl;
         *fout << "U = "<<getU()<<std::endl;
         *fout << "P = "<<getP()<<std::endl;
         *fout << "  or by interchanges: ";
         for(ptrdiff_t i=0;i<getP().size();i++)
             *fout<<(getP().getValues())[i]<<" ";
     }
     Matrix<T> lu = getP()*getL()*getU();
     RT nm = Norm(lu-(pimpl->istrans ? mm.transpose() : mm.view()));
     nm /= Norm(getL())*Norm(getU());
     if (fout) {
         *fout << "PLU = "<<lu<<std::endl;
         *fout << "Norm(M-PLU)/Norm(PLU) = "<<nm<<std::endl;
     }
     return nm < mm.doCondition()*RT(mm.colsize())*TMV_Epsilon<T>();
 }
Beispiel #18
0
int main(void)
{
	int i, j, k, l;
	int pl, pj, pk;
	int p;
	int D;


	l = 3;
	pl = getP(l);	
	for(;;) {
		for (k = 1; k < l; ++k) {
			pk = getP(pk);
			//p = (pl > pk) ? pl - pk : pk - pl;
			D = abs(pl - pk);
			if (isPentagonal(D)) {
				if (isPentagonal(pl + pk)) {
					printf("%d\n", D);
				}
			}
		}
		++l;
		pl = getP(l);
				
	}

	//stop:
	//printf("pl = %d, pj = %d, pk = %d\n", pl, pj, pk);



	


	return 0;
}
//----------------------------------------------------------------------------------
void FunctionsSingleton::coutAll() const
{
	std::cout << getD() << std::endl;
	std::cout << getF() << std::endl;
	std::cout << getG() << std::endl;
	std::cout << getM() << std::endl;
	std::cout << getN() << std::endl;
	std::cout << getP() << std::endl;
	std::cout << getQ() << std::endl;
	std::cout << getR() << std::endl;
	std::cout << getW() << std::endl;
	
	std::cout << "Alpha: " << mAlpha << std::endl;
	std::cout << "Beta: "  << mBeta  << std::endl;
	std::cout << "Gamma: " << mGamma << std::endl;
}
Beispiel #20
0
//==============================================================================
//                                   CALC UDOT
//==============================================================================
// To be called from tip to base.
// Temps do not need to be initialized.
//
// First pass
// ----------
// Given previously-calculated quantities from the State 
//      P       this body's articulated body inertia
//     Phi      composite body child-to-parent shift matrix
//      H       joint transition matrix; sense is transposed from Jain
//      G       P * H * DI
// and supplied arguments
//      F       body force applied to B
//      f       generalize forces applied to B's mobilities
//    udot_p    known udots (if mobilizer is prescribed)
// calculate 
//      z       articulated body residual force on B
//    zPlus     AB residual force as felt on inboard side of mobilizer
//     eps      f - ~H*z  gen force plus gen equiv of body forces
// For a prescribed mobilizer we have zPlus=z. Otherwise, zPlus = z + G*eps.
//
// This is the first (inward) loop of Algorithm 16.2 on page 323 of Jain's
// 2011 book, modified to include the applied body force and not including
// the auxiliary quantity "nu=DI*eps".
template<int dof, bool noR_FM, bool noX_MB, bool noR_PF> void
RigidBodyNodeSpec<dof, noR_FM, noX_MB, noR_PF>::calcUDotPass1Inward(
    const SBInstanceCache&                  ic,
    const SBTreePositionCache&              pc,
    const SBArticulatedBodyInertiaCache&    abc,
    const SBDynamicsCache&                  dc,
    const Real*                             jointForces,
    const SpatialVec*                       bodyForces,
    const Real*                             allUDot,
    SpatialVec*                             allZ,
    SpatialVec*                             allZPlus,
    Real*                                   allEpsilon) const 
{
    const Vec<dof>&   f     = fromU(jointForces);
    const SpatialVec& F     = bodyForces[nodeNum];
    SpatialVec&       z     = allZ[nodeNum];
    SpatialVec&       zPlus = allZPlus[nodeNum];
    Vec<dof>&         eps   = toU(allEpsilon);

    const bool isPrescribed = isUDotKnown(ic);
    const HType&              H = getH(pc);
    const ArticulatedInertia& P = getP(abc);
    const HType&              G = getG(abc);

    // z = Pa+b - F
    z = getMobilizerCentrifugalForces(dc) - F; // 6 flops

    // z += P H udot_p if prescribed
    if (isPrescribed && !isUDotKnownToBeZero(ic)) {
        const Vec<dof>& udot = fromU(allUDot);
        z += P*(H*udot); // 66+12*dof flops
    }

    // z += sum(Phi(child) * zPlus(child)) for all children
    for (unsigned i=0; i<children.size(); ++i) {
        const PhiMatrix&  phiChild   = children[i]->getPhi(pc);
        const SpatialVec& zPlusChild = allZPlus[children[i]->getNodeNum()];
        z += phiChild * zPlusChild; // 18 flops
    }

    eps  = f - ~H*z; // 12*dof flops

    zPlus = z;
    if (!isPrescribed)
        zPlus += G*eps; // 12*dof flops
}
Beispiel #21
0
void VarproFunction::computeCorrectionAndJacobian( const gsl_matrix *R, 
         const gsl_matrix *perm, gsl_vector *res, gsl_matrix *jac ) {
  computeGammaSr(R, myRorig, myTmpYr, true);                  
  myGam->multInvGammaVector(myTmpYr);
  if (res != NULL) {
    if (myIsGCD) {
      gsl_vector_memcpy(res, getP());
      myStruct->multByGtUnweighted(res, myRorig, myTmpYr, -1, 1);
    } else {
      gsl_vector_set_zero(res);
      myStruct->multByGtUnweighted(res, myRorig, myTmpYr, -1, 1);
    }
    myStruct->multByWInv(res, 1);
  }
  if (jac != NULL) {  
    computeJacobianOfCorrection(myTmpYr, R, perm, jac);
  } 
}
Beispiel #22
0
void memcpy_bug()
{
  S *s;
  double *p = getP(0);

  if (p) {
      int intSptr[sizeof(S*)/sizeof(int)];
      unsigned i = 0;
      for (i = 0; i < sizeof(intSptr)/sizeof(*intSptr); ++i) {
	  intSptr[i] = (int) p[i];
      }
      memcpy(&s, intSptr, sizeof(intSptr));
      (s)->u.f1 = p;
      verify_p((s)->u.f1);      
  } else {
      s = getS();
  }
  verify_p(s->u.f1);
}
Beispiel #23
0
void peano::applications::faxen::records::RegularGridCellPacked::toString (std::ostream& out) const {
   out << "("; 
   out << "P:" << getP();
   out << ",";
   out << "U:" << getU();
   out << ",";
   out << "V:" << getV();
   out << ",";
   out << "F:" << getF();
   out << ",";
   out << "G:" << getG();
   out << ",";
   out << "rhs:" << getRhs();
   out << ",";
   out << "res:" << getRes();
   out << ",";
   out << "isInside:" << getIsInside();
   out <<  ")";
}
bool PluginLoader::loadAll(QString from){
 QDir dir(from);
 QStringList listfile;
  listfile = dir.entryList("*.*");
#ifdef MYDEBUG
 qDebug(from.latin1());
#endif 
 for(int i = 2; i<listfile.size();i++){
#ifdef MYDEBUG
  qDebug("Pillo ficheros");
  qDebug(listfile[i].latin1());
#endif
  QLibrary * lib = new QLibrary(dir.path()+QString("/")+listfile[i]);
  if(lib->load()){ 
    _pluginlist.push_back(lib);
   #ifdef MYDEBUG
    qDebug("Se añadio a la lista de plugins");
   #endif
  }
 }
 
 
 for(int i=0;i<_pluginlist.size();i++){
  getPluginType getP = (getPluginType)_pluginlist[i]->resolve("getMVPlugin");
  if(getP){
   ModelsViewPlugin * modv = NULL;
   modv = getP();
   if(modv){
    _viewerlist.push_back(modv);
    QStringList l = modv->keys();
    for(int j = 0 ; j<l.size();j++)
     if(_keys.findIndex(l[j])==-1) _keys<<l[j];
   }
   #ifdef MYDEBUG
    else    qDebug("En Plugin no se cargo nada");
   #endif
   
  }
 }
 return true;
 
}
void GetComplexP()
{
	int j, fcn;
	double pvalue;
	int votes[NumFunctions];
	//Get the most frequent function, then the P value.
	for(int comp=0; comp<numberOfComplexes; comp++){
		for(j=0; j<NumFunctions; j++){ votes[j]=0; }
		ComplexList[comp].RewindToHead();
		for(j=0; j<ComplexSize[comp]; j++){
			votes[FunctionNum[ComplexList[comp].CurrentPtr->Data]]++;
			ComplexList[comp].Advance();
		}
		
		//get the P value.
		fcn=0;
		ComplexP[comp]=1;
		ComplexPee[comp]=1;
		int en = 0;
		
		for(j=0; j<NumFunctions; j++){
			pvalue = getP(FunctionSize[j],ComplexSize[comp],votes[j]);
			ComplexPee[comp] *= pvalue;
			if(pvalue<ComplexP[comp]){
				fcn = j;
				ComplexP[comp]=pvalue;
			}
			if(votes[j]) en++;
		}
		if(ComplexPee[comp] < 0) ComplexPee[comp] = 0;
		ComplexPee[comp]= pow(ComplexPee[comp], (float)1/en);
		
		
		//set the letter
		ComplexFunction[comp]=fcn;
		MainInComplex[comp] = votes[fcn];
		UnknownInComplex[comp] = votes[NumFunctions-1];
		
		//printf("P value %f for %d %d %d\n",ComplexP[comp],FunctionSize[maxVotes],ComplexSize[comp],votes[maxVotes]);
	}
}
Beispiel #26
0
int main()
{
    {
        typedef std::pair<int, short> P;
        P p(3, 4);
        assert(std::get<0>(p) == 3);
        assert(std::get<1>(p) == 4);
        std::get<0>(p) = 5;
        std::get<1>(p) = 6;
        assert(std::get<0>(p) == 5);
        assert(std::get<1>(p) == 6);
    }

#if TEST_STD_VER > 11
    {
        static_assert(S().k == 1, "");
        static_assert(std::get<1>(getP()) == 4, "");
    }
#endif

}
Beispiel #27
0
//
// Calculate acceleration in internal coordinates, based on the last set
// of forces that were reduced into epsilon (e.g., see above).
// Base to tip: temp allA_GB does not need to be initialized before
// beginning the iteration.
//
template<int dof, bool noR_FM, bool noX_MB, bool noR_PF> void 
RigidBodyNodeSpec<dof, noR_FM, noX_MB, noR_PF>::calcUDotPass2Outward(
    const SBInstanceCache&                  ic,
    const SBTreePositionCache&              pc,
    const SBArticulatedBodyInertiaCache&    abc,
    const SBTreeVelocityCache&              vc,
    const SBDynamicsCache&                  dc,
    const Real*                             allEpsilon,
    SpatialVec*                             allA_GB,
    Real*                                   allUDot,
    Real*                                   allTau) const
{
    const Vec<dof>& eps  = fromU(allEpsilon);
    SpatialVec&     A_GB = allA_GB[nodeNum];
    Vec<dof>&       udot = toU(allUDot);    // pull out this node's udot

    const bool isPrescribed = isUDotKnown(ic);
    const HType&              H   = getH(pc);
    const PhiMatrix&          phi = getPhi(pc);
    const ArticulatedInertia& P   = getP(abc);
    const SpatialVec&         a   = getMobilizerCoriolisAcceleration(vc);
    const Mat<dof,dof>&       DI  = getDI(abc);
    const HType&              G   = getG(abc);

    // Shift parent's acceleration outward (Ground==0). 12 flops
    const SpatialVec& A_GP  = allA_GB[parent->getNodeNum()]; 
    const SpatialVec  APlus = ~phi * A_GP;

    if (isPrescribed) {
        Vec<dof>& tau = updTau(ic,allTau);  // pull out this node's tau
        // This is f - ~H(P*APlus + z); compare Jain 16.17b. Note sign
        // change since our tau is on the LHS while his is on the RHS.
        tau = eps - ~H*(P*APlus); // 66 + 12*dof flops
    } else {
        udot = DI*eps - ~G*APlus; // 2*dof^2 + 11*dof
    }

    A_GB = APlus + H*udot + a;
}
Beispiel #28
0
void VarproFunction::computePhat( gsl_vector* p, const gsl_matrix *R ) {
  try  {
    computeGammaSr(R, myRorig, myTmpYr, true);
  } catch (Exception *e) {
    if (!strncmp(e->getMessage(), "Gamma", 5)) {
      delete e;
      e = new Exception("Gamma matrix is singular. "
                        "Unable to compute the correction.\n");
    }
    throw e;
  }
  myGam->multInvGammaVector(myTmpYr);
  
  gsl_vector_set_zero(p);
  if (myIsGCD) {
    myStruct->multByGtUnweighted(p, myRorig, myTmpYr, 1, 1, false);
  } else {
    myStruct->multByGtUnweighted(p, myRorig, myTmpYr, -1, 1);
    myStruct->multByWInv(p, 2);
    gsl_vector_add(p, getP());
  }
}
int main(int, char**)
{
    {
        typedef std::pair<int, short> P;
        P p(3, static_cast<short>(4));
        assert(std::get<0>(p) == 3);
        assert(std::get<1>(p) == 4);
        std::get<0>(p) = 5;
        std::get<1>(p) = 6;
        assert(std::get<0>(p) == 5);
        assert(std::get<1>(p) == 6);
    }

#if TEST_STD_VER > 11
    {
        static_assert(S().k == 1, "");
        static_assert(std::get<1>(getP()) == 4, "");
    }
#endif


  return 0;
}
void GetClusterP()
{
	int j, fcn;
	double pvalue;
	int votes[NumFunctions];
	//Get the most frequent function, then the P value.
	for(int cluster=0; cluster<numClust; cluster++){
		for(j=0; j<NumFunctions; j++){ votes[j]=0; }
		graph.ClusterList[cluster].RewindToHead();
		for(j=0; j<graph.ClusterSize[cluster]; j++){
			votes[FunctionNum[graph.ClusterList[cluster].CurrentPtr->Data]]++;
			graph.ClusterList[cluster].Advance();
		}
		
		//get the P value.
		fcn=0;
		ClusterP[cluster]=1;
		for(j=0; j<NumFunctions; j++){
			pvalue= getP(FunctionSize[j],graph.ClusterSize[cluster],votes[j]);
			
			if(pvalue<=ClusterP[cluster] && votes[j] > 0){
				fcn = j;
				ClusterP[cluster]=pvalue;
			}
			
		}
		
		
		//set the letter
		ClusterFunction[cluster]=fcn;
		MainInCluster[cluster] = votes[fcn];
		UnknownInCluster[cluster] = votes[0];
		
		//printf("P value %f for %d %d %d\n",ClusterP[cluster],FunctionSize[maxVotes],graph.ClusterSize[cluster],votes[maxVotes]);
	}
}