Example #1
0
/* SASHA */
static double  min1(double xx1, double xx2, double (*FQ)(double))
{  double x1=xx1,x2=xx2;
   double x3,x4,f1,f2,f3,f4;

   nCall=0; 
   f1=FQ(x1);
   f2=FQ(x2); 
 
   if(f1<f2) { x3=x1;f3=f1;f1=f2;x1=x2;f2=f3;x2=x3;}
   for(;;) 
   {  x3=x2+ (x2-x1);
      f3=FQ(x3); if(nCall>1000) return x2;
      if(f3<f2) { x1=x2;x2=x3; f1=f2;f2=f3;}  else  break;
   }

   for(;;)
   {
      double d1,d2,d3,ff4,xx4;
      if(f1>f3) {f4=f3;x4=x3;f3=f1;x3=x1;x1=x4;f1=f4;}
            
      if(x1==x2|| x2==x3) return x2;
      d1=f1/(x2-x1)/(x3-x1);
      d2=f2/(x1-x2)/(x3-x2);   
      d3=f3/(x1-x3)/(x2-x3); 
      xx4=(d1*(x2+x3)+d2*(x1+x3)+d3*(x1+x2))/(2*(d1+d2+d3));
      ff4=d1*(x2-xx4)*(x3-xx4)+d2*(x1-xx4)*(x3-xx4)+d3*(x1-xx4)*(x2-xx4);
      
           if(fabs(x1-x2)>10*fabs(x2-x3)) x4=(x1+9*x2)/10;
      else if(fabs(x2-x3)>10*fabs(x1-x2)) x4=(x3+9*x2)/10; 
      else x4=xx4;
         
      if(x4==x2) return x2;
      f4=FQ(x4);  if(nCall>1000) return x2;
      if( (x4-x2)*(x1-x2) >0)
      { if(f4<f2) {x3=x2; f3=f2; x2=x4;f2=f4;} else {x1=x4;f1=f4;}}       
      else 
      { if(f4<f2) {x1=x2; f1=f2; x2=x4;f2=f4;} else {x3=x4;f3=f4;}} 
         
      if( (x1==x2|| x2==x3) ||
          (fabs(x1-x3)<0.01)||
          (fabs(f2-ff4) < 0.001*fabs(ff4)) ||
          (fabs(x1-x3)<0.1 &&  fabs(f2-ff4) < 0.01*fabs(ff4))
        ) return x2;
   } 
}
void AA(void*u,Uint8*_,B L){u=u;while(L>0){B M=p&037777,s=p>>12,u=(s%R)[
l],J=(s%U)[b],w=0,a=0,n;A v,q,m,E=(0x2000-(p&017777))/8192e0f;v=q=0;
#define EF_(x) F[w][1638##x+M
#define EF(l,s,ms) ((s*ms+EF_(4)-l]*(1-ms))/2.f+EF_(3)]/2.f)
#define FQ(s) (A)sin((0.12*pow(2,n/12.))*p*s)
#define IZ(v,c) v*=v c?v:0;
#define BF F[w][M]=F[w][M+16384]=q;v+=q;++w
#define IP(n,x,y,z,c) if(n!=46){x}q=EF(y,q,z);c;BF;
#define IS(s,c) if(q c s 0.75f)q=s 0.75f;
#define NQ(x,a,m) n=x-(x>=97?121:65)+a;q=FQ(m);
IP(u,NQ(u,12,1)m=FQ(1.01f);IZ(q,>6e-1)IZ(m,>6e-1)q+=m;q*=5e-1f*(E+1);,12288,
0.2f,;)for(;a<3;++a){char sn=(s%D)[a[r]];q=0;IP(sn,NQ(sn,12,0.25f)IZ(q,<0.3),
#define _Q(_name, _query_type, _type, _result_type) {                \
	.name        = _name,                                            \
	.query_type  = _query_type,                                      \
	.type        = PIPE_DRIVER_QUERY_TYPE_ ## _type,                 \
	.result_type = PIPE_DRIVER_QUERY_RESULT_TYPE_ ## _result_type,   \
	.group_id    = ~(unsigned)0,                                     \
}

#define FQ(_name, _query_type, _type, _result_type) \
	_Q(_name, FD_QUERY_ ## _query_type, _type, _result_type)

#define PQ(_name, _query_type, _type, _result_type) \
	_Q(_name, PIPE_QUERY_ ## _query_type, _type, _result_type)

static const struct pipe_driver_query_info sw_query_list[] = {
	FQ("draw-calls", DRAW_CALLS, UINT64, AVERAGE),
	FQ("batches", BATCH_TOTAL, UINT64, AVERAGE),
	FQ("batches-sysmem", BATCH_SYSMEM, UINT64, AVERAGE),
	FQ("batches-gmem", BATCH_GMEM, UINT64, AVERAGE),
	FQ("batches-nondraw", BATCH_NONDRAW, UINT64, AVERAGE),
	FQ("restores", BATCH_RESTORE, UINT64, AVERAGE),
	PQ("prims-emitted", PRIMITIVES_EMITTED, UINT64, AVERAGE),
	FQ("staging", STAGING_UPLOADS, UINT64, AVERAGE),
	FQ("shadow", SHADOW_UPLOADS, UINT64, AVERAGE),
	FQ("vsregs", VS_REGS, FLOAT, AVERAGE),
	FQ("fsregs", FS_REGS, FLOAT, AVERAGE),
};

static int
fd_get_driver_query_info(struct pipe_screen *pscreen,
		unsigned index, struct pipe_driver_query_info *info)