コード例 #1
0
ファイル: spline.C プロジェクト: HerculesCE/ParaView
void Tri::genFile (Curve *cur, double *x, double *y){
  register int i;
  Geometry *g;
  Point    p1, p2, a;
  double   *z, *w, *eta, xoff, yoff;
  int      fac;

  fac = cur->face;

  p1.x = vert[vnum(fac,0)].x;  p1.y = vert[vnum(fac,0)].y;
  p2.x = vert[vnum(fac,1)].x;  p2.y = vert[vnum(fac,1)].y;

  getzw(qa,&z,&w,'a');

  eta    = dvector (0, qa);
  if ((g = lookupGeom (cur->info.file.name)) == (Geometry *) NULL)
       g = loadGeom   (cur->info.file.name);


  /* If the current edge has an offset, apply it now */
  xoff = cur->info.file.xoffset;
  yoff = cur->info.file.yoffset;
  if (xoff != 0.0 || yoff != 0.0) {
    dsadd (g->npts, xoff, g->x, 1, g->x, 1);
    dsadd (g->npts, yoff, g->y, 1, g->y, 1);
    if (option("verbose") > 1)
      printf ("shifting current geometry by (%g,%g)\n", xoff, yoff);
  }

  /* get the end points which are assumed to lie on the curve */
  /* set up search direction in normal to element point -- This
     assumes that vertices already lie on spline */

  a.x      = p1.x  - (p2.y - p1.y);
  a.y      = p1.y  + (p2.x - p1.x);
  eta[0]   = searchGeom (a, p1, g);
  a.x      = p2.x  - (p2.y - p1.y);
  a.y      = p2.y  + (p2.x - p1.x);
  eta[qa-1] = searchGeom (a, p2, g);

  /* Now generate the points where we'll evaluate the geometry */

  for (i = 1; i < qa-1; i++)
    eta [i] = eta[0] + 0.5 * (eta[qa-1] - eta[0]) * (z[i] + 1.);

  for (i = 0; i < qa; i++) {
    x[i] = splint (g->npts, eta[i], g->arclen, g->x, g->sx);
    y[i] = splint (g->npts, eta[i], g->arclen, g->y, g->sy);
  }

  g->pos = 0;     /* reset the geometry */
  if (xoff != 0.)
    dvsub (g->npts, g->x, 1, &xoff, 0, g->x, 1);
  if (yoff != 0.)
    dvsub (g->npts, g->y, 1, &yoff, 0, g->y, 1);

  free (eta);    /* free the workspace */

  return;
}
コード例 #2
0
ファイル: cdbc.c プロジェクト: jpmens/cdbc
int cdbc_view_walk(CDBC *cd, int (*func)(CDBC *, json_t *obj, void *userdata), void *userdata, char *ddoc, char *view, char *arg, ...)
{
    va_list ap;
    char *s;
    str uri;
    int rc;

    if (!cd || !cd->dbname)
        return (CDBC_ERROR);

    dsinit(&uri);

    dscat(&uri, cd->dbname);
    dscat(&uri, "/_design/");
    dscat(&uri, ddoc);
    dscat(&uri, "/_view/");
    dscat(&uri, view);


    if (arg && *arg) {
        dsadd(&uri, '?');
        dscat(&uri, arg);

        va_start(ap, arg);
        while ((s = va_arg(ap, char *)) != NULL) {
            dsadd(&uri, '&');
            dscat(&uri, s);
        }
        va_end(ap);
    }
コード例 #3
0
// The core Mandelbrot calculation function in double precision
inline int CalcMandelbrotDS(const dfloat xPos, const dfloat yPos, 
							const dfloat xJParam, const dfloat yJParam, const int crunch, const bool isJulia)
{
    dfloat x, y, xx, yy, sum;
    int i = crunch;

	dfloat xC, yC ;
	if(isJulia) {
		dseq(xC, xJParam) ;     // xC0 = xJParam ;
		dseq(yC, yJParam) ;     // yC0 = yJParam ;
		dseq(y, yPos);      // y = yPos;
		dseq(x, xPos);      // x = xPos;
		dsmul(yy, y, y);    // yy = y * y;
		dsmul(xx, x, x);	// xx = x * x;
		dsadd(sum, xx, yy); // sum = xx + yy;
	}
	else {
		dseq(xC, xPos) ;     // xC = xPos ;
		dseq(yC, yPos) ;     // yC = yPos ;
		dsdeq(y, 0.0) ;	// y = 0 ;
		dsdeq(x, 0.0) ;	// x = 0 ;
		dsdeq(yy, 0.0) ;   // yy = 0 ;
		dsdeq(xx, 0.0) ;   // xx = 0 ;
		dsdeq(sum, 0.0) ;   // sum = 0 ;
	}
    while (--i && (sum[0] < 4.0f)) {
        dsmul(y, x, y);     // y = x * y * 2.0f + yC ;
        dsadd(y, y, y);
        dsadd(y, y, yC);

        dssub(x, xx, yy);   //  x = xx - yy + xC ;
        dsadd(x, x, xC);

        dsmul(yy, y, y);    // yy = y * y;
        dsmul(xx, x, x);    // xx = x * x;
        dsadd(sum, xx, yy); // sum = xx + yy;
    }
    return i;
} // CalcMandelbrotDS
コード例 #4
0
ファイル: cdbc.c プロジェクト: jpmens/cdbc
int cdbc_get(CDBC *cd, char *docid)
{
    str uri;
    int rc;

    if (!cd)
        return CDBC_ERROR;

    if (!cd->dbname)
        return CDBC_NODBNAME;

    dsinit(&uri);

    dscat(&uri, cd->dbname);
    dsadd(&uri, '/');
    dscat(&uri, docid);

    rc = cdbc_request(cd, (char *)dsstring(&uri));
    dsfree(&uri);
    return (rc);

}
コード例 #5
0
/**
 * Addition by assignment
 */
inline HALMD_GPU_ENABLED dsfloat& operator+=(dsfloat& v, dsfloat const& w)
{
    dsadd(v.hi, v.lo, v.hi, v.lo, w.hi, w.lo);
    return v;
}