Exemple #1
0
static int
update(void * self, pkt_t *pkt, void *fh, int isnew)
{
    FLOWDESC *x = F(fh);
    config_t * cf = CONFIG(self);

    if (isnew) {
	bzero(x, sizeof(FLOWDESC));
	x->ts = COMO(ts);
    }

    if (COMO(type) == COMOTYPE_NF) {
	if (cf->iface == -1 || H16(NF(input)) == cf->iface) {
	    x->bytes[0] += H32(NF(pktcount)) * COMO(len) * H16(NF(sampling));
	    x->pkts[0] += H32(NF(pktcount)) * (uint32_t) H16(NF(sampling));
	} else if (H16(NF(output)) == cf->iface) { 
	    x->bytes[1] += H32(NF(pktcount)) * COMO(len) * H16(NF(sampling));
	    x->pkts[1] += H32(NF(pktcount)) * (uint32_t) H16(NF(sampling));
	} 
    } else if (COMO(type) == COMOTYPE_SFLOW) {
	x->bytes[0] += (uint64_t) COMO(len) * 
		      (uint64_t) H32(SFLOW(sampling_rate));
	x->pkts[0] += H32(SFLOW(sampling_rate));
    } else {
	x->bytes[0] += COMO(len);
        x->pkts[0]++;
    }

    return 0;
}
Exemple #2
0
/*
 * Function name:   do_sell
 * Description:     Try to let the player sell the_item
 *                  Observe there is no message written when sold item
 *                  has a value higher than the shop gives out.
 * Returns:         1 on sucess
 * Arguments:       str - string holding name of item, hopefully
 */
int
do_sell(string str)
{
    object *item;
    int value, check;
    string str1, str2;

    if(!str || str =="")
    {
	NF("Sell what?\n");
	return 0;
    }

/*  Did player specify how to get the money? */
    if (sscanf(str, "%s for %s", str1, str2) != 2)
    {
 	str1 = str;
	str2 = "";
    }

    check = 1; /* Nothing worn or wielded will be sold. */

    if (str1 == "all!")
    {
	str1 = "all";
        check = 0; /* Unless the player wants it. */
    }

    if (parse_command(str1, TP, "%i", item))
	item = NORMAL_ACCESS(item, 0, 0);
    else
	item = ({ });
Exemple #3
0
static double DeltaQCD(double Q)
{
 double  a=alphaQCD(Q)/M_PI;
 int nf=NF(Q);

 return  a*( 5.67 + a*( (35.94-1.36*nf) + a*(164.14-nf*(25.77-nf*0.259) )));
}
Exemple #4
0
/*
 * Function name:   do_read
 * Description:     If a player wants to know what instuctions can be
 *                  used
 * Arguments:       str - string, hopefully "sign"
 * Returns:         1/0
 */
int
do_read(string str)
{
    NF("Read what?\n");
    if (str != "sign")
	return 0;

    write("" +
	"You can try these instructions: \n" +
	"    buy sword for gold and get copper back\n" +
	"    buy sword for gold coins\n" +
	"    sell sword for copper coins\n" +
	"    sell all  - will let you sell all items except for\n" +
        "                items you wield or wear.\n" +
	"    sell all! - will let you sell ALL items you have, well\n" +
	"                at least the droppable, and no coins.\n" +
	"    sell sword, sell second sword, sell sword 2, sell two swords\n" +
	"                also works. You might want to change the verb to\n" +
	"                'value' or 'buy' too. Bevare, you will never buy\n"+
	"                more than one item at a time. So if you really\n" +
	"                those three expensive swords, you have to repeat\n" +
	"                yourself three times.\n" +
	"    If you want a list of all swords available in the store, the\n" +
	"    correct syntax is: list sword\n" +
	"    (not: list swords, though this might change) \n" +
	"");
    return 1;
}
Exemple #5
0
Word shortBraidForm(int N, const Word& w) {
  crag::braidgroup::BraidGroup B(N);
  ThRightNormalForm NF(B, w);
  Word w1 = NF.getShortWord();
  //  cout << "int len = " << w1.length() << endl;
  return shortenBraid(N, w1);
}
Exemple #6
0
void
capture(mdl_t *self, pkt_t *pkt, tuple_t *st, double srate)
{
    config_t *config = mdl_get_config(self, config_t);
    int app, app1, app2;
    double b, p;

    if (! isTCP && ! isUDP) /* non-TCP, non-UDP traffic */
        app = 1;
    else {                  /* TCP and UDP traffic */
        if (isTCP) {
            app1 = config->tcp_port2app[H16(TCP(src_port))];
            app2 = config->tcp_port2app[H16(TCP(dst_port))];
        } else {
            app1 = config->udp_port2app[H16(UDP(src_port))];
            app2 = config->tcp_port2app[H16(UDP(dst_port))];
        }

        if (app1 == 0 || app2 == 0) /* at most 1 port matches a known app */
            app = app1 + app2;
        else if (app1 == app2)      /* both ports match the same app */
            app = app1;
        else                        /* ports match different apps, unknown */
            app = 0;
    }

    if (COMO(type) == COMOTYPE_NF) {
        b = H32(NF(pktcount)) * COMO(len) * H16(NF(sampling));
        p = H32(NF(pktcount)) * (uint32_t) H16(NF(sampling));
    } else if (COMO(type) == COMOTYPE_SFLOW) {
        b = (uint64_t) COMO(len) * (uint64_t) H32(SFLOW(sampling_rate));
        p = H32(SFLOW(sampling_rate));
    } else {
        b = COMO(len);
        p = 1;
    }

    /* scale with sampling rate */
    st->bytes[app] += b / srate;
    st->pkts[app] += p / srate;
}
Matrix  
AC3D8HexWithSensitivity::getNodalForces(void)
{
  double r  = 0.0;
  double rw = 0.0;
  double s  = 0.0;
  double sw = 0.0;
  double t  = 0.0;
  double tw = 0.0;
  double weight = 0.0;
  double det_of_Jacobian = 0.0;
  
  short where = 0;
  
  Matrix sigma(1,3);
  Matrix NF(1,nodes_in_elem);
  
  this->computeDiff();
  NF.Zero();
  
  for(short GP_c_r = 1; GP_c_r <= r_integration_order; GP_c_r++) {
    r = get_Gauss_p_c(r_integration_order, GP_c_r);
    rw = get_Gauss_p_w(r_integration_order, GP_c_r);
    for( short GP_c_s = 1; GP_c_s <= s_integration_order; GP_c_s++ ) {
      s = get_Gauss_p_c(s_integration_order, GP_c_s);
      sw = get_Gauss_p_w(s_integration_order, GP_c_s);
      for(short GP_c_t = 1; GP_c_t <= t_integration_order; GP_c_t++) {
        t = get_Gauss_p_c(t_integration_order, GP_c_t);
        tw = get_Gauss_p_w(t_integration_order, GP_c_t);
        
        det_of_Jacobian = detJ[where];
        Matrix &dhGlobal = *L[where];
        
        weight = sw * rw * tw * det_of_Jacobian;
        
        // assemble stress tensor
        const Vector &stressvec = theMaterial[where]->getStress();
        sigma(0,0) = stressvec(0);
        sigma(0,1) = stressvec(1);
        sigma(0,2) = stressvec(2);
        
        NF.addMatrixProduct(1.0, sigma, dhGlobal, weight);
        
        // nodal forces See Zienkievicz part 1 pp 108
        // nodal_forces = nodal_forces + dhGlobal("ib")*stress_at_GP("ab")*weight;
        
        where++;
      }
    }
  }
  
  return NF;
}
Exemple #8
0
void curvature::applyFilter(RichParameterSet *pars)
{
	Eigen::MatrixXd V(mesh()->n_vertices(), 3);
	Eigen::MatrixXi F(mesh()->n_faces(), 3);

	Eigen::MatrixXd NV(mesh()->n_vertices(), 3);
	Eigen::MatrixXd NF(mesh()->n_faces(), 3);

	Vector3VertexProperty points = mesh()->vertex_coordinates();
	Vector3VertexProperty normals = mesh()->vertex_normals(true);
	Vector3FaceProperty fnormals = mesh()->face_normals(true);

	// Fill in vertices
	int vi = 0;
	foreach(Vertex v, mesh()->vertices()) { V.row(vi) = points[v]; NV.row(vi) = normals[v]; vi++; }
Exemple #9
0
static int
update(__unused void * self, pkt_t *pkt, void *fh, int isnew)
{
    FLOWDESC *x = F(fh);

    if (isnew) {
	x->ts = COMO(ts);
        x->bytes = 0;
        x->pkts = 0;
    }

    if (COMO(type) == COMOTYPE_NF) {
        x->bytes += H32(NF(pktcount)) * COMO(len) * H16(NF(sampling));
        x->pkts += H32(NF(pktcount)) * (uint32_t) H16(NF(sampling));
    } else if (COMO(type) == COMOTYPE_SFLOW) {
	x->bytes += (uint64_t) COMO(len) * (uint64_t) H32(SFLOW(sampling_rate));
	x->pkts += (uint64_t) H32(SFLOW(sampling_rate));
    } else {
	x->bytes += COMO(len);
        x->pkts++;
    }

    return 0;
}
ThRightNormalForm::NF ThRightNormalForm::inverse() const {
  int dec_size = theDecomposition.size();

  int power = -theOmegaPower - dec_size;
  const Permutation omega = Permutation::getHalfTwistPermutation(theRank);
  list<Permutation> result;

  list<Permutation>::const_iterator it = theDecomposition.end();
  for (int i = 0; i < dec_size; ++i) {
    --it;
    if ((i % 2 == 0) == (theOmegaPower % 2 != 0))
      result.push_back(omega * -(*it));
    else
      result.push_back(-(*it) * omega);
  }

  return NF(theRank, power, result);
}
Exemple #11
0
/* single to double-difference transformation matrix (D') --------------------*/
static int ddmat(rtk_t *rtk, double *D,char **msg)
{
    int i,j,k,f,nb=0,nx=rtk->nx,na=rtk->na,nf=NF(&rtk->opt);
    //*msg += sprintf(*msg,"A");
    for (i=0; i<MAX_SAT; i++) {
        rtk->ssat[i].fix=0;
    }
    //*msg += sprintf(*msg,"B");
    for (i=0; i<na; i++) D[i+i*nx]=1.0;
    //*msg += sprintf(*msg,"C");
    for (f=0,k=na; f<nf; f++,k+=MAX_SAT) {
        for (i=k; i<k+MAX_SAT; i++) {
            if ((rtk->x[i]==0.0)||(!rtk->ssat[i-k].vsat))
                continue;

            if (rtk->ssat[i-k].lock>0&&!(rtk->ssat[i-k].slip&2)&&
                    rtk->ssat[i-k].azel[1]>=rtk->opt.elmaskar) {
                rtk->ssat[i-k].fix=2; /* fix */
                break;
            }
            else rtk->ssat[i-k].fix=1;
        }
        for (j=k; j<k+MAX_SAT; j++) {
            if (i==j||rtk->x[j]==0.0||
                    !rtk->ssat[j-k].vsat)
                continue;

            if (rtk->ssat[j-k].lock>0&&!(rtk->ssat[j-k].slip&2)&&
                    rtk->ssat[i-k].vsat&&
                    rtk->ssat[j-k].azel[1]>=rtk->opt.elmaskar) {
                D[i+(na+nb)*nx]= 1.0;
                D[j+(na+nb)*nx]=-1.0;
                nb++;
                rtk->ssat[j-k].fix=2; /* fix */
            }
            else rtk->ssat[j-k].fix=1;
        }
    }

    //*msg += sprintf(*msg,"D");
    return nb;
}
ThRightNormalForm::NF
ThRightNormalForm::multiply( const ThRightNormalForm& rep ) const
{
  const Permutation omega = Permutation::getHalfTwistPermutation( theRank );
  
  // 1. shift omegas to the right
  int power = theOmegaPower + rep.theOmegaPower;
  
  list< Permutation > blocks( theDecomposition );
  
  // 2. if power of the omega on the left is odd we must flip 
  //    permutations of the second form
  list< Permutation >::const_iterator it = rep.theDecomposition.begin( );
  if( theOmegaPower%2 ) {
    for( size_t t=0 ; t<rep.theDecomposition.size( ) ; ++t , ++it )
      blocks.push_back( omega * (*it) * omega );
  } else
    blocks.insert( blocks.end( ) , 
		   rep.theDecomposition.begin( ) , 
		   rep.theDecomposition.end( ) );
  
  adjustDecomposition( theRank , power , blocks );
  return NF( theRank , power , blocks );
}
Exemple #13
0
int 
NdbBackup::NFMaster(NdbRestarter& _restarter){
  const int sz = sizeof(NFDuringBackupM_codes)/sizeof(NFDuringBackupM_codes[0]);
  return NF(_restarter, NFDuringBackupM_codes, sz, true);
}
double alphaQCD(double Q) 
{ 
  if(notInitialized) initQCD(0.1184,1.2,4.23,173.07);
  if(Q<qLim) Q=qLim;
  if(Q<qMin) return 1; return alpha3(Q,lambda[NF(Q)],NF(Q));
}
Vector 
AC3D8HexWithSensitivity::nodal_forces_from_displacement(const Vector &u)
{
  Vector nodalF(numDOF);
  
  double r, s, t;
  double rw, sw, tw;
  double weight = 0.0;
  double det_of_Jacobian = 0.0;

  short where = 0;
  
  Matrix sigma(1,3);
  Matrix NF(1,nodes_in_elem);
  
  Vector epsilon(3);
  Matrix sstrain(3,1);
  Matrix tmp_disp(nodes_in_elem, 1);
  
  int i;
  for(i = 0; i < nodes_in_elem; i++) {
    tmp_disp(i,0) = u(i);
  }
  
  this->computeDiff();
  
  for(short GP_c_r = 1; GP_c_r <= r_integration_order; GP_c_r++) {
    r = get_Gauss_p_c(r_integration_order, GP_c_r);
    rw = get_Gauss_p_w(r_integration_order, GP_c_r);
    for(short GP_c_s = 1; GP_c_s <= s_integration_order; GP_c_s++) {
      s = get_Gauss_p_c(s_integration_order, GP_c_s);
      sw = get_Gauss_p_w(s_integration_order, GP_c_s);
      for(short GP_c_t = 1; GP_c_t <= t_integration_order; GP_c_t++) {
        t = get_Gauss_p_c(t_integration_order, GP_c_t);
        tw = get_Gauss_p_w(t_integration_order, GP_c_t);
        
        det_of_Jacobian = detJ[where];
        Matrix &dhGlobal = *L[where];
        
        sstrain.addMatrixProduct(0.0, dhGlobal, tmp_disp, 1.0);
        epsilon(0) = sstrain(0,0);
        epsilon(1) = sstrain(1,0);
        epsilon(2) = sstrain(2,0);
        
        theMaterial[where]->setTrialStrain(epsilon);
        
        weight = sw * rw * tw * det_of_Jacobian;
        
        // assemble stress tensor
        const Vector &stressvec = theMaterial[where]->getStress();
        sigma(0,0) = stressvec(0);
        sigma(0,1) = stressvec(1);
        sigma(0,2) = stressvec(2);
        
        NF.addMatrixProduct(1.0, sigma, dhGlobal, weight);
        
        where++;
      }
    }
  }
  
  for(i = 1; i <= nodes_in_elem; i++) {
    nodalF(i) = NF(0,i);
  }
  
  return nodalF;
}
Exemple #16
0
Word garsideDehornoy(int N, const Word& w) {
  crag::braidgroup::BraidGroup B(N);
  ThRightNormalForm NF(B, w);
  const auto w1 = NF.getShortWord();
  return dehornoy(N, w1);
}
 const Vector &
AC3D8HexWithSensitivity::getResistingForceSensitivity(int gradNumber)
{
  double r  = 0.0;
  double rw = 0.0;
  double s  = 0.0;
  double sw = 0.0;
  double t  = 0.0;
  double tw = 0.0;
  double weight = 0.0;
  double det_of_Jacobian = 0.0;
  static const int nstress = 3 ;
  static Vector stress (nstress);
  short where = 0;
  
  Matrix sigma(1,3);
  Matrix NF(1,nodes_in_elem);
  
  this->computeDiff();
  NF.Zero();
  
  for(short GP_c_r = 1; GP_c_r <= r_integration_order; GP_c_r++) {
    r = get_Gauss_p_c(r_integration_order, GP_c_r);
    rw = get_Gauss_p_w(r_integration_order, GP_c_r);
    for( short GP_c_s = 1; GP_c_s <= s_integration_order; GP_c_s++ ) {
      s = get_Gauss_p_c(s_integration_order, GP_c_s);
      sw = get_Gauss_p_w(s_integration_order, GP_c_s);
      for(short GP_c_t = 1; GP_c_t <= t_integration_order; GP_c_t++) {
        t = get_Gauss_p_c(t_integration_order, GP_c_t);
        tw = get_Gauss_p_w(t_integration_order, GP_c_t);
        
        det_of_Jacobian = detJ[where];
        Matrix &dhGlobal = *L[where];
        
        weight = sw * rw * tw * det_of_Jacobian;
        
        // assemble stress tensor
        const Vector &stressvec = theMaterial[where]->getStressSensitivity(gradNumber,true);
        sigma(0,0) = stressvec(0);
        sigma(0,1) = stressvec(1);
        sigma(0,2) = stressvec(2);
        
        NF.addMatrixProduct(1.0, sigma, dhGlobal, weight);

	//	opserr<<"sigma"<<sigma<<endln;
     //   opserr<<"dhGlobal"<<dhGlobal<<endln;
      //  opserr<<"weight"<<weight<<endln;
      //  opserr<<"NF"<<NF<<endln;

        
        // nodal forces See Zienkievicz part 1 pp 108
        // nodal_forces = nodal_forces + dhGlobal("ib")*stress_at_GP("ab")*weight;
        
        where++;
      }
    }
  }
  
  int i, counter = 0;
  //converting nodalforce matrix to vector
  for (i = 0; i < nodes_in_elem; i++){
    P(i) = NF(0,i);
  }
        
 // opserr<<"P in getResistingForceSensitivity is  "<<P<<endln;
  // P.addVector(1.0, Q, -1.0);
  
  return P;


  //return NF;



 }
Exemple #18
0
double nfQCD(double Q) {return NF(Q);}
Exemple #19
0
double alphaQCD(double Q) 
{ 
  if(notInitialized) initQCD(0.1172,1.2,4.23,171.4);
  if(Q<qMin) return 1; return alpha3(Q,lambda[NF(Q)],NF(Q));
}
int
AC3D8HexWithSensitivity::commitSensitivity(int gradNumber, int numGrads)
{
  double r  = 0.0;
  double rw = 0.0;
  double s  = 0.0;
  double sw = 0.0;
  double t  = 0.0;
  double tw = 0.0;
  double weight = 0.0;
  double det_of_Jacobian = 0.0;
  static const int nstress = 3 ;
  int success;

  static Vector stress (nstress);
  short where = 0;
  
  Matrix sigma(1,3);
  Matrix NF(1,nodes_in_elem);
  
  this->computeDiff();
  NF.Zero();

  static Matrix ul(1,3);

  for(short GP_c_r = 1; GP_c_r <= r_integration_order; GP_c_r++) {
    r = get_Gauss_p_c(r_integration_order, GP_c_r);
    rw = get_Gauss_p_w(r_integration_order, GP_c_r);
    for( short GP_c_s = 1; GP_c_s <= s_integration_order; GP_c_s++ ) {
      s = get_Gauss_p_c(s_integration_order, GP_c_s);
      sw = get_Gauss_p_w(s_integration_order, GP_c_s);
      for(short GP_c_t = 1; GP_c_t <= t_integration_order; GP_c_t++) {
        t = get_Gauss_p_c(t_integration_order, GP_c_t);
        tw = get_Gauss_p_w(t_integration_order, GP_c_t);
        
        det_of_Jacobian = detJ[where];
        Matrix &dhGlobal = *L[where];
        
        weight = sw * rw * tw * det_of_Jacobian;

        where++;

      }
    }
  }
  
 
  int i;

  Vector epsilon(3); 
  Matrix sstrain(3,1);
  
  ul(0,0)= theNodes[0]->getDispSensitivity(1,gradNumber);
  ul(0,1)= theNodes[1]->getDispSensitivity(2,gradNumber);
  ul(0,2)= theNodes[2]->getDispSensitivity(3,gradNumber);
 // opserr<<"ul"<<ul<<endln;

  for(i = 0; i < numGP; i++) {
    const Matrix &dhGlobal = *L[i];
    
    sstrain.addMatrixProduct(0.0, dhGlobal, ul, 1.0);
    epsilon(0) = sstrain(0,0);
    epsilon(1) = sstrain(1,0);
    epsilon(2) = sstrain(2,0);
  
    success = theMaterial[i]->commitSensitivity(epsilon,gradNumber,numGrads ) ;


   } 
  return success;


  //return NF;



 }
Exemple #21
0
        {"transfer", 2, 2},
        {"deflect", 2, 3},
        {"multiparty", 0, 4},
        {"seperate", 1, 5},
    };

static WsStdLibFuncReg lib_wtais95_functions[] =
    {
        {"sendText", 6, 0},
        {"cancelText", 1, 1},
        {"sendAck", 1, 2},
    };

static WsStdLibReg libraries[] =
    {
        {"Lang", 0, NF(lib_lang_functions), lib_lang_functions},
        {"Float", 1, NF(lib_float_functions), lib_float_functions},
        {"String", 2, NF(lib_string_functions), lib_string_functions},
        {"URL", 3, NF(lib_url_functions), lib_url_functions},
        {"WMLBrowser", 4, NF(lib_wmlbrowser_functions), lib_wmlbrowser_functions},
        {"Dialogs", 5, NF(lib_dialogs_functions), lib_dialogs_functions},
        {"Crypto", 6, NF(lib_crypto_functions), lib_crypto_functions},
        {"EFI", 7, NF(lib_efi_functions), lib_efi_functions},
        {"WTAPublic", 512, NF(lib_wtapublic_functions), lib_wtapublic_functions},
        {"WTAVoiceCall", 513, NF(lib_wtavoicecall_functions), lib_wtavoicecall_functions},
        {"WTANetText", 514, NF(lib_wtanettext_functions), lib_wtanettext_functions},
        {"WTAPhoneBook", 515, NF(lib_wtaphonebook_functions), lib_wtaphonebook_functions},
        {"WTAMisc", 516, NF(lib_wtamisc_functions), lib_wtamisc_functions},
        {"WTAANSI163", 517, NF(lib_wtaansi136_functions), lib_wtaansi136_functions},
        {"WTAGSM", 518, NF(lib_wtagsm_functions), lib_wtagsm_functions},
        {"WTACallLog", 519, NF(lib_wtacalllog_functions), lib_wtacalllog_functions},
Exemple #22
0
int 
NdbBackup::NFSlave(NdbRestarter& _restarter){
  const int sz = sizeof(NFDuringBackupS_codes)/sizeof(NFDuringBackupS_codes[0]);
  return NF(_restarter, NFDuringBackupS_codes, sz, false);
}
                if (cache[T] == 0) cache[T] = nombre_facteur(T*modulo, p, modulo);
                resultat += cache[T];
            }
            
            resultat %= modulo;
        }
        
        return resultat;
    }
}


ENREGISTRER_PROBLEME(288, "An enormous factorial")
{
    // For any prime p the number N(p,q) is defined by N(p,q) = ∑n=0 to q Tn*p**n
    // with Tn generated by the following random number generator:
    //
    // S0 = 290797
    // Sn+1 = Sn² mod 50515093
    // Tn = Sn mod p
    // 
    // Let Nfac(p,q) be the factorial of N(p,q).
    // Let NF(p,q) be the number of factors p in Nfac(p,q).
    // 
    // You are given that NF(3,10000) mod 3**20=624955285.
    //
    // Find NF(61,10**7) mod 61**10
    nombre resultat = NF(61, 10000000, 10);
    return std::to_string(resultat);
}