Пример #1
0
static void aten_read_block( PIA *pi, char * buf, int count )

{	int  k, a, b, c, d;

	switch (pi->mode) {

	case 0:	w0(0x48); w2(0xe); w2(6);
		for (k=0;k<count/2;k++) {
			w2(7); w2(6); w2(2);
			a = r1(); w0(0x58); b = r1();
			w2(0); d = r1(); w0(0x48); c = r1();
			buf[2*k] = j44(c,d);
			buf[2*k+1] = j44(a,b);
		}
		w2(0xc);
		break;

	case 1: w0(0x58); w2(0xe); w2(6);
		for (k=0;k<count/2;k++) {
			w2(0x27); w2(0x26); w2(0x22);
			a = r0(); w2(0x20); b = r0();
			buf[2*k] = b; buf[2*k+1] = a;
		}
		w2(0x26); w2(0xc);
		break;
	}
}
Пример #2
0
SEXP kx_r_execute_with_params(SEXP connection, SEXP query, SEXP param)
{
	K result;
	SEXP s;
	kx_connection = INTEGER_VALUE(connection);
	int i, n = length(param);
	K vector = ktn(KF,n); 
	for (i = 0; i < n; i++) {
      kF(vector)[i] = REAL(param)[i];
    }
    

	result = k(kx_connection, (char*) CHARACTER_VALUE(query), vector, (K)0);
	if (0 == result) {
		error("Error: not connected to kdb+ server\n");
	}
	else if (-128 == result->t) {
		char *e = calloc(strlen(result->s) + 1, 1);
		strcpy(e, result->s);
		r0(result);
		error("Error from kdb+: `%s\n", e);
	}
	s = from_any_kobject(result);
	r0(result);
	return s;
}
Пример #3
0
KDB_API K K_DECL testSerial(K a) {
	K k = kpn("000001.SZ", 9);

	//K s = b9(-1, k);
	K s = b9(1, k);

	for (G* i = kG(s); i < kG(s) + s->n; ++i) {
		std::cout << std::setiosflags(std::ios::uppercase) << std::setfill('0') << std::setw(2)
			<< std::hex << static_cast<int>(*i) << ',';
	}
	std::cout << std::endl;

#	if KX_HAS_OKX
	std::cout << "okx = " << okx(s) << std::endl;
#	endif

	if (a->g) {
		r0(s);
		return k;
	}
	else {
		r0(k);
		return s;
	}
}
K recieve_data(I x)
{
    static char buf[BUFFER_SIZE];
    
    read_bytes(sizeof(int), &buf);
    int tnamesize = 0;
    memcpy(&tnamesize, buf, sizeof(int));
   
    read_bytes(tnamesize, &buf);
    buf[tnamesize] = '\0';
    
    K tname = ks(buf);

    read_bytes(sizeof(J), &buf);
    J size = 0;
    memcpy(&size, buf, sizeof(J));

    read_bytes(size, &buf);
    K bytes = ktn(KG, size);
    memcpy(kG(bytes), &buf, (size_t) size);

    K result = k(0, ".u.upd", tname, d9(bytes), (K) 0);
    r0(bytes);

    if (result != 0) {
        r0(result);
    }

    return (K) 0;
}
Пример #5
0
void Dirac_DomainWall_4D::
BprojCore_dag(double* f1,double* fN,const double* f) const{

  // f1 = f5(0), fN = f5(N5_-1)
  for(int c=0; c<NC_; ++c){
    double fup_r = 0.5*(f[r0(c)] +f[r2(c)]);
    double fup_i = 0.5*(f[i0(c)] +f[i2(c)]);
    double fdn_r = 0.5*(f[r1(c)] +f[r3(c)]);
    double fdn_i = 0.5*(f[i1(c)] +f[i3(c)]);

    fN[r0(c)] = fup_r;   fN[i0(c)] = fup_i;
    fN[r1(c)] = fdn_r;   fN[i1(c)] = fdn_i;
    fN[r2(c)] = fup_r;   fN[i2(c)] = fup_i;
    fN[r3(c)] = fdn_r;   fN[i3(c)] = fdn_i;

    fup_r -= f[r2(c)]; //0.5*(f[r0(c)] -f[r2(c)])
    fup_i -= f[i2(c)]; //0.5*(f[i0(c)] -f[i2(c)])
    fdn_r -= f[r3(c)]; //0.5*(f[r1(c)] -f[r3(c)])
    fdn_i -= f[i3(c)]; //0.5*(f[i1(c)] -f[i3(c)])

    f1[r0(c)] = fup_r;   f1[i0(c)] = fup_i;
    f1[r1(c)] = fdn_r;   f1[i1(c)] = fdn_i;
    f1[r2(c)] =-fup_r;   f1[i2(c)] =-fup_i;
    f1[r3(c)] =-fdn_r;   f1[i3(c)] =-fdn_i;
  }
}
Пример #6
0
int main(int argc,char*argv[])
{
    K flip,result,columnNames,columnData;

    int row,col,nCols,nRows;
	int handle=khpu("localhost",1234,"user:password");
    if(handle<0) exit(1);
	result = k(handle,"`asc",(K)0);
	std::string str = "([]a:til 10;b:reverse til 10;c:10#01010101010b;d:`a)";
	result = k(handle,str.c_str(),(K)0);
    if(!result) printf("Network Error\n"),perror("Network"),exit(1);
    if(result->t==-128) printf("Server Error %s\n",result->s),kclose(handle),exit(1);
//    kclose(handle);
    if(result->t!=99&&result->t!=98) 
	{
		printf("type %d\n",result->t);
		r0(result);
		exit(1);
	}
    flip = ktd(result); // if keyed table, unkey it. ktd decrements ref count of arg.
    // table (flip) is column names!list of columns (data)
    columnNames = kK(flip->k)[0];
    columnData = kK(flip->k)[1];
    nCols = columnNames->n;
    nRows = kK(columnData)[0]->n;
    for(row=0;row<nRows;row++)
    {
        if(0==row)
        {
            for(col=0;col<nCols;col++)
            {   
                if(col>0)printf(",");
                printf("%s",kS(columnNames)[col]);
            }
            printf("\n");
        }
        for(col=0;col<nCols;col++)
        {
            K obj=kK(columnData)[col];

            if(col>0)printf(",");
            switch(obj->t)
            {
                case(1):{printf("%d",kG(obj)[row]);}break;
                case(4):{printf("%d",kG(obj)[row]);}break;
                case(5):{printf("%d",kH(obj)[row]);}break;
                case(6):{printf("%d",kI(obj)[row]);}break;
                case(7):{printf("%lld",kJ(obj)[row]);}break;
                case(8):{printf("%f",kE(obj)[row]);}break;
                case(9):{printf("%f",kF(obj)[row]);}break;
                case(11):{printf("%s",kS(obj)[row]);}break;
                default:{printf("unknown type");}break;
            }
        }
        printf("\n");
    }
    r0(flip);
    return 0;
}
Пример #7
0
void DiracWilsonLike::gamma5core(double* w,const double* f)const{
  for(int c=0; c<N; ++c){
    w[r0(c)] = f[r2(c)];  w[i0(c)] = f[i2(c)];
    w[r1(c)] = f[r3(c)];  w[i1(c)] = f[i3(c)];
    w[r2(c)] = f[r0(c)];  w[i2(c)] = f[i0(c)];
    w[r3(c)] = f[r1(c)];  w[i3(c)] = f[i1(c)];
  }
}
Пример #8
0
void GammaMatrix::isigma24core(double* w,const double* f)const{
  for(int c=0; c<Ncol_; ++c){
    w[r0(c)] = f[r3(c)];  w[i0(c)] = f[i3(c)];
    w[r1(c)] =-f[r2(c)];  w[i1(c)] =-f[i2(c)];
    w[r2(c)] = f[r1(c)];  w[i2(c)] = f[i1(c)];
    w[r3(c)] =-f[r0(c)];  w[i3(c)] =-f[i0(c)];
  }
}
Пример #9
0
static void kbic_read_block( PIA *pi, char * buf, int count )

{       int     k, a, b;

        switch (pi->mode) {

        case 0: w0(0x98); w2(4); w2(6); w2(4);
                for (k=0;k<count/2;k++) {
			w2(1); w0(8);    a = r1();
			       w0(0x28); b = r1();
			buf[2*k]   = j44(a,b);
			w2(5);           b = r1();
			       w0(8);    a = r1();
			buf[2*k+1] = j44(a,b);
			w2(4);
                } 
                break;

        case 1: w0(0xb8); w2(4); w2(6); w2(4); 
                for (k=0;k<count/4;k++) {
                        w0(0xb8); 
			w2(4); w2(5); 
                        w0(8);    buf[4*k]   = j53(r12w());
			w0(0xb8); buf[4*k+1] = j53(r12w());
			w2(4); w2(5);
			          buf[4*k+3] = j53(r12w());
			w0(8);    buf[4*k+2] = j53(r12w());
                }
                w2(4);
                break;

        case 2: w0(0x88); w2(4); w2(6); w2(4);
                for (k=0;k<count/2;k++) {
                        w2(0xa0); w2(0xa1); buf[2*k] = r0();
                        w2(0xa5); buf[2*k+1] = r0();
                }
                w2(4);
                break;

        case 3: w0(0xa0); w2(4); w2(6); w2(4); w3(0);
                for (k=0;k<count;k++) buf[k] = r4();
                w2(4); w2(0); w2(4);
                break;

	case 4: w0(0xa0); w2(4); w2(6); w2(4); w3(0);
                for (k=0;k<count/2;k++) ((u16 *)buf)[k] = r4w();
                w2(4); w2(0); w2(4);
                break;

        case 5: w0(0xa0); w2(4); w2(6); w2(4); w3(0);
                for (k=0;k<count/4;k++) ((u32 *)buf)[k] = r4l();
                w2(4); w2(0); w2(4);
                break;


        }
}
Пример #10
0
void GammaMatrix::projMcore(double* w,const double* f)const{
  for(int c=0; c<Ncol_; ++c){
    double fup_r = 0.5*(f[r0(c)] -f[r2(c)]);
    double fup_i = 0.5*(f[i0(c)] -f[i2(c)]);
    double fdn_r = 0.5*(f[r1(c)] -f[r3(c)]);
    double fdn_i = 0.5*(f[i1(c)] -f[i3(c)]);
    w[r0(c)] = fup_r;   w[i0(c)] = fup_i;
    w[r1(c)] = fdn_r;   w[i1(c)] = fdn_i;
    w[r2(c)] =-fup_r;   w[i2(c)] =-fup_i;
    w[r3(c)] =-fdn_r;   w[i3(c)] =-fdn_i;
  }
}
Пример #11
0
void DiracWilsonLike::projMcore(double* w,const double* f)const{
  for(int c=0; c<N; ++c){
    double fup_r = 0.5*(f[r0(c)] -f[r2(c)]);
    double fup_i = 0.5*(f[i0(c)] -f[i2(c)]);
    double fdn_r = 0.5*(f[r1(c)] -f[r3(c)]);
    double fdn_i = 0.5*(f[i1(c)] -f[i3(c)]);
    w[r0(c)] = fup_r;   w[i0(c)] = fup_i;
    w[r1(c)] = fdn_r;   w[i1(c)] = fdn_i;
    w[r2(c)] =-fup_r;   w[i2(c)] =-fup_i;
    w[r3(c)] =-fdn_r;   w[i3(c)] =-fdn_i;
  }
}
Пример #12
0
static void on26_read_block( PIA *pi, char * buf, int count )

{       int     k, a, b;

        switch (pi->mode) {

        case 0: w0(1); P1; w0(1); P2; w0(2); P1; w0(0x18); P2; w0(0); P1;
		udelay(10);
		for (k=0;k<count;k++) {
                        w2(6); a = r1();
                        w2(4); b = r1();
                        buf[k] = j44(a,b);
                }
		w0(2); P1; w0(8); P2; 
                break;

        case 1: w0(1); P1; w0(1); P2; w0(2); P1; w0(0x19); P2; w0(0); P1;
		udelay(10);
                for (k=0;k<count/2;k++) {
                        w2(0x26); buf[2*k] = r0();  
			w2(0x24); buf[2*k+1] = r0();
                }
                w0(2); P1; w0(9); P2;
                break;

        case 2: w3(1); w3(1); w2(5); w4(1); w2(4);
		w3(0); w3(0); w2(0x24);
		udelay(10);
                for (k=0;k<count;k++) buf[k] = r4();
                w2(4);
                break;

        case 3: w3(1); w3(1); w2(5); w4(1); w2(4);
                w3(0); w3(0); w2(0x24);
                udelay(10);
                for (k=0;k<count/2;k++) ((u16 *)buf)[k] = r4w();
                w2(4);
                break;

        case 4: w3(1); w3(1); w2(5); w4(1); w2(4);
                w3(0); w3(0); w2(0x24);
                udelay(10);
                for (k=0;k<count/4;k++) ((u32 *)buf)[k] = r4l();
                w2(4);
                break;

        }
}
Пример #13
0
static int epat_read_regr( PIA *pi, int cont, int regr )

{	int  a, b, r;

	r = regr + cont_map[cont];

	switch (pi->mode) {

	case 0:	w0(r); w2(1); w2(3); 
		a = r1(); w2(4); b = r1();
		return j44(a,b);

	case 1: w0(0x40+r); w2(1); w2(4);
		a = r1(); b = r2(); w0(0xff);
		return j53(a,b);

	case 2: w0(0x20+r); w2(1); w2(0x25);
		a = r0(); w2(4);
		return a;

	case 3:
	case 4:
	case 5: w3(r); w2(0x24); a = r4(); w2(4);
		return a;

	}
	return -1;	/* never gets here */
}
Пример #14
0
static void epat_connect ( PIA *pi )

{       pi->saved_r0 = r0();
        pi->saved_r2 = r2();

 	/* Initialize the chip */
	CPP(0);

	if (epatc8) {
		CPP(0x40);CPP(0xe0);
		w0(0);w2(1);w2(4);
		WR(0x8,0x12);WR(0xc,0x14);WR(0x12,0x10);
		WR(0xe,0xf);WR(0xf,4);
		/* WR(0xe,0xa);WR(0xf,4); */
		WR(0xe,0xd);WR(0xf,0);
		/* CPP(0x30); */
	}

        /* Connect to the chip */
	CPP(0xe0);
        w0(0);w2(1);w2(4); /* Idle into SPP */
        if (pi->mode >= 3) {
          w0(0);w2(1);w2(4);w2(0xc);
          /* Request EPP */
          w0(0x40);w2(6);w2(7);w2(4);w2(0xc);w2(4);
        }

	if (!epatc8) {
		WR(8,0x10); WR(0xc,0x14); WR(0xa,0x38); WR(0x12,0x10);
	}
}
Пример #15
0
static void epat_connect ( PIA *pi )

{       pi->saved_r0 = r0();
        pi->saved_r2 = r2();

#ifdef CONFIG_PARIDE_EPATC8
 	/* Initialize the chip */
        CPP(0);CPP(0x40);CPP(0xe0);              
        w0(0);w2(1);w2(4);
        WR(0x8,0x12);WR(0xc,0x14);WR(0x12,0x10);
        WR(0xe,0xf);WR(0xf,4);
     /* WR(0xe,0xa);WR(0xf,4); */
        WR(0xe,0xd);WR(0xf,0);
     /* CPP(0x30); */

        /* Connect to the chip */
	CPP(0xe0);
        w0(0);w2(1);w2(4); /* Idle into SPP */
        if (pi->mode >= 3) {
          w0(0);w2(1);w2(4);w2(0xc);
          /* Request EPP */
          w0(0x40);w2(6);w2(7);w2(4);w2(0xc);w2(4);
        }
#else
 	CPP(0); CPP(0xe0);
	w0(0); w2(1); w2(4);
	if (pi->mode >= 3) {
		w0(0); w2(1); w2(4); w2(0xc);
		w0(0x40); w2(6); w2(7); w2(4); w2(0xc); w2(4);
	}
	WR(8,0x10); WR(0xc,0x14); WR(0xa,0x38); WR(0x12,0x10);
#endif
}
Пример #16
0
static int comm_read_regr( PIA *pi, int cont, int regr )

{       int     l, h, r;

        r = regr + cont_map[cont];

        switch (pi->mode)  {

        case 0: w0(r); P1; w0(0);
        	w2(6); l = r1(); w0(0x80); h = r1(); w2(4);
                return j44(l,h);

        case 1: w0(r+0x20); P1; 
        	w0(0); w2(0x26); h = r0(); w2(4);
                return h;

	case 2:
	case 3:
        case 4: w3(r+0x20); (void)r1();
        	w2(0x24); h = r4(); w2(4);
                return h;

        }
        return -1;
}       
Пример #17
0
static int kbic_read_regr( PIA *pi, int cont, int regr )

{       int     a, b, s;

        s = cont_map[cont];

	switch (pi->mode) {

	case 0: w0(regr|0x18|s); w2(4); w2(6); w2(4); w2(1); w0(8);
	        a = r1(); w0(0x28); b = r1(); w2(4);
		return j44(a,b);

	case 1: w0(regr|0x38|s); w2(4); w2(6); w2(4); w2(5); w0(8);
		a = r12w(); w2(4);
		return j53(a);

	case 2: w0(regr|0x08|s); w2(4); w2(6); w2(4); w2(0xa5); w2(0xa1);
		a = r0(); w2(4);
       		return a;

	case 3:
	case 4:
	case 5: w0(0x20|s); w2(4); w2(6); w2(4); w3(regr);
		a = r4(); b = r4(); w2(4); w2(0); w2(4);
		return a;

	}
	return -1;
}       
Пример #18
0
/*
 * Make the matrix orthonormal in place using an iterative method.
 * It is potentially slower if the matrix is far from orthonormal (i.e. if
 * the row basis vectors are close to colinear) but in the common case
 * of near-orthonormality it should be just as fast.
 *
 * The translation part is left intact.  If the translation is represented as
 * a homogenous coordinate (i.e. a non-unity lower right corner), it is divided
 * out.
 */
bool
GfMatrix4f::Orthonormalize(bool issueWarning)
{
    // orthogonalize and normalize row vectors
    GfVec3d r0(_mtx[0][0],_mtx[0][1],_mtx[0][2]);
    GfVec3d r1(_mtx[1][0],_mtx[1][1],_mtx[1][2]);
    GfVec3d r2(_mtx[2][0],_mtx[2][1],_mtx[2][2]);
    bool result = GfVec3d::OrthogonalizeBasis(&r0, &r1, &r2, true);
    _mtx[0][0] = r0[0];
    _mtx[0][1] = r0[1];
    _mtx[0][2] = r0[2];
    _mtx[1][0] = r1[0];
    _mtx[1][1] = r1[1];
    _mtx[1][2] = r1[2];
    _mtx[2][0] = r2[0];
    _mtx[2][1] = r2[1];
    _mtx[2][2] = r2[2];

    // divide out any homogeneous coordinate - unless it's zero
    if (_mtx[3][3] != 1.0 && !GfIsClose(_mtx[3][3], 0.0, GF_MIN_VECTOR_LENGTH))
    {
	_mtx[3][0] /= _mtx[3][3];
	_mtx[3][1] /= _mtx[3][3];
	_mtx[3][2] /= _mtx[3][3];
	_mtx[3][3] = 1.0;
    }

    if (!result && issueWarning)
	TF_WARN("OrthogonalizeBasis did not converge, matrix may not be "
                "orthonormal.");

    return result;
}
Пример #19
0
void MSNewton::Fixed::submit_constraints(const NewtonJoint* joint, dgFloat32 timestep, int thread_index) {
	JointData* joint_data = (JointData*)NewtonJointGetUserData(joint);

	// Calculate position of pivot points and Jacobian direction vectors in global space.
	dMatrix matrix0, matrix1, matrix2;
	MSNewton::Joint::c_calculate_global_matrix(joint_data, matrix0, matrix1, matrix2);

	const dVector& p0 = matrix0.m_posit;
	const dVector& p1 = matrix1.m_posit;
	// Get a point along the pin axis at some reasonable large distance from the pivot.
	dVector q0(p0 + matrix0.m_right.Scale(MIN_JOINT_PIN_LENGTH));
	dVector q1(p1 + matrix1.m_right.Scale(MIN_JOINT_PIN_LENGTH));
	// Get the ankle point.
	dVector r0(p0 + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH));
	dVector r1(p1 + matrix1.m_front.Scale(MIN_JOINT_PIN_LENGTH));

	// Restrict movement on the pivot point along all three orthonormal directions
	NewtonUserJointAddLinearRow(joint, &p0[0], &p1[0], &matrix0.m_front[0]);
	if (joint_data->ctype == CT_FLEXIBLE)
		NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
	else if (joint_data->ctype == CT_ROBUST)
		NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
	NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);

	NewtonUserJointAddLinearRow(joint, &p0[0], &p1[0], &matrix0.m_up[0]);
	if (joint_data->ctype == CT_FLEXIBLE)
		NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
	else if (joint_data->ctype == CT_ROBUST)
		NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
	NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);

	NewtonUserJointAddLinearRow(joint, &p0[0], &p1[0], &matrix0.m_right[0]);
	if (joint_data->ctype == CT_FLEXIBLE)
		NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
	else if (joint_data->ctype == CT_ROBUST)
		NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
	NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);

	// Restrict rotation along all three orthonormal directions
	NewtonUserJointAddLinearRow(joint, &q0[0], &q1[0], &matrix0.m_front[0]);
	if (joint_data->ctype == CT_FLEXIBLE)
		NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
	else if (joint_data->ctype == CT_ROBUST)
		NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
	NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);

	NewtonUserJointAddLinearRow(joint, &q0[0], &q1[0], &matrix0.m_up[0]);
	if (joint_data->ctype == CT_FLEXIBLE)
		NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
	else if (joint_data->ctype == CT_ROBUST)
		NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
	NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);

	NewtonUserJointAddLinearRow(joint, &r0[0], &r1[0], &matrix0.m_up[0]);
	if (joint_data->ctype == CT_FLEXIBLE)
		NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
	else if (joint_data->ctype == CT_ROBUST)
		NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
	NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);
}
Пример #20
0
int sc_main(int argc, char* argv[])
{
    sc_signal<bool> t_a0;
    sc_signal<bool> t_a1;
    sc_signal<bool> t_a2;
    sc_signal<bool> t_a3;
    sc_signal<bool> t_b0;
    sc_signal<bool> t_b1;
    sc_signal<bool> t_b2;
    sc_signal<bool> t_b3;
    sc_signal<bool> t_c0;
    sc_signal<bool> t_s0;
    sc_signal<bool> t_s1;
    sc_signal<bool> t_s2;
    sc_signal<bool> t_s3;
    sc_signal<bool> t_c4;
    ripple_adder r0("r0");
    r0.a0(t_a0);
    r0.a1(t_a1);
    r0.a2(t_a2);
    r0.a3(t_a3);
    r0.b0(t_b0);
    r0.b1(t_b1);
    r0.b2(t_b2);
    r0.b3(t_b3);
    r0.c0(t_c0);
    r0.s0(t_s0);
    r0.s1(t_s1);
    r0.s2(t_s2);
    r0.s3(t_s3);
    r0.c4(t_c4);
    ripple_adder_driver d0("d0");
    d0.d_a0(t_a0);
    d0.d_a1(t_a1);
    d0.d_a2(t_a2);
    d0.d_a3(t_a3);
    d0.d_b0(t_b0);
    d0.d_b1(t_b1);
    d0.d_b2(t_b2);
    d0.d_b3(t_b3);
    d0.d_c0(t_c0);
    ripple_adder_monitor m0("m0");
    m0.m_a0(t_a0);
    m0.m_a1(t_a1);
    m0.m_a2(t_a2);
    m0.m_a3(t_a3);
    m0.m_b0(t_b0);
    m0.m_b1(t_b1);
    m0.m_b2(t_b2);
    m0.m_b3(t_b3);
    m0.m_c0(t_c0);
    m0.m_s0(t_s0);
    m0.m_s1(t_s1);
    m0.m_s2(t_s2);
    m0.m_s3(t_s3);
    m0.m_c4(t_c4);
    // simulate for max 1000 ns
    sc_start(1, SC_SEC);
    return 0;
}
Пример #21
0
UIntT num_replications(RealT eps, RealT s0, RealT level=0.95, UIntT max_trials=::std::numeric_limits<UIntT>::max())
{
	UIntT r0(0);
	r0 = num_replications_initial<RealT,UIntT>(eps, s0, level);

	return num_replications(eps, r0, s0, level, max_trials);
}
Пример #22
0
static int dstr_read_regr( PIA *pi, int cont, int regr )

{       int     a, b, r;

        r = regr + cont_map[cont];

	w0(0x81); P1;
	if (pi->mode) { w0(0x11); } else { w0(1); }
	P2; w0(r); P1;

        switch (pi->mode)  {

        case 0: w2(6); a = r1(); w2(4); w2(6); b = r1(); w2(4);
                return j44(a,b);

        case 1: w0(0); w2(0x26); a = r0(); w2(4);
                return a;

	case 2:
	case 3:
        case 4: w2(0x24); a = r4(); w2(4);
                return a;

        }
        return -1;
}       
Пример #23
0
DEF_TEST(Data, reporter) {
    const char* str = "We the people, in order to form a more perfect union.";
    const int N = 10;

    SkAutoTUnref<SkData> r0(SkData::NewEmpty());
    SkAutoTUnref<SkData> r1(SkData::NewWithCopy(str, strlen(str)));
    SkAutoTUnref<SkData> r2(SkData::NewWithProc(new int[N], N*sizeof(int),
                                           delete_int_proc, gGlobal));
    SkAutoTUnref<SkData> r3(SkData::NewSubset(r1, 7, 6));

    assert_len(reporter, r0, 0);
    assert_len(reporter, r1, strlen(str));
    assert_len(reporter, r2, N * sizeof(int));
    assert_len(reporter, r3, 6);

    assert_data(reporter, r1, str, strlen(str));
    assert_data(reporter, r3, "people", 6);

    SkData* tmp = SkData::NewSubset(r1, strlen(str), 10);
    assert_len(reporter, tmp, 0);
    tmp->unref();
    tmp = SkData::NewSubset(r1, 0, 0);
    assert_len(reporter, tmp, 0);
    tmp->unref();

    test_cstring(reporter);
    test_files(reporter);
}
Пример #24
0
void
vec4_gs_visitor::emit_thread_end()
{
   if (c->control_data_header_size_bits > 0) {
      /* During shader execution, we only ever call emit_control_data_bits()
       * just prior to outputting a vertex.  Therefore, the control data bits
       * corresponding to the most recently output vertex still need to be
       * emitted.
       */
      current_annotation = "thread end: emit control data bits";
      emit_control_data_bits();
   }

   /* MRF 0 is reserved for the debugger, so start with message header
    * in MRF 1.
    */
   int base_mrf = 1;

   current_annotation = "thread end";
   dst_reg mrf_reg(MRF, base_mrf);
   src_reg r0(retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));
   vec4_instruction *inst = emit(MOV(mrf_reg, r0));
   inst->force_writemask_all = true;
   emit(GS_OPCODE_SET_VERTEX_COUNT, mrf_reg, this->vertex_count);
   if (INTEL_DEBUG & DEBUG_SHADER_TIME)
      emit_shader_time_end();
   inst = emit(GS_OPCODE_THREAD_END);
   inst->base_mrf = base_mrf;
   inst->mlen = 1;
}
Пример #25
0
static void k971_connect ( PIA *pi  )

{   pi->saved_r0 = r0();
    pi->saved_r2 = r2();
    CCP(0x20);
    w2(4);
}
Пример #26
0
static int epia_read_regr( PIA *pi, int cont, int regr )

{       int     a, b, r;

	regr += cont_map[cont];

        switch (pi->mode)  {

        case 0: r = regr^0x39;
                w0(r); w2(1); w2(3); w0(r);
                a = r1(); w2(1); b = r1(); w2(4);
                return j44(a,b);

        case 1: r = regr^0x31;
                w0(r); w2(1); w0(r&0x37); 
                w2(3); w2(5); w0(r|0xf0);
                a = r1(); b = r2(); w2(4);
                return j53(a,b);

        case 2: r = regr^0x29;
                w0(r); w2(1); w2(0X21); w2(0x23); 
                a = r0(); w2(4);
                return a;

	case 3:
	case 4:
        case 5: w3(regr); w2(0x24); a = r4(); w2(4);
                return a;

        }
        return -1;
}       
Пример #27
0
static int fit3_read_regr( PIA *pi, int cont, int regr )

{	int  a, b;

	if (cont) {
	  if (regr != 6) return 0xff;
	  regr = 7;
	}

	switch (pi->mode) {

	case 0: w2(0xc); w0(regr + 0x10); w2(0x8); w2(0xc);
		w2(0xd); a = r1();
		w2(0xf); b = r1();
		w2(0xc);
		return j44(a,b);

	case 1: w2(0xc); w0(regr + 0x90); w2(0x8); w2(0xc);
		w2(0xec); w2(0xee); w2(0xef); a = r0();
		w2(0xc);
		return a;

	case 2: w2(0xc); w0(regr + 0x90); w2(0x8); w2(0xc);
		w2(0xec);
		a = r4(); b = r4();
		w2(0xc);
		return a;

	}
	return -1;

}
Пример #28
0
static int on26_read_regr( PIA *pi, int cont, int regr )

{       int     a, b, r;

	r = (regr<<2) + 1 + cont;

        switch (pi->mode)  {

        case 0: w0(1); P1; w0(r); P2; w0(0); P1; 
		w2(6); a = r1(); w2(4);
		w2(6); b = r1(); w2(4);
		w2(6); w2(4); w2(6); w2(4);
                return j44(a,b);

        case 1: w0(1); P1; w0(r); P2; w0(0); P1;
		w2(0x26); a = r0(); w2(4); w2(0x26); w2(4);
                return a;

	case 2:
	case 3:
        case 4: w3(1); w3(1); w2(5); w4(r); w2(4);
		w3(0); w3(0); w2(0x24); a = r4(); w2(4);
		w2(0x24); r4(); w2(4);
                return a;

        }
        return -1;
}       
Пример #29
0
 /* @param beta current estimates
  * @return t(beta) * matrixB * beta
  */
 STK::Real FusedLassoPenalty::penaltyTerm(STK::VectorX const& beta) const
 {
   STK::Real pen = lambda1_ * beta.abs().sum();
   STK::Range r0(beta.begin(), beta.size()-1), r1(beta.begin()+1, beta.size()-1);
   pen += lambda2_ * (beta.sub(r0) - beta.sub(r1)).abs().sum();
   return pen;
 }
Пример #30
0
int main()
{
	try {

	std::shared_ptr<gal::verb::VerbosityRegistry> vr(
			new gal::verb::VerbosityRegistry);
	
	vr->reg<gal::mng::managed_process>( "gal managed_process");
	vr->reg<gal::mng::managed_object>(  "gal managed_object");
	vr->reg<gal::registry_base>(   "gal registry_base");
	vr->reg<gal::mng::registry_process>("gal registry_process");
	vr->reg<gal::mng::registry_object>( "gal registry_object");
	
	typedef gal::mng::registry_object R1;
	typedef std::shared_ptr<R1> S_R1;
	
	typedef gal::mng::registry_process R0;
	typedef std::shared_ptr<R0> S_R0;
	
	// process registry
	S_R0 r0(new R0);

	r0->VERB::init_verb(vr);
	r0->init();
	
	// object registry
	S_R1 r1(new R1);
	r1->VERB::init_verb(vr);

	r0->reg(r1);

	r1->init();


	typedef std::shared_ptr<foo> S_F;


	S_F f0(new foo);
	S_F f1(new foo);
	S_F f2(new foo);

	f0->init_verb(vr);
	f1->init_verb(vr);
	f2->init_verb(vr);

	r1->reg(f0);
	r1->reg(f1);
	r1->reg(f2);

	gal::object_index i0 = f0->get_index();

	r1->get(i0);

	} catch(std::exception & e) {
	
	printf("%s\n", e.what());

	}
}