예제 #1
0
int
o_face(		/* print out a polygon */
	char	*mod,
	char	*typ,
	char	*id,
	FUNARGS	*fa
)
{
	char	entbuf[2048], *linestart;
	register char	*cp;
	register int	i;

	if ((fa->nfargs < 9) | (fa->nfargs % 3))
		return(-1);
	setmat(mod);
	setobj(id);
	cp = linestart = entbuf;
	*cp++ = 'f';
	for (i = 0; i < fa->nfargs; i += 3) {
		*cp++ = ' ';
		if (cp - linestart > 72) {
			*cp++ = '\\'; *cp++ = '\n';
			linestart = cp;
			*cp++ = ' '; *cp++ = ' ';
		}
		getvertid(cp, fa->farg + i);
		while (*cp)
			cp++;
	}
	puts(entbuf);
	return(0);
}
예제 #2
0
int
o_sphere(	/* print out a sphere */
	char	*mod,
	char	*typ,
	char	*id,
	register FUNARGS	*fa
)
{
	char	cent[6];

	if (fa->nfargs != 4)
		return(-1);
	setmat(mod);
	setobj(id);
	printf("sph %s %.12g\n", getvertid(cent, fa->farg),
			typ[0]=='b' ? -fa->farg[3] : fa->farg[3]);
	return(0);
}
예제 #3
0
int
o_instance(	/* convert an instance (or mesh) */
	char	*mod,
	char	*typ,
	char	*id,
	FUNARGS	*fa
)
{
	register int	i;
	register char	*cp;
	char	*start = NULL, *end = NULL;
	/*
	 * We don't really know how to do this, so we just create
	 * a reference to an undefined MGF file and it's the user's
	 * responsibility to create this file and put the appropriate
	 * stuff into it.
	 */
	if (fa->nsargs < 1)
		return(-1);
	setmat(mod);			/* only works if surfaces are void */
	setobj(id);
	for (cp = fa->sarg[0]; *cp; cp++)	/* construct MGF file name */
		if (*cp == '/')
			start = cp+1;
		else if (*cp == '.')
			end = cp;
	if (start == NULL)
		start = fa->sarg[0];
	if (end == NULL || start >= end)
		end = cp;
	fputs("i ", stdout);			/* print include entity */
	for (cp = start; cp < end; cp++)
		putchar(*cp);
	fputs(".mgf", stdout);			/* add MGF suffix */
	for (i = 1; i < fa->nsargs; i++) {	/* add transform */
		putchar(' ');
		fputs(fa->sarg[i], stdout);
	}
	putchar('\n');
	clrverts();			/* vertex id's no longer reliable */
	return(0);
}
예제 #4
0
int
o_cylinder(	/* print out a cylinder */
	char	*mod,
	char	*typ,
	char	*id,
	register FUNARGS	*fa
)
{
	char	v1[6], v2[6];

	if (fa->nfargs != 7)
		return(-1);
	setmat(mod);
	setobj(id);
	getvertid(v1, fa->farg);
	getvertid(v2, fa->farg + 3);
	printf("cyl %s %.12g %s\n", v1,
			typ[0]=='t' ? -fa->farg[6] : fa->farg[6], v2);
	return(0);
}
예제 #5
0
int
o_ring(	/* print out a ring */
	char	*mod,
	char	*typ,
	char	*id,
	register FUNARGS	*fa
)
{
	if (fa->nfargs != 8)
		return(-1);
	setmat(mod);
	setobj(id);
	printf("v cent =\n\tp %.12g %.12g %.12g\n",
			fa->farg[0], fa->farg[1], fa->farg[2]);
	printf("\tn %.12g %.12g %.12g\n",
			fa->farg[3], fa->farg[4], fa->farg[5]);
	if (fa->farg[6] < fa->farg[7])
		printf("ring cent %.12g %.12g\n",
				fa->farg[6], fa->farg[7]);
	else
		printf("ring cent %.12g %.12g\n",
				fa->farg[7], fa->farg[6]);
	return(0);
}
예제 #6
0
int
o_cone(	/* print out a cone */
	char	*mod,
	char	*typ,
	char	*id,
	register FUNARGS	*fa
)
{
	char	v1[6], v2[6];

	if (fa->nfargs != 8)
		return(-1);
	setmat(mod);
	setobj(id);
	getvertid(v1, fa->farg);
	getvertid(v2, fa->farg + 3);
	if (typ[1] == 'u')			/* cup -> inverted cone */
		printf("cone %s %.12g %s %.12g\n",
				v1, -fa->farg[6], v2, -fa->farg[7]);
	else
		printf("cone %s %.12g %s %.12g\n",
				v1, fa->farg[6], v2, fa->farg[7]);
	return(0);
}
예제 #7
0
int main(int argc, char *argv[])
{

   double *a, *b, *c, *aa ;
   unsigned int n ;
   unsigned i, j, k, iInner, jInner, kInner, blockSize ;
   struct timespec ts1, ts2, ts3, ts4, ts5, ts6, ts7 ;

   printf("hello code beginning\n") ;
   n = MATSIZE ; // default settings
   blockSize = BLOCKSIZE ;
   if (argc != 3)
   {
      printf("input matrix size and blocksize\n") ;
      exit(0);
   }
   n = atoi(argv[1]) ;
   blockSize = atoi(argv[2]) ;
   printf("matrix size %d blocksize %d\n", n,blockSize) ;
   if (n%blockSize)
   {
      printf("for this simple example matrix size must be a multiple of the block size.\n  Please re-start \n") ;
      exit(0);
   }
// allocate matrices
   a = (double *)calloc((n+blockSize)*(n+blockSize), sizeof(double)) ;
   b = (double *)calloc((n+blockSize)*(n+blockSize), sizeof(double)) ;
   c = (double *)calloc((n+blockSize)*(n+blockSize), sizeof(double)) ;
   aa = (double *)calloc((n+blockSize)*(n+blockSize), sizeof(double)) ;
   if (aa == NULL) // cheap check only the last allocation checked.
   {
     printf("insufficient memory \n") ;
     exit(0) ;
   }

// fill matrices

   setmat(n, n, a) ;
   setmat(n, n, aa) ;


   srand(1) ; // set random seed (change to go off time stamp to make it better

   fillmat(n,n,b) ;
   fillmat(n,n,c) ;

   current_utc_time(&ts1) ;
// multiply matrices
   abasicmm (n,n,a,b,c) ;

   current_utc_time(&ts2) ;

   setmat(n, n, a) ;

   current_utc_time(&ts3) ;

   abettermm (n,n,a,b,c) ;

   current_utc_time(&ts4) ;

   ablockmm (n, n, aa, b, c, blockSize) ;

   current_utc_time(&ts5) ;

   cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
               n, n, n, 1.0, b, n, c, n, 0.0, a, n);

   current_utc_time(&ts6) ;

   printf("matrix multplies complete \n") ; fflush(stdout) ;

/**/
   checkmatmult(n,n,a,aa) ;

   {
      double t1, t2, t3, t4, tmp ;
      t1 =  ts2.tv_sec-ts1.tv_sec;
      tmp = ts2.tv_nsec-ts1.tv_nsec;
      tmp /= 1.0e+09 ;
      t1 += tmp ;
      printf("ijk ordering basic time %lf\n",t1) ;
      t2 =  ts4.tv_sec-ts3.tv_sec;
      tmp = ts4.tv_nsec-ts3.tv_nsec;
      tmp /= 1.0e+09 ;
      t2 += tmp ;
      printf("ikj ordering bette time %lf\n",t2) ;
      t3 =  ts5.tv_sec-ts4.tv_sec;
      tmp = ts5.tv_nsec-ts4.tv_nsec;
      tmp /= 1.0e+09 ;
      t3 += tmp ;
      printf("ikj blocked time        %lf\n",t3) ;
      t4 =  ts6.tv_sec-ts5.tv_sec;
      tmp = ts6.tv_nsec-ts5.tv_nsec;
      tmp /= 1.0e+09 ;
      t4 += tmp ;
      printf("cblas_dgemm             %lf\n",t4) ;

   }

}