Esempio n. 1
0
  void DiracStaggered::DslashXpay(cudaColorSpinorField &out, const cudaColorSpinorField &in, 
				  const QudaParity parity, const cudaColorSpinorField &x,
				  const double &k) const
  {    
    checkParitySpinor(in, out);

    initSpinorConstants(in, profile);
    setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda
    staggeredDslashCuda(&out, fatGauge, longGauge, &in, parity, dagger, &x, k, commDim, profile);
  
    flops += 1158ll*in.Volume();
  }
Esempio n. 2
0
void DiracWilson::Dslash(cudaColorSpinorField &out, const cudaColorSpinorField &in, 
			 const QudaParity parity) const
{
  initSpinorConstants(in);
  checkParitySpinor(in, out);
  checkSpinorAlias(in, out);

  setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda

  wilsonDslashCuda(&out, gauge, &in, parity, dagger, 0, 0.0, commDim);

  flops += 1320ll*in.Volume();
}
Esempio n. 3
0
  void DiracWilson::DslashXpay(cudaColorSpinorField &out, const cudaColorSpinorField &in, 
			       const QudaParity parity, const cudaColorSpinorField &x,
			       const double &k) const
  {
    initSpinorConstants(in, profile);
    checkParitySpinor(in, out);
    checkSpinorAlias(in, out);

    setFace(face1,face2); // FIXME: temporary hack maintain C linkage for dslashCuda

    wilsonDslashCuda(&out, gauge, &in, parity, dagger, &x, k, commDim, profile);

    flops += 1368ll*in.Volume();
  }
Esempio n. 4
0
Globals::Globals(std::string dmode, std::string shading, float* background, std::string face, std::string order, bool dsided, bool local, bool enabled, float* ambient) {
	this->dmode = setDmode(dmode);
	this->shading = setShading(shading);
	this->face = setFace(face);
	this->order = setOrder(order);
	this->dsided = dsided;
	this->local = local;
	this->enabled = enabled;

	for (int i=0 ; i<4 ; i++) {
		this->background[i] = background[i];
		this->ambient[i] = ambient[i];
	}
}
Esempio n. 5
0
void DiracStaggered::Dslash(cudaColorSpinorField &out, const cudaColorSpinorField &in, 
			 const QudaParity parity) const
{
  if (!initDslash) {
    initDslashConstants(*fatGauge, in.Stride());
    initStaggeredConstants(*fatGauge, *longGauge);
  }
  checkParitySpinor(in, out);

  setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda
  staggeredDslashCuda(&out, *fatGauge, *longGauge, &in, parity, dagger, 0, 0, commDim);
  
  flops += 1146*in.Volume();
}
Esempio n. 6
0
// apply hopping term, then clover: (A_ee^-1 D_eo) or (A_oo^-1 D_oe),
// and likewise for dagger: (A_ee^-1 D^dagger_eo) or (A_oo^-1 D^dagger_oe)
// NOTE - this isn't Dslash dagger since order should be reversed!
void DiracCloverPC::Dslash(cudaColorSpinorField &out, const cudaColorSpinorField &in, 
			   const QudaParity parity) const
{
  if (!initDslash) initDslashConstants(gauge, in.stride);
  if (!initClover) initCloverConstants(clover.even.stride);
  checkParitySpinor(in, out, cloverInv);
  checkSpinorAlias(in, out);

  setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda

  cloverDslashCuda(&out, gauge, cloverInv, &in, parity, dagger, 0, 0.0, 
		   blockDslash, blockDslashFace);

  flops += (1320+504)*in.volume;
}
Esempio n. 7
0
  // apply hopping term, then clover: (A_ee^-1 D_eo) or (A_oo^-1 D_oe),
  // and likewise for dagger: (A_ee^-1 D^dagger_eo) or (A_oo^-1 D^dagger_oe)
  // NOTE - this isn't Dslash dagger since order should be reversed!
  void DiracCloverPC::Dslash(cudaColorSpinorField &out, const cudaColorSpinorField &in, 
			     const QudaParity parity) const
  {
    initSpinorConstants(in);
    checkParitySpinor(in, out);
    checkSpinorAlias(in, out);

    setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda

    FullClover cs;
    cs.even = clover.evenInv; cs.odd = clover.oddInv; cs.evenNorm = clover.evenInvNorm; cs.oddNorm = clover.oddInvNorm;
    cs.precision = clover.precision; cs.bytes = clover.bytes, cs.norm_bytes = clover.norm_bytes;
    cloverDslashCuda(&out, gauge, cs, &in, parity, dagger, 0, 0.0, commDim);

    flops += (1320+504)*in.Volume();
  }
Esempio n. 8
0
//!NEW : added setFace(),   domainWallDslashCuda() got an extra argument  
void DiracDomainWall::Dslash(cudaColorSpinorField &out, const cudaColorSpinorField &in, 
			     const QudaParity parity) const
{
  if ( in.Ndim() != 5 || out.Ndim() != 5) errorQuda("Wrong number of dimensions\n");
  checkParitySpinor(in, out);
  checkSpinorAlias(in, out);
 
  initSpinorConstants(in);
  setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda  
  domainWallDslashCuda(&out, gauge, &in, parity, dagger, 0, mass, 0, commDim);   

  long long Ls = in.X(4);
  long long bulk = (Ls-2)*(in.Volume()/Ls);
  long long wall = 2*in.Volume()/Ls;
  flops += 1320LL*(long long)in.Volume() + 96LL*bulk + 120LL*wall;
}
Esempio n. 9
0
// xpay version of the above
void DiracCloverPC::DslashXpay(cudaColorSpinorField &out, const cudaColorSpinorField &in, 
			       const QudaParity parity, const cudaColorSpinorField &x,
			       const double &k) const
{
  if (!initDslash) initDslashConstants(gauge, in.Stride());
  if (!initClover) initCloverConstants(clover.Stride());
  checkParitySpinor(in, out, clover);
  checkSpinorAlias(in, out);

  setFace(face); // FIXME: temporary hack maintain C linkage for dslashCuda

  FullClover cs;
  cs.even = clover.evenInv; cs.odd = clover.oddInv; cs.evenNorm = clover.evenInvNorm; cs.oddNorm = clover.oddInvNorm;
  cs.precision = clover.precision; cs.bytes = clover.bytes, cs.norm_bytes = clover.norm_bytes;
  cloverDslashCuda(&out, gauge, cs, &in, parity, dagger, &x, k, commDim);

  flops += (1320+504+48)*in.Volume();
}
Esempio n. 10
0
Octahedron::Octahedron(uint8_t style) {
    setStyle(style);
    setVerticesPerFace(3);

    //  used factor 1.7*1024
    setInitialVertice(0, 0, 0, 1741);
    setInitialVertice(1, 1741, 0, 0);
    setInitialVertice(2, 0, 1741, 0);
    setInitialVertice(3, -1741, 0, 0);
    setInitialVertice(4, 0, -1741, 0);
    setInitialVertice(5, 0, 0, -1741);

    setFace(0, 0, 1, 2);
    setFace(1, 0, 2, 3);
    setFace(2, 0, 3, 4);
    setFace(3, 0, 4, 1);
    setFace(4, 5, 2, 1);
    setFace(5, 5, 3, 2);
    setFace(6, 5, 4, 3);
    setFace(7, 5, 1, 4);
}
Esempio n. 11
0
void Planet::initWithForceSide( int force )
{
	Planet::init();
	m_nForceSide = force;
	
	// 星球
	if(force == kForceSideCat)
	{
		initWithFile("Planet_cat.png");
	}
	else if(force == kForceSideDog)
	{
		initWithFile("Planet_dog.png");
	}
	else if(force == kForceSideThird)
	{
		initWithFile("Planet_third.png");
	}
	else if(force == kForceSideMiddle)
	{
		initWithFile("Planet_middle.png");
	}
	else
	{
		return;
	}

	// 中间的脸
	CCSize planetSize = boundingBox().size;
	if(!m_pFace)
	{
		Face* pFace = Face::createWithForceSide(force);
		setFace(pFace);
		m_pFace->setPosition(ccp(planetSize.width / 2 + 3, planetSize.height / 2 - 3));
		this->addChild(m_pFace);
	}
	else
		m_pFace->initWithForceSide(force);

	
	

	// 右上角的数字
	CCString* pStr = CCString::createWithFormat("%d",  getFightUnitCount());
	if(!m_pFightUnitLabel)
	{
		setFightUnitLabel(CCLabelTTF::create(" ", FONT_00_STARMAP_TRUETYPE, 19));
        int x = planetSize.width - 16;
        int y = planetSize.height - 16;
        // 对于ios再微调一下
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
        x -= 1;
        y -= 2;
#endif
		m_pFightUnitLabel->setPosition(ccp(x, y));
		this->addChild(m_pFightUnitLabel);        
	}

	if(m_nForceSide != kForceSideMiddle)
	{
		ccColor3B ccMyOrange={255, 104, 0};
		m_pFightUnitLabel->setColor(ccMyOrange);
	}
	else
	{	
		ccColor3B ccMyGray={72, 72, 72};
		m_pFightUnitLabel->setColor(ccMyGray);
	}
	m_pFightUnitLabel->setString(pStr->getCString());


	// 每次init之后stopped都会被置为false
	// 主要是因为当把一个middel星设为stop后,被另一方占领需要自动恢复成正常增加
	m_bIncreaseStopped =false;
	// b2Body创建

	// setLevel(0);
	slowDownRestore(0);
	setScale(1);
}
Esempio n. 12
0
  QList<FacePtr> FaceDetector::detect(const MatPtr image) {
    // Make grayscaled version of the image, and equalize the histogram
    // which normalizes the brightness and increases the contrast in the
    // image.
    cv::Mat grayImg;
    cvtColor(*image.get(), grayImg, cv::COLOR_BGR2GRAY);
    equalizeHist(grayImg, grayImg);

    // Detect faces with scale factor 1.1, minimum 3 neighbors and
    // minimum 80x80 face size.
    std::vector<cv::Rect> faces;
    faceCas.detectMultiScale(grayImg, faces, 1.1, 3, 0, cv::Size(80, 80));

    QList<FacePtr> results;
    for (auto it = faces.begin(); it != faces.end(); ++it) {
      const auto &f = *it;
      auto face = FacePtr(new Face);
      face->setFace(f);

      // Detect two eyes for each face with scale factor 1.1, 3
      // min. neighbors and min size of 30x30.
      cv::Mat facePart = grayImg(f);
      std::vector<cv::Rect> eyes;
      eyesCas.detectMultiScale(facePart, eyes, 1.1, 3, 0, cv::Size(30, 30));
      if (eyes.size() >= 2) {
        // Take the two largest.
        auto &eye1 = eyes[0], &eye2 = eyes[1];
        int area1 = eye1.width * eye1.height,
          area2 = eye2.width * eye2.height;
        if (area1 > area2) {
          qSwap<cv::Rect>(eye1, eye2);
          qSwap<int>(area1, area2);
        }
        for (int i = 2; i < eyes.size(); i++) {
          const auto &eye = eyes[i];
          int area = eye.width * eye.height;
          if (area > area1 && area < area2) {
            eye1 = eye;
            area1 = area;
          }
          else if (area > area2 && area < area1) {
            eye2 = eye;
            area2 = area;
          }
          else if (area > area1 && area > area2) {
            eye1 = eye;
            area1 = area;
            qSwap<cv::Rect>(eye1, eye2);
            qSwap<int>(area1, area2);
          }
        }

        // Since we are only looking at the sub-region of the face we
        // need to convert into image coordinates.
        eye1.x += f.x; eye1.y += f.y;
        eye2.x += f.x; eye2.y += f.y;
        face->setEyes(eye1, eye2);
      }

      results << face;
    }
    
    return results;
  }
Esempio n. 13
0
Dodecahedron::Dodecahedron(uint8_t style) {
    setStyle(style);
    setVerticesPerFace(5);

    //  used factor 1.7*1024
    setInitialVertice(0, 1057, 0, 1384);
    setInitialVertice(1, 327, 1004, 1384);
    setInitialVertice(2, -855, 621, 1384);
    setInitialVertice(3, -855, -621, 1384);
    setInitialVertice(4, 327, -1004, 1384);
    setInitialVertice(5, 1709, 0, 327);
    setInitialVertice(6, 529, 1626, 327);
    setInitialVertice(7, -1384, 1004, 327);
    setInitialVertice(8, -1384, -1004, 327);
    setInitialVertice(9, 529, -1626, 327);
    setInitialVertice(10, 1384, 1004, -327);
    setInitialVertice(11, -529, 1626, -327);
    setInitialVertice(12, -1709, 0, -327);
    setInitialVertice(13, -529, -1626, -327);
    setInitialVertice(14, 1384, -1004, -327);
    setInitialVertice(15, 855, 621, -1384);
    setInitialVertice(16, -327, 1004, -1384);
    setInitialVertice(17, -1057, 0, -1384);
    setInitialVertice(18, -327, -1004, -1384);
    setInitialVertice(19, 855, -621, -1384);

    setFace(0,   0,  1,  2,  3,  4);
    setFace(1,   0,  5, 10,  6,  1);
    setFace(2,   1,  6, 11,  7,  2);
    setFace(3,   2,  7, 12,  8,  3);
    setFace(4,   3,  8, 13,  9,  4);
    setFace(5,   4,  9, 14,  5,  0);
    setFace(6,  15, 16, 11,  6, 10);
    setFace(7,  16, 17, 12,  7, 11);
    setFace(8,  17, 18, 13,  8, 12);
    setFace(9,  18, 19, 14,  9, 13);
    setFace(10, 19, 15, 10,  5, 14);
    setFace(11, 15, 19, 18, 17, 16);
}
Esempio n. 14
0
Isocahedron::Isocahedron(uint8_t style) {
    setStyle(style);
    setVerticesPerFace(3);

    //  used factor 1.7*1024
    setInitialVertice(0, 0, 0, 1741);
    setInitialVertice(1, 1556, 0, 778);
    setInitialVertice(2, 480, 1481, 778);
    setInitialVertice(3, -1260, 916, 778);
    setInitialVertice(4, -1260, -916, 778);
    setInitialVertice(5, 480, -1481, 778);
    setInitialVertice(6, 1260, 916, -778);
    setInitialVertice(7, -480, 1481, -778);
    setInitialVertice(8, -1556, 0, -778);
    setInitialVertice(9, -480, -1481, -778);
    setInitialVertice(10, 1260, -916, -778);
    setInitialVertice(11, 0, 0, -1741);

    setFace(0,  0,  1,  2);
    setFace(1,  0,  2,  3);
    setFace(2,  0,  3,  4);
    setFace(3,  0,  4,  5);
    setFace(4,  0,  5,  1);
    setFace(5, 11,  7,  6);
    setFace(6, 11,  8,  7);
    setFace(7, 11,  9,  8);
    setFace(8, 11, 10,  9);
    setFace(9, 11,  6, 10);
    setFace(10, 1,  6,  2);
    setFace(11, 2,  7,  3);
    setFace(12, 3,  8,  4);
    setFace(13, 4,  9,  5);
    setFace(14, 5, 10,  1);
    setFace(15, 6,  7,  2);
    setFace(16, 7,  8,  3);
    setFace(17, 8,  9,  4);
    setFace(18, 9, 10,  5);
    setFace(19, 10, 6,  1);
}