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;
}
Beispiel #2
0
/* 
**************************************************************
 * Prototype: ZOLTAN_EDGE_LIST_MULTI_FN
 * For every vertex in the ID list, return a list of all its
 * adjacent vertices, and the processes on which they reside.
 * Also include the edge weights if any.
 * For graph methods.  
 **************************************************************
 */
static void get_edge_list(void *data, int sizeGID, int sizeLID,
        int num_obj, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
        int *num_edges, 
        ZOLTAN_ID_PTR nborGID, int *nborProc,
        int wgt_dim, float *ewgts, int *ierr)
{
    UZData *uz = (UZData *) data;
    int i, id, r, c, r2, c2, e;

    ZOLTAN_ID_PTR nextID; 
    int *nextProc;

    if ( (sizeGID != 1) || (sizeLID != 1) ||
         (wgt_dim != 0)){      /* we are not using edge weights */
        *ierr = ZOLTAN_FATAL;
        return;
    }
    
    nextID = nborGID;
    nextProc = nborProc;

    /* printf("querying %d vertices\n", num_obj); */
    for (i=0;  i < num_obj ; ++i) {
        id = globalID[i];
        r = getR(id);
        c = getC(id);

        /* printf(" %d (%d,%d) : ", id, r, c); */
        for (e=0; e<uz->stencil; ++e) {
            r2 = r+neig[e].r;
            c2 = c+neig[e].c;
            
            if (r2>=0 && r2<uz->meshR &&
                c2>=0 && c2<uz->meshC) {
                *nextID++ = gID(r2, c2);
                *nextProc++ = pID(r2/(uz->meshR/uz->procR), c2/(uz->meshC/uz->procC));
                /* printf(" %d (%d, %d) [%d] ", *(nextID-1), r2, c2, *(nextProc-1)); */
            }
            
        }
        if (uz->redgeto && (uz->redgeto[i]>=0)) {
            r2 = getR(uz->redgeto[i]);
            c2 = getC(uz->redgeto[i]);
            
            *nextID++ = gID(r2, c2);
            *nextProc++ = pID(r2/(uz->meshR/uz->procR), c2/(uz->meshC/uz->procC));
            /* printf(" %d (%d, %d) [%d] ", *(nextID-1), r2, c2, *(nextProc-1)); */
        }
        /* printf("\n"); */
        
        *ierr = ZOLTAN_OK;       
    }
}
Beispiel #3
0
static int filledges(int lid, int *adjID, int *adjProc, UZData *uz)
{
    int *nextID = adjID, *ptr;
    int *nextProc = adjProc;
    int gid = gIDfLID(lid);
    int r = getR(gid), r2;
    int c = getC(gid), c2, e, j;

    /* printf(" %d (%d,%d) : ", id, r, c); */
    for (e=0; e<uz->stencil; ++e) {
        r2 = r+neig[e].r;
        c2 = c+neig[e].c;
            
        if (r2>=0 && r2<uz->meshR &&
            c2>=0 && c2<uz->meshC) {
            *nextID++ = gID(r2, c2);
            if (adjProc)
                *nextProc++ = pID(r2/(uz->meshR/uz->procR), c2/(uz->meshC/uz->procC));
                /* printf(" %d (%d, %d) [%d] ", *(nextID-1), r2, c2, *(nextProc-1)); */
            }
            
    }
    if (uz->redgeto && (uz->redgeto[lid]>=0)) {
        for (ptr=adjID; ptr<nextID && *ptr!=uz->redgeto[lid]; ++ptr);
        if (ptr>=nextID) {
            r2 = getR(uz->redgeto[lid]);
            c2 = getC(uz->redgeto[lid]);
            
            *nextID++ = uz->redgeto[lid];
            if (adjProc)
                *nextProc++ = pID(r2/(uz->meshR/uz->procR), c2/(uz->meshC/uz->procC));
            /* printf(" %d (%d, %d) [%d] ", *(nextID-1), r2, c2, *(nextProc-1)); */
        }
    }

    if (xadj) {
        for (j=xadj[lid]; j<xadj[lid+1]; ++j) {
            for (ptr=adjID; ptr<nextID && *ptr!=uz->redgeto[lid]; ++ptr);
            if (ptr>=nextID) {
                *nextID++ = adj[j];
                if (adjProc)
                    *nextProc++ = pIDfGID(adj[j]);
            }
        }
    }

    /* printf("\n"); */
    return nextID-adjID;
}
/*Fills the matrix with the matching pattern then used to compute the LCS*/
void fillMatrixWithValues(int** mat, int **p,char* stringA,char* stringB, int lenA, int lenB){
	int i, j, s, t;

	for(i = 1; i <= lenA; i++) {
		for(j = 1; j <= lenB; j++) {
			//eq. 7
			t = (0 - p[getC(stringA[i - 1])][j]) < 0 ? 1 : 0;
			s = (0 - (mat[i - 1][j]-t*mat[i - 1][p[getC(stringA[i - 1])][j]-1])) < 0 ? 1 : 0;
			if(stringA[i-1]==stringB[j-1])
				cost(i);
			mat[i][j] = mat[i - 1][j] + t*(s ^ 1);
			//
		}
	}
}
interrupt void port1ISR(){
	_disable_interrupts();
	msdelay(20); // delay for 20 ms
	ISRc = getC();
	P1IFG &= ~(ALLROWS); // clears the interrupt flag
	_enable_interrupts();
}
Beispiel #6
0
					template<SizeT TS> inline void match(const char(&mKeyword)[TS])
					{
						for(auto i(0u); i < TS - 1; ++i)
						{
							if(getC() != mKeyword[i]) throwError("Invalid keyword", std::string{"Couldn't match keyword `"} + std::string{mKeyword} + "'");
							++idx;
						}
					}
Beispiel #7
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;
}
Beispiel #8
0
int getc_main (int argc, char ** argv) {	
	int c;
	while((c = getC()) != 1) {
		printf("%c", c + 1);
	}
	
	return 0;
}
Beispiel #9
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;
}
Beispiel #10
0
					inline Str readStr()
					{
						// Skip opening '"'
						++idx;

						// Find end index of the string
						auto end(idx);
						auto sz(0u);
						for(; true; ++end, ++sz)
						{
							// End of the string
							if(getC(end) == '"') break;

							// Skip non-escape sequences
							if(getC(end) != '\\') continue;

							// Skip escape sequences
							++end;
							SSVU_ASSERT(isValidEscapeSequenceChar(getC(end)));
						}

						// Reserve memory for the string (BOTTLENECK)
						Str result;
						result.reserve(sz);

						for(; idx < end; ++idx)
						{
							// Not an escape sequence
							if(!isC('\\')) { result += getC(); continue; }

							// Escape sequence: skip '\'
							++idx;

							// Convert escape sequence
							result += getEscapeSequence(getC());
						}

						// Skip closing '"'
						++idx;

						return result;
					}
Beispiel #11
0
Double_t strangeZ(Double_t *x, Double_t *par) {
  Double_t n0=par[0];  //1.35
  Double_t m=par[1];  //(1.78-1.35)/140
  Double_t z0=par[2]; //antenna position
  Double_t x1=par[3]; // pulser position
  Double_t D=x[0];
  Double_t C=getC(par,D);
  Double_t z1=(D/m)*TMath::CosH(m*(x1+C)/D)-n0/m;
  //  std::cout << D << "\t" << C << "\t" << z1 <<"\n";
  return z1;  
}
Beispiel #12
0
					inline Val parseVal()
					{
						// Check value type
						switch(getC())
						{
							case '{': return parseObj();
							case '[': return parseArr();
							case '"': return parseStr();
							case 't': return parseBlnTrue();
							case 'f': return parseBlnFalse();
							case 'n': return parseNll();
						}

						// Check if value is a number
						if(isNumStart(getC())) return parseNum();

						throwError("Invalid value", std::string{"No match for values beginning with `"} + getC() + "`");

						return Val{Nll{}};
					}
Beispiel #13
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;
}
Beispiel #14
0
int _kill (int argc, char ** argv)
{
	int c = getC();
	printf("%c\n", c);
	if (argc > 1) {
		int pid = atoi(argv[1]);
		if (pid >= 0) {
			kill(2,pid);
		}
	}
	return 0;
}
Beispiel #15
0
int main(void)	{
	int i, len;
	char str[20];

	scanf("%s", str);

	len = strlen(str);

	for (i = 0; i < len; i++)
		printf("..%c.", getC(i));
	printf(".\n");

	for (i = 0; i < len; i++)
		printf(".%c.%c", getC(i), getC(i));
	printf(".\n");

	printf("#");
	for (i = 0; i < len - 1; i++)
		printf(".%c.%c", str[i], i % 3 == 0 ? '#' : '*');
	printf(".%c.%c", str[i], i % 3 == 2 ? '*' : '#');
	printf("\n");

	for (i = 0; i < len; i++)
		printf(".%c.%c", getC(i), getC(i));
	printf(".\n");

	for (i = 0; i < len; i++)
		printf("..%c.", getC(i));
	printf(".\n");

	return 0;
}
Beispiel #16
0
/* 释放本技能相关 ui 资源 */
void SkillItem::releaseUI() {
    CCTextureCache* pTextureCache = CCTextureCache::sharedTextureCache();
    CCSpriteFrameCache* pSpriteFrameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    
    // 获取大文件名
    
    std::string c = getC();
    std::string pvrFile = c + ".pvr.ccz";
    std::string plistFile = c + ".plist";
    
    pTextureCache->removeTextureForKey(pvrFile.c_str());
    pSpriteFrameCache->removeSpriteFramesFromFile(plistFile.c_str());
}
Beispiel #17
0
float ColorSpace::getH()
{
    float h;
    if (getC() == 0.0f)
    {
        return 0.5f;
    }
    if (red == getZ())
    {
        h = ((float)(grn - blue) / getC() + 6.0f);
        while (h > 6.0f)
        {
            h = h - 6.0f;
        }
    } else if (grn == getZ())
    {
        h = (blue - red) / getC() + 2.0f;
    } else {
        h = (red - grn) / getC() + 4.0f;
    }
    return h / 6.0f;
}
Beispiel #18
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;
}
Beispiel #19
0
Double_t strangeRight(Double_t *x, Double_t *par) {
  Double_t n0=par[0];  //1.35
  Double_t m=par[1];  //(1.78-1.35)/140
  Double_t z0=par[2]; //antenna position
  Double_t x1=par[3]; // pulser position
  Double_t z1=par[4]; // pulser position
  Double_t D=x[0];
  Double_t C=getC(par,D);
  
  Double_t val=TMath::CosH(m*(x1+C)/D);
  //  std::cout << D << "\t" << C << "\t" << val <<"\n";
  return val;
}
Beispiel #20
0
Intersection Triangle::intersects(Ray ray) {
    Intersection is(ray, this);

    Vect p = ray.getOrigin();
    Vect d = ray.getDirection();
    Vect v0 = getA();
    Vect v1 = getB();
    Vect v2 = getC();

    Vect e1, e2, h, s, q;
    float a0, f, u, v;

    e1 = v1 - v0;
    e2 = v2 - v0;

    h = d.crossProduct(e2);
    a0 = e1.dotProduct(h);

    if (a0 > -0.00001 && a0 < 0.00001)
        return is;

    f = 1 / a0;
    s = p - v0;
    u = f * (s.dotProduct(h));

    if (u < 0.0 || u > 1.0)
        return is;

    q = s.crossProduct(e1);
    v = f * d.dotProduct(q);

    if (v < 0.0 || u + v > 1.0)
        return is;

    // at this stage we can compute t to find out where
    // the intersection point is on the line
    float t = f * e2.dotProduct(q);

    if (t > 0.00001) { // ray intersection
        is.setIntersectionPoint(t);
        return is;
    }

    else // this means that there is a line intersection
         // but not a ray intersection
         return is;
}
Beispiel #21
0
// Standard getchar
char getchar() {
	char c;
	int sx = getCursorX();
	int sy = getCursorY();
	while ((c = getC()) != '\n') {
		if (c != 0) {
			if (c != 0x0f) {
				if (c != '\r' || getCursorY() > sy || getCursorX() > sx)
					putchar(c);
			} else {
				putTab();
			}
		}
	}
	putchar(c);
	return c;
}
Beispiel #22
0
/* 
 **************************************************************
 * Prototype: ZOLTAN_NUM_EDGES_MULTI_FN
 * Return the number of edges for each vertex in the ID lists.
 * For graph methods.
 **************************************************************
 */
static void get_num_edges_list(void *data, int sizeGID, int sizeLID,
                               int num_obj,
                               ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
                               int *numEdges, int *ierr)
{
    UZData *uz = (UZData *) data;
    int i, id, r, c, r2, c2, edgecnt, e;
    
    if ( (sizeGID != 1) || (sizeLID != 1)){
        *ierr = ZOLTAN_FATAL;
        return;
    }
    
    for (i=0;  i < num_obj ; ++i){
        id = globalID[i];
        r = getR(id);
        c = getC(id);

        if (r==0 || c==0 || r==(uz->meshR-1) || c==(uz->meshC-1)) {
            /* we can probably do much smarter thing bu since
               we're not going to time graph generation time,
               simply run through over edges and see how many edges
               it will have. */
            edgecnt = 0;
            for (e=0; e<uz->stencil; ++e) {
                r2 = r+neig[e].r;
                c2 = c+neig[e].c;
                
                if (r2>=0 && r2<uz->meshR &&
                    c2>=0 && c2<uz->meshC)
                    ++edgecnt;
            }
            numEdges[i] = edgecnt;
        } else /* internal vertices always have all the edges */
            numEdges[i] = uz->stencil;
        if (uz->redgeto && (uz->redgeto[i]>=0))
            ++numEdges[i];        
    }
    
    *ierr = ZOLTAN_OK;
}
Beispiel #23
0
int main()
{
	int n;
	scanf("%d", &n);
	int dp[2][3];
	dp[0][0] = 1;
	dp[0][1] = 0;
	dp[0][2] = 0;
	int cur = 0;
	for (int i = 0; i < n; ++i)
	{
		cur = 1 - cur;
		char c = getC();
		if (c == '0')
		{
			dp[cur][0] = dp[1 - cur][1] + dp[1 - cur][0];
			dp[cur][1] = dp[1 - cur][1] + dp[1 - cur][2];
			dp[cur][2] = 0;
		}
		else if (c == '1')
		{
			dp[cur][0] = 0;
			dp[cur][1] = dp[1 - cur][0] + dp[1 - cur][1];
			dp[cur][2] = dp[1 - cur][1] + dp[1 - cur][2];
		}
		else
		{
			dp[cur][0] = 0;
			dp[cur][1] = dp[1 - cur][0] + dp[1 - cur][1];
			dp[cur][2] = 0;
		}
		dp[cur][0] %= mod;
		dp[cur][1] %= mod;
		dp[cur][2] %= mod;
	}
	printf("%d\n", dp[cur][0] + dp[cur][1]);
	return 0;
}
Beispiel #24
0
int
main (void)
{
  A* p;
  int i;
  int s = 0;

  p = getB();
  for (i = 0; i < 100; i++)
   {
      s += p->AA();
   }

  for (i = 0; i < 100; i++)
   {
      if (i%10 == 0)
        p = getB();
      else
        p = getC();

      s += p->AA();
   }
   printf ("result = %d\n",s);
}
Beispiel #25
0
void control::setC(bool change) {
    if (getC() != change) {
        this->A = change;
        emit this->CChanged(change);
    }
}
Beispiel #26
0
// topdir = 1..nd
// sidedir = -nd..nd
// toplinknum,sidelinknum = 0..nin-1
void
QOP_staples_deriv(QOP_info_t *info, int nout, int nin,
		  QDP_ColorMatrix *deriv[], QDP_ColorMatrix *chain[],
		  QDP_ColorMatrix *in[],
		  int nstaples[], int *topdir[], int *sidedir[],
		  int *toplinknum[], int *sidelinknum[], QLA_Real *coef[])
{
#define NC QDP_get_nc(in[0])
  double dtime = QOP_time();
  double nflops = 0;
  int nd = QDP_ndim();
  QDP_ColorMatrix *ftmps[nin][nd], *t1, *t2, *t3, *t4, *tc, *bt2[nd], *bt3[nd], *ctmps[nd];
  int ctn[nd];
  for(int i=0; i<nin; i++)
    for(int j=0; j<nd; j++)
      ftmps[i][j] = NULL;
  for(int i=0; i<nd; i++) bt2[i] = bt3[i] = ctmps[i] = NULL;
  t1 = QDP_create_M();
  t2 = QDP_create_M();
  t3 = QDP_create_M();
  t4 = QDP_create_M();
  tc = QDP_create_M();

  // process in reverse in case calculated staples used as input for others
  for(int io=nout-1; io>=0; io--) {
    for(int i=0; i<nd; i++) {
      if(ctmps[i]) QDP_discard_M(ctmps[i]);
      ctn[i] = 0;
    }
    QDP_M_eq_M(tc, chain[io], QDP_all);
    for(int s=0; s<nstaples[io]; s++) {
      QLA_Real c = coef[io][s];
      int tn = toplinknum[io][s];
      int sdir = sidedir[io][s];
      //QOP_printf0("io: %i  s: %i  sdir: %i  tn: %i  c: %g\n", io, s, sdir, tn, c);
      if(sdir==0) {
	if(c==1) {
	  QDP_M_peq_M(deriv[tn], tc, QDP_all);
	  nflops += PEQM;
	} else {
	  QDP_M_peq_r_times_M(deriv[tn], &c, tc, QDP_all);
	  nflops += 2*PEQM;
	}
      } else if(sdir>0) {
	int nu = sdir-1;
	int mu = topdir[io][s]-1;
	int sn = sidelinknum[io][s];
	//QOP_printf0("  mu: %i  nu: %i  sn: %i\n", mu, nu, sn);
	QDP_ColorMatrix *Umunu = getU(tn, mu, nu);
	QDP_ColorMatrix *Unumu = getU(sn, nu, mu);
	QDP_M_eq_M_times_M(t1, in[sn], Umunu, QDP_all);
	QDP_M_eq_Ma_times_M(t2, tc, t1, QDP_all);
	QDP_ColorMatrix *tb2 = shiftb(t2, mu);
	QDP_M_eq_M_times_M(t1, tc, Unumu, QDP_all);
	QDP_M_eq_Ma_times_M(t3, in[sn], t1, QDP_all);
	QDP_ColorMatrix *tb3 = shiftb(t3, nu);
	if(c==1) {
	  QDP_M_peq_M_times_Ma(deriv[sn], t1, Umunu, QDP_all);
	  QDP_M_peq_M(deriv[sn], tb2, QDP_all);
	  QDP_M_peq_M(deriv[tn], tb3, QDP_all);
	  nflops += 4*EQMTM+PEQMTM+2*PEQM;
	} else {
	  QDP_M_eq_M_times_Ma(t4, t1, Umunu, QDP_all);
	  QDP_M_peq_r_times_M(deriv[sn], &c, t4, QDP_all);
	  QDP_M_peq_r_times_M(deriv[sn], &c, tb2, QDP_all);
	  QDP_M_peq_r_times_M(deriv[tn], &c, tb3, QDP_all);
	  nflops += 5*EQMTM+6*PEQM;
	}
	QDP_discard_M(tb2);
	QDP_discard_M(tb3);
      } else {
	int nu = -sdir-1;
	int mu = topdir[io][s]-1;
	int sn = sidelinknum[io][s];
	QDP_ColorMatrix *Cmunu = getC(nu);
	QDP_ColorMatrix *Unumu = getU(sn, nu, mu);
	QDP_M_eq_M_times_M(t1, in[sn], Cmunu, QDP_all);
	QDP_M_eq_Ma_times_M(t2, in[tn], t1, QDP_all);
	QDP_ColorMatrix *tb2 = shiftb(t2, mu);
	QDP_M_eq_M_times_M(t3, in[tn], Unumu, QDP_all);
	if(c==1) {
	  QDP_M_peq_M_times_Ma(deriv[tn], t1, Unumu, QDP_all);
	  QDP_M_peq_M_times_Ma(deriv[sn], t3, Cmunu, QDP_all);
	  QDP_M_peq_M(deriv[sn], tb2, QDP_all);
	  nflops += 3*EQMTM+2*PEQMTM+PEQM;
	} else {
	  QDP_M_eq_M_times_Ma(t4, t1, Unumu, QDP_all);
	  QDP_M_peq_r_times_M(deriv[tn], &c, t4, QDP_all);
	  QDP_M_eq_M_times_Ma(t4, t3, Cmunu, QDP_all);
	  QDP_M_peq_r_times_M(deriv[sn], &c, t4, QDP_all);
	  QDP_M_peq_r_times_M(deriv[sn], &c, tb2, QDP_all);
	  nflops += 5*EQMTM+6*PEQM;
	}
	QDP_discard_M(tb2);
      }
    }
  }

  for(int i=0; i<nin; i++)
    for(int j=0; j<nd; j++)
      if(ftmps[i][j]!=NULL) QDP_destroy_M(ftmps[i][j]);
  for(int i=0; i<nd; i++) {
    if(bt2[i]!=NULL) QDP_destroy_M(bt2[i]);
    if(bt3[i]!=NULL) QDP_destroy_M(bt3[i]);
    if(ctmps[i]!=NULL) QDP_destroy_M(ctmps[i]);
  }
  QDP_destroy_M(t1);
  QDP_destroy_M(t2);
  QDP_destroy_M(t3);
  QDP_destroy_M(t4);
  QDP_destroy_M(tc);
  info->final_sec = QOP_time() - dtime;
  info->final_flop = nflops*QDP_sites_on_node; 
  info->status = QOP_SUCCESS;
#undef NC
}
Beispiel #27
0
static void
load_snap (SNAP *src, STRTAB *stab, SPWAW_SNAPSHOT *dst)
{
	int	i;

	dst->raw.game.cmt.title = STRTAB_getstr (stab, src->cmt.title);
	dst->raw.game.cmt.mapsrc = STRTAB_getstr (stab, src->cmt.mapsrc);

	getB (year); getB (month); getB (day); getB (hour);
	dst->raw.game.battle.location = STRTAB_getstr (stab, src->b.location);
	getB (terrain); getB (weather); getB (visibility); getB (turn); getB (turn_max);
	getB (OOB_p1); getB (OOB_p2); getB (OOB_p3); getB (OOB_p4);
	getB (miss_p1); getB (miss_p2); getB (credit);

	for (i=0; i<SNAP_VHEXCNT; i++) {
		dst->raw.game.battle.vhex[i].x = src->b.vhex[i].x;
		dst->raw.game.battle.vhex[i].y = src->b.vhex[i].y;
		dst->raw.game.battle.vhex[i].value = src->b.vhex[i].value;
		dst->raw.game.battle.vhex[i].owner = src->b.vhex[i].owner;
	}

	getC (campaign); getC (start_year); getC (start_month); getC (end_year); getC (end_month);
	getC (battles); getC (majvics); getC (minvics); getC (battles_max);
	getC (P1BLmen); getC (P1BLart); getC (P1BLsoft); getC (P1BLapc); getC (P1BLafv); getC (P1BLgliders); getC (P1BLair);
	getC (P2BLmen); getC (P2BLart); getC (P2BLsoft); getC (P2BLapc); getC (P2BLafv); getC (P2BLgliders); getC (P2BLair);
	getC (P1TLmen); getC (P1TLart); getC (P1TLsoft); getC (P1TLapc); getC (P1TLafv); getC (P1TLgliders); getC (P1TLair);
	getC (P2TLmen); getC (P2TLart); getC (P2TLsoft); getC (P2TLapc); getC (P2TLafv); getC (P2TLgliders); getC (P2TLair);
	getC (busy); getC (P1score); getC (P2score); getC (P1result); getC (P2result);
}
Beispiel #28
0
/*
 * local function to read an expression
 */
static LVAL _readexpr(tpLspObject pLSP,FILE *f)
{
   int ch,ch1,ch2,i;
   LVAL p;
   char *s;
   double dval;
   long lval;


   spaceat(ch,f);
   if( ch == EOF )
   {
      return NIL;
   }
   if( ch == pLSP->cClose )
   {
      return NIL;
   }

   if( ch == pLSP->cOpen )/* Read a cons node. */
      return readcons(pLSP,f);

   /**** Note: XLISP allows 1E++10 as a symbol. This is dangerous.
         We do not change XLISP (so far), but here I exclude all symbol
         names starting with numeral. */
   if( const_p1(ch) )/* Read a symbol. */
   {
      for( i = 0 ; const_p(ch) ; i++ ){
        if( storech(pLSP,i,ch) )return NIL;
        ch = getC(pLSP,f);
        }
      UNGETC(ch);
      /* Recognize NIL and nil symbols. */
      if( !strcmp(BUFFER,"NIL") || !strcmp(BUFFER,"nil") )
         return NIL;
      p = newsymbol();
      s = StrDup( BUFFER );
      if( null(p) || s == NULL )return NIL;
      setsymbol(p,s);
      return p;
   }
   if( ch == '\"' ){
     ch = GETC(f);
     storech(pLSP,0,0); /* inititalize the buffer */
     if( ch != '\"' )goto SimpleString;
     ch = GETC(f);
     if( ch != '\"' ){
       UNGETC(ch);
       ch = '\"';/* ch should hold the first character of the string that is " now */
       goto SimpleString;
       }
     ch = GETC(f);     
     /* multi line string */
     for( i = 0 ; ch != EOF ; i++ ){
       if( ch == '\"' ){
         ch1 = GETC(f);
         ch2 = GETC(f);
         if( ch1 == '\"' && ch2 == '\"' )break;
         UNGETC(ch2);
         UNGETC(ch1);
         }
       if( ch == '\\' ){
         ch = GETC(f);
         s = escapers;
         while( *s ){
           if( *s++ == ch ){
             ch = *s;
             break;
             }
           if( *s )s++;
           }
         }
       if( storech(pLSP,i,ch) )return NIL;
       ch = GETC(f);
       }
     p = newstring();
     s = StrDup( BUFFER );
     if( null(p) || s == NULL )return NIL;
     setstring(p,s);
     return p;
     }

   if( ch == '\"' ){/* Read a string. */
     ch = GETC(f);/* Eat the " character. */
SimpleString:
     for( i = 0 ; ch != '\"' && ch != EOF ; i++ ){
       if( ch == '\\' ){
         ch = GETC(f);
         s = escapers;
         while( *s ){
           if( *s++ == ch ){
             ch = *s;
             break;
             }
           if( *s )s++;
           }
         }
       if( ch == '\n' )return NIL;
       if( storech(pLSP,i,ch) )return NIL;
       ch = GETC(f);
       }
      p = newstring();
      s = StrDup( BUFFER );
      if( null(p) || s == NULL )
      {
         return NIL;
      }
      setstring(p,s);
      return p;
   }
   if( numeral1(ch) )
   {
      for( i = 0 ; isinset(ch,"0123456789+-eE.") ; i++ )
      {
         if( storech(pLSP,i,ch) )return NIL;
         ch = getC(pLSP,f);
      }
      UNGETC(ch);
      cnumeric(BUFFER,&i,&dval,&lval);
      switch( i )
      {
      case 0:
         return NIL;
      case 1:
         /* A float number is coming. */
         p = newfloat();
         if( null(p) )
         {
            return NIL;
         }
         setfloat(p,dval);
         return p;
      case 2:
         /* An integer is coming. */
         p = newint();
         if( null(p) )
         {
            return NIL;
         }
         setint(p,lval);
         return p;
      default:
         return NIL;
      }
   }
   return NIL;
}
Beispiel #29
0
void
DLVertex :: Print ( std::ostream& o ) const
{
	o << "[d(" << getDepth(true) << "/" << getDepth(false)
	  << "),s(" << getSize(true) << "/" << getSize(false)
	  << "),b(" << getBranch(true) << "/" << getBranch(false)
	  << "),g(" << getGener(true) << "/" << getGener(false)
	  << "),f(" << getFreq(true) << "/" << getFreq(false) << ")] ";
	o << getTagName();

	switch ( Type() )
	{
	case dtAnd:		// nothing to do (except for printing operands)
	case dtSplitConcept:
		break;

	case dtTop:		// nothing to do
	case dtNN:
		return;

	case dtDataExpr:
		o << ' ' << *static_cast<const TDataEntry*>(getConcept())->getFacet();
		return;

	case dtDataValue:	// named entry -- just like concept names
	case dtDataType:

	case dtPConcept:
	case dtNConcept:
	case dtPSingleton:
	case dtNSingleton:
		o << '(' << getConcept()->getName() << ") " << (isNNameTag(Type()) ? "=" : "[=") << ' ' << getC();
		return;

	case dtLE:
		o << ' ' << getNumberLE() << ' ' << getRole()->getName() << ' ' << getC();
		return;

	case dtForall:
		o << ' ' << getRole()->getName() << '{' << getState() << '}' << ' ' << getC();
		return;

	case dtIrr:
		o << ' ' << getRole()->getName();
		return;

	case dtProj:
		o << ' ' << getRole()->getName() << ", " << getC() << " => " << getProjRole()->getName();
		return;

	case dtChoose:
		o << ' ' << getC();
		return;

	default:
		std::cerr << "Error printing vertex of type " << getTagName() << "(" << Type() << ")";
		fpp_unreachable();
	}

	// print operands of the concept constructor
	for ( const_iterator q = begin(); q != end(); ++q )
		o << ' ' << *q;
}
void Target::process(cv::Mat drawing) {
	//std::cout<<"Drawing "<<point_a.getCenter()<<std::endl;
	cv::Scalar red = cv::Scalar(0, 0, 255);
	cv::Scalar green = cv::Scalar(0, 255, 0);
	cv::line(drawing, getA().getCenter(), getC().getCenter(), red, 3); //AC, shortest side
	cv::line(drawing, getA().getCenter(), getB().getCenter(), green, 3); //AB, longest side
	//line( drawing, potentialPoints[l].getCenter(), potentialPoints[n].getCenter(), lineColor);

	float x2 = getA().getCenter().x;
	float y2 = getB().getCenter().y;

	cv::line(drawing, getA().getCenter(), cv::Point2f(x2, y2), cv::Scalar(255, 0, 0), 3);

	float yawx = getA().getCenter().x - getB().getCenter().x;
	float yawy = getA().getCenter().y - getB().getCenter().y;

	float yawrad = atan2(yawy, yawx) + (M_PI / 2);
	float yawdeg = yawrad * 180 / M_PI;

	float centerx = (getA().getCenter().x + getB().getCenter().x) / 2;
	float centery = (getA().getCenter().y + getB().getCenter().y) / 2;

	float imageCenterX = drawing.cols / 2;
	float imageCenterY = drawing.rows / 2;

	float dx = centerx - imageCenterX;
	float dy = centery - imageCenterY;

	float bearingRad = atan2(dy, dx) + (M_PI / 2);
	float bearingDeg = bearingRad * 180 / M_PI;

	//float relativebearingrad = bearingRad - yawrad;
	//float relativebearingdeg = relativebearingrad * 180 / M_PI;



/*
	float dx = abs(centerx - imageCenterX);
	float dy = abs(centery - imageCenterY);

	float bearingRad = atan(dy / dx);
	float bearingDeg = bearingRad * 180 / M_PI;

	if (centerx > imageCenterX) {
		//Center is to the left
		if (centery > imageCenterY) {
			//Center is to bottom
			bearingRad += ((3 * M_PI) / 2);
			bearingDeg += 270;
		} else if (centery < imageCenterY) {
			//Center is to the top
			bearingRad = ((3 * M_PI) / 2) - bearingRad;
			bearingDeg = 270 - bearingDeg;
		}
	} else if (centerx < imageCenterX) {
		//Center is to the right
		if (centery > imageCenterY) {
			//Center is to bottom
			bearingRad = (M_PI / 2) - bearingRad;
			bearingDeg = 90 - bearingDeg;
		} else if (centery < imageCenterY) {
			//Center is to the top
			bearingRad += M_PI / 2;
			bearingDeg += 90;
		}
	}*/

	float pitchMultiplier = cos(bearingRad);
	float rollMultiplier = sin(bearingRad);

	/* Simple proportional roll/pitch controller */

	//AB is 24cm on actual target
	float abDistance = sqrt( pow(yawx, 2) + pow(yawy, 2) );
	float pixelSize = 240 / abDistance;

	//max = 1900, normal = 1500, min = 1100
	int normalRC = 1500;
	int maxRC = 1900;
	int minRC = 1100;

	float gain = 0.5;
	float error = sqrt( pow( (dx * pixelSize), 2) + pow( (dy * pixelSize), 2) );
	float output = gain * error;

	int pitchRC = (int) (pitchMultiplier * output) + normalRC;
	int rollRC = (int) (rollMultiplier * output) + normalRC;

	if (pitchRC > maxRC) {
		pitchRC = maxRC;
	} else if (pitchRC < minRC) {
		pitchRC = minRC;
	}

	if (rollRC > maxRC) {
		rollRC = maxRC;
	} else if (rollRC < minRC) {
		rollRC = minRC;
	}

	/* Simple proportional yaw controller */
	float yawGain = 2.2;
	int yawRC = (int) (yawdeg * yawGain) + normalRC;

	if (yawRC > maxRC) {
		yawRC = maxRC;
	} else if (yawRC < minRC) {
		yawRC = minRC;
	}


	printf ("pitch: %f, roll: %f, yaw:%f, abs bearing: %f\n", pitchMultiplier, rollMultiplier, yawdeg, bearingDeg );
	printf ("distance: %f, pitchrc: %d, rollrc: %d, yawrc: %d\n", error, pitchRC, rollRC, yawRC );

	cv::circle(drawing, cv::Point2f(centerx, centery), 5, cv::Scalar(255, 0, 0), 3);
	cv::circle(drawing, cv::Point2f(imageCenterX, imageCenterY), 5, cv::Scalar(255, 0, 0), 3);

	std::stringstream ys, ps, rs, bs;
	ys << "yaw: " << yawdeg;
	ps << "pitch: " << pitchMultiplier;
	rs << "roll: " << rollMultiplier;
	bs << "bear: " << bearingDeg;

	cv::putText(drawing, ys.str(), cv::Point(20,50), cv::FONT_HERSHEY_SIMPLEX, 2, cv::Scalar(0,255,255),2);
	cv::putText(drawing, ps.str(), cv::Point(20,150), cv::FONT_HERSHEY_SIMPLEX, 2, cv::Scalar(0,255,255),2);
	cv::putText(drawing, rs.str(), cv::Point(20,250), cv::FONT_HERSHEY_SIMPLEX, 2, cv::Scalar(0,255,255),2);
	cv::putText(drawing, bs.str(), cv::Point(20,350), cv::FONT_HERSHEY_SIMPLEX, 2, cv::Scalar(0,255,255),2);


}