Ejemplo n.º 1
0
  void 
  EinsplineSetLocal::evaluate (const ParticleSet& P, int iat, 
			       ValueVector_t& psi)
  {
    PosType r (P.R[iat]);
    PosType ru(PrimLattice.toUnit(P.R[iat]));
    ru[0] -= std::floor (ru[0]);
    ru[1] -= std::floor (ru[1]);
    ru[2] -= std::floor (ru[2]);
    for(int j=0; j<OrbitalSetSize; j++) {
      complex<double> val;
      Orbitals[j]->evaluate(ru, val);

      double phase = -dot(r, Orbitals[j]->kVec);
      double s,c;
      sincos (phase, &s, &c);
      complex<double> e_mikr (c,s);
      val *= e_mikr;
#ifdef QMC_COMPLEX
      psi[j] = val;
#else
      psi[j] = real(val);
#endif
    }
  }
Ejemplo n.º 2
0
    TEST( RocksRecoveryUnitTest, Simple1 ) {
        unittest::TempDir td( _rocksRecordStoreTestDir );
        scoped_ptr<rocksdb::DB> db( getDB( td.path() ) );

        db->Put( rocksdb::WriteOptions(), "a", "b" );

        string value;
        db->Get( rocksdb::ReadOptions(), "a", &value );
        ASSERT_EQUALS( value, "b" );

        {
            RocksRecoveryUnit ru( db.get(), false );
            ru.beginUnitOfWork();
            ru.writeBatch()->Put( "a", "c" );

            value = "x";
            db->Get( rocksdb::ReadOptions(), "a", &value );
            ASSERT_EQUALS( value, "b" );

            ru.endUnitOfWork();
            value = "x";
            db->Get( rocksdb::ReadOptions(), "a", &value );
            ASSERT_EQUALS( value, "c" );
        }

    }
void main()
{
    
	ru(num);
    int *min,*max,*m,*n,t,h;
	max=min=num;
	for(m=num+1;m<num+10;m++)
	{
		if(*m>*max)
		{
			max=m;
		}
	}
	t=num[9];
	num[9]=*max;
	*max=t;
    for(n=num+1;n<num+10;n++)
	{
		if(*n<*min)
		{
			min=n;
		}
	}
	h=num[0];
	num[0]=*min;
	num[0]=h;
	chu (num);
}
Ejemplo n.º 4
0
int score(vector< map<int,float> > & reco){
     int ret = 0;
     for(map<int,int>::iterator k = test_data.begin(); k != test_data.end(); ++k){
          vector< pair<int,float> > ru(reco[k->first].begin(), reco[k->first].end());
          sort(ru.begin(), ru.end(), GreaterSecond<int,float>);
          for(int i = 0; i < ru.size() && i < 10; ++i){
               if(ru[i].first == k->second){
                    ++ret;
                    break;
               }
          }
     }
     return ret;
}
Ejemplo n.º 5
0
int main() {
    char s[100];
    char p[100];

    get(s,0,10);
    get(p,100,10);

    ru(s,p);

//out:

    asm("int3");
    return 0;
}
Ejemplo n.º 6
0
int ru(char *s,char *p) {
    while(*s != '\0') {
	if(*p == '*') {
	    if(ru(s + 1,p)) {
		return 1;
	    }
	} else {
	    if(*s != *p) {
		return 0;
	    }
	    s++;
	}
	p++;
    }
    return (*s) == (*p);
}
Ejemplo n.º 7
0
void
EinsplineSetLocal::evaluate (const ParticleSet& P, int first, int last,
                             ValueMatrix_t& vals, GradMatrix_t& grads,
                             ValueMatrix_t& lapls)
{
    for(int iat=first,i=0; iat<last; iat++,i++) {
        PosType r (P.R[iat]);
        PosType ru(PrimLattice.toUnit(r));
        ru[0] -= std::floor (ru[0]);
        ru[1] -= std::floor (ru[1]);
        ru[2] -= std::floor (ru[2]);
        complex<double> val;
        TinyVector<complex<double>,3> gu;
        Tensor<complex<double>,3> hess;
        complex<double> eye (0.0, 1.0);
        for(int j=0; j<OrbitalSetSize; j++) {
            complex<double> u;
            TinyVector<complex<double>,3> gradu;
            complex<double> laplu;

            Orbitals[j]->evaluate(ru, val, gu, hess);
            u  = val;
            gradu = dot(PrimLattice.G, gu);
            laplu = trace(hess, GGt);

            PosType k = Orbitals[j]->kVec;
            TinyVector<complex<double>,3> ck;
            ck[0]=k[0];
            ck[1]=k[1];
            ck[2]=k[2];
            double s,c;
            double phase = -dot(r, k);
            sincos (phase, &s, &c);
            complex<double> e_mikr (c,s);
#ifdef QMC_COMPLEX
            vals(j,i)  = e_mikr * u;
            grads(i,j) = e_mikr*(-eye*u*ck + gradu);
            lapls(i,j) = e_mikr*(-dot(k,k)*u - 2.0*eye*dot(ck,gradu) + laplu);
#else
            vals(j,i)  = real(e_mikr * u);
            grads(i,j) = real(e_mikr*(-eye*u*ck + gradu));
            lapls(i,j) = real(e_mikr*(-dot(k,k)*u - 2.0*eye*dot(ck,gradu) + laplu));
#endif

        }
    }
}
Ejemplo n.º 8
0
void
EinsplineSetLocal::evaluate (const ParticleSet& P, int iat,
                             ValueVector_t& psi, GradVector_t& dpsi,
                             ValueVector_t& d2psi)
{
    PosType r (P.R[iat]);
    PosType ru(PrimLattice.toUnit(P.R[iat]));
    ru[0] -= std::floor (ru[0]);
    ru[1] -= std::floor (ru[1]);
    ru[2] -= std::floor (ru[2]);
    complex<double> val;
    TinyVector<complex<double>,3> gu;
    Tensor<complex<double>,3> hess;
    complex<double> eye (0.0, 1.0);
    for(int j=0; j<OrbitalSetSize; j++) {
        complex<double> u;
        TinyVector<complex<double>,3> gradu;
        complex<double> laplu;

        Orbitals[j]->evaluate(ru, val, gu, hess);
        u  = val;
        // Compute gradient in cartesian coordinates
        gradu = dot(PrimLattice.G, gu);
        laplu = trace(hess, GGt);

        PosType k = Orbitals[j]->kVec;
        TinyVector<complex<double>,3> ck;
        ck[0]=k[0];
        ck[1]=k[1];
        ck[2]=k[2];
        double s,c;
        double phase = -dot(P.R[iat], k);
        sincos (phase, &s, &c);
        complex<double> e_mikr (c,s);
#ifdef QMC_COMPLEX
        psi[j]   = e_mikr * u;
        dpsi[j]  = e_mikr*(-eye * ck * u + gradu);
        d2psi[j] = e_mikr*(-dot(k,k)*u - 2.0*eye*dot(ck,gradu) + laplu);
#else
        psi[j]   = real(e_mikr * u);
        dpsi[j]  = real(e_mikr*(-eye * ck * u + gradu));
        d2psi[j] = real(e_mikr*(-dot(k,k)*u - 2.0*eye*dot(ck,gradu) + laplu));
#endif

    }
}
Ejemplo n.º 9
0
void XHScrollBar::OnMouseDown(XPoint &pt,int iPos)
{
	if(iPos) return;
	if(m_nRange<=0) return;
	XRect r;
	GetClientRect(r);
	XRect ru(0,0,r.bottom,r.bottom);
	XRect rd(r.right-r.bottom,0,r.right,r.bottom);
	int pp;
	CalcRect(r,pp);
	m_nStatus=XS_NONE;
	if(ru.PtInRect(pt))
		m_nStatus=XS_UPLINE;
	else if(rd.PtInRect(pt))
		m_nStatus=XS_DOWNLINE;
	else if(pt.x<r.left)
	{
		m_nStatus=XS_UPPAGE;
		m_nDownPos=(pt.x-((r.left+r.right)>>1))*1000/pp+m_nPos;
	}
Ejemplo n.º 10
0
void QDCDDActor::sl_onAlgorithmTaskFinished() {
    QList<SharedAnnotationData> res;
    QMapIterator<RemoteBLASTTask*, int> iter(offsetMap);
    while (iter.hasNext()) {
        iter.next();
        RemoteBLASTTask* rqt = iter.key();
        QList<SharedAnnotationData> annotations = rqt->getResultedAnnotations();
        //shift by offset
        int offset = offsetMap.value(rqt);
        QMutableListIterator<SharedAnnotationData> annIter(annotations);
        while (annIter.hasNext()) {
            QVector<U2Region>& location = annIter.next()->location->regions;
            U2Region::shift(offset, location);
        }
        res << annotations;
    }
    offsetMap.clear();

    int minLen = cfg->getParameter(MIN_RES_LEN)->getAttributeValueWithoutScript<int>();
    int maxLen = cfg->getParameter(MAX_RES_LEN)->getAttributeValueWithoutScript<int>();
    const QString& qualVal = cfg->getParameter(QUAL_ATTR)->getAttributeValueWithoutScript<QString>();
    foreach (const SharedAnnotationData& ad, res) {
        const U2Region& reg = ad->location->regions.first();
        if (reg.length < minLen || reg.length > maxLen) {
            continue;
        }
        foreach(const U2Qualifier& qual, ad->qualifiers) {
            if (qual.value.contains(qualVal)) {
                QDResultUnit ru(new QDResultUnitData);
                ru->strand = ad->getStrand();
                ru->quals = ad->qualifiers;
                ru->region = reg;
                ru->owner = units.values().first();
                QDResultGroup* g = new QDResultGroup(QDStrand_Both);
                g->add(ru);
                results.append(g);
                break;
            }
        }
    }
}
Ejemplo n.º 11
0
void octreeSolid::computeBoxAndVolume(octreeSNode *node)
{
	if (node->bEnd)
	{
		// Leaf node
		node->leftDownTight = node->leftDownf;
		node->rightUpTight = node->rightUpf;
		node->volumef = volumeRectf((node->rightUpTight - node->leftDownTight));
	}
	else
	{
		Vec3f ld(MAX, MAX, MAX);
		Vec3f ru(MIN, MIN, MIN);
		node->volumef = 0;
		for (int i = 0; i < 8; i++)
		{
			if (node->children[i])
			{
				computeBoxAndVolume(node->children[i]);
				node->volumef += node->children[i]->volumef;

				for (int j = 0; j < 3; j ++)
				{
					if (ld[j] > node->children[i]->leftDownTight[j])
					{
						ld[j] = node->children[i]->leftDownTight[j];
					}
					if (ru[j] < node->children[i]->rightUpTight[j])
					{
						ru[j] = node->children[i]->rightUpTight[j];
					}
				}
			}
		}

		node->leftDownTight = ld;
		node->rightUpTight = ru;
	}
}
Ejemplo n.º 12
0
void SurfaceObj::computeCenterPoint()
{
	int i;
	Vec3f ld(MAX, MAX, MAX);
	Vec3f ru(MIN, MIN, MIN);
	for (i = 0; i < Point.size(); i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (ld[j] > Point[i][j])
			{
				ld[j] = Point[i][j];
			}
			if (ru[j] < Point[i][j])
			{
				ru[j] = Point[i][j];
			}
		}
	}

	MidPoint = (ld + ru) / 2;
}
/**
  Given a graph, select k random start vertices. Call these 
  k vertices set S. For all vertices v in the graph, find the farthest
  distance between v and any of the vertices in S. Store this is distField.
  
  Note that this implementation is faster than running K separate BFSs in 
  parallel because all k BFSs share a frontier. This means that for each 
  node we must store a bit vector of size K bits, indicating whether or not
  a node has been visited yet by the kth BFS. 
  
  Note that a node v will continue to be added to the frontier as long as its
  source vertex u has a different bit vector than it. This means that v is 
  being visited for the first time by at least one of the K BFSs. Thus we must
  also increment our estimate of its radius since the radius is the FARTHEST
  distance of node v to any of the u source vertices.   

  At the end of the algorithm distField will contain the maximum distance from 
  each node v in the graph to any of the K source nodes. The final radius 
  estimate of the graph is obtained by taking the max radius obtained from all 
  nodes in the graph. Note that this is an estimate because we only ran a BFS 
  from K nodes. If we wanted an exact radius we would have had to run a BFS from
  every single node in the graph.
 **/
void kBFS(graph *g, int *distField) {

  int** visited;
  int** nextVisited;
  int* radii;
  int iter = 0;

  // set up globals
  #pragma omp parallel for schedule(static)
  for (int i = 0; i < g->num_nodes; i++)
    distField[i] = NA;
  radii = distField;

  visited = (int**) malloc(sizeof(int*) * g->num_nodes);
  nextVisited = (int**) malloc(sizeof(int*) * g->num_nodes);

  for (int i = 0; i < g->num_nodes; i++) {
    visited[i] = (int*) malloc(sizeof(int) * NUMWORDS);
    nextVisited[i] = (int*) malloc(sizeof(int) * NUMWORDS);
    memset(visited[i], 0, sizeof(int) * NUMWORDS);
    memset(nextVisited[i], 0, sizeof(int) * NUMWORDS);
  }


  // initialize the frontier with K random nodes
  srand(0);
  int numSources = std::min(K, g->num_nodes);
  int S[numSources]; // the set of source nodes
  for (int i = 0; i < numSources; i++) 
    S[i] = (std::rand()/(float)RAND_MAX) * g->num_nodes;

  VertexSet* frontier = newVertexSet(SPARSE, numSources, g->num_nodes);
  for (int i = 0; i < numSources; i++) {
    addVertex(frontier, S[i]);
  }

  // iterate over values 1 thru k to do initialization
  VertexSet* ks = newVertexSet(SPARSE, numSources, g->num_nodes);
  for (int i = 0; i < numSources; i++) 
    addVertex(ks, i);

  Init i(S, visited, nextVisited, radii);
  vertexMap(ks, i, NORETURN);

  freeVertexSet(ks);

  VertexSet *newFrontier;

  while (frontier->size > 0) {
    iter = iter + 1;
    RadiiUpdate ru(visited, nextVisited, radii, iter);
    newFrontier = edgeMap(g, frontier, ru);

    freeVertexSet(frontier);
    frontier = newFrontier;

    VisitedCopy vc(visited, nextVisited);
    vertexMap(frontier, vc, NORETURN);
  }

  for (int i = 0; i < g->num_nodes; i++) {
    free(visited[i]);
    free(nextVisited[i]);
  }

  freeVertexSet(frontier);
  free(visited);
  free(nextVisited);
}
Ejemplo n.º 14
0
int main()
{
  ru(5);
  rs(5);
  exit(0);
}