示例#1
0
template <class T> complex<T> R2q2g_qmqppm_LT
      (const eval_param<T>& ep,
                 const mass_param_coll& mpc){
      // {{qm, qp, p, m}, LT}
 
#if _VERBOSE
  _MESSAGE("R2q2g :  qmqppm LT");
#endif
 
 return( (complex<T>(0,-1)*pow(SPA(1,4),2)*SPA(2,4))/(complex<T>(2,0)*SPA(1,2)*SPA(2,3)*
SPA(3,4))
        ); 
  
} 
示例#2
0
static F2(jtpdtspvv){A x;D*av,s,t,*wv,z;I i,*u,*u0,*uu,*v,*v0,*vv;P*ap,*wp;
 RZ(a&&w);
 ap=PAV(a); x=SPA(ap,i); u=u0=AV(x); uu=u+AN(x); x=SPA(ap,x); av=DAV(x);
 wp=PAV(w); x=SPA(wp,i); v=v0=AV(x); vv=v+AN(x); x=SPA(wp,x); wv=DAV(x);
 z=0.0;
 NAN0;
 while(1){
  i=*u; while(i>*v&&v<vv)++v; if(v==vv)break;
  if(i==*v){s=av[u-u0]; t=wv[v-v0]; z+=s&&t?s*t:0; ++u; ++v; continue;}
  i=*v; while(i>*u&&u<uu)++u; if(u==uu)break;
  if(i==*u){s=av[u-u0]; t=wv[v-v0]; z+=s&&t?s*t:0; ++u; ++v; continue;}
 }
 NAN1;
 R scf(z);
}
示例#3
0
static F2(jtpdtspmv){A ax,b,g,x,wx,y,yi,yj,z;B*bv;I m,n,s[2],*u,*v,*yv;P*ap,*wp,*zp;
 RZ(a&&w);
 ap=PAV(a); y=SPA(ap,i); yv=AV(y); s[0]=n=*AS(y); s[1]=1;
 GATV(yj,INT,n,2,s);
 if(DENSE&AT(w)){
  GATV(yi,INT,n,2,s); u=AV(yi); AR(yj)=1; v=AV(yj);
  DO(n, *u++=*yv++; *v++=*yv++;);
/*------------------------------------------------------------------------
 *  mkarp  -  allocate and fill in an ARP or RARP packet
 *------------------------------------------------------------------------
 */
static
struct ep *
mkarp(int ifn, short type, short op, IPaddr spa, IPaddr tpa)
{
	register struct	arp	*parp;
	struct	ep		*pep;

	pep = (struct ep *) getbuf(Net.netpool);
	if ((int)pep == SYSERR)
		return (struct ep *)SYSERR;
	memcpy(pep->ep_dst, nif[ifn].ni_hwb.ha_addr, EP_ALEN);
	pep->ep_order = ~0;
	pep->ep_type = type;
	parp = (struct arp *)pep->ep_data;
	parp->ar_hwtype = hs2net(AR_HARDWARE);
	parp->ar_prtype = hs2net(EPT_IP);
	parp->ar_hwlen = EP_ALEN;
	parp->ar_prlen = IP_ALEN;
	parp->ar_op = hs2net(op);
	memcpy(SHA(parp), nif[ifn].ni_hwa.ha_addr, EP_ALEN);
	memcpy(SPA(parp), &spa, IP_ALEN);
	memcpy(THA(parp), nif[ifn].ni_hwa.ha_addr, EP_ALEN);
	memcpy(TPA(parp), &tpa, IP_ALEN);
	return pep;
}
示例#5
0
static B jtspsscell(J jt,A w,I wf,I wcr,A*zc,A*zt){A c,t,y;B b;
     I cn,*cv,j,k,m,n,p,*s,tn,*tv,*u,*u0,*v,*v0;P*wp;
 wp=PAV(w); s=AS(w); p=3+s[wf];
 y=SPA(wp,i); s=AS(y); m=s[0]; n=s[1];
 u0=AV(y); u=u0+n; 
 v0=u0+wf; v=v0+n;
 if(!m){*zt=*zc=mtv; R 1;}
 GATV(t,INT,2+2*m,1,0); tv=AV(t); tv[0]=tv[1]=0; tn=2;
 GATV(c,INT,  2*m,2,0); cv=AV(c); cv[0]=0;       cn=0; *(1+AS(c))=2;
 for(j=1;j<m;++j){
  b=1;
  for(k=0;k<wf;++k)
   if(u0[k]!=u[k]){
    tv[tn++]=j; tv[tn++]=j; cv[1+cn]=tn-cv[cn];
    if(p==tn-cv[cn]){++cv[cn]; cv[1+cn]-=2;} 
    cn+=2;
    cv[cn]=tn-2; u0=u; v0=v; b=0;
    break;
   }
  if(b&&*v0!=*v){tv[tn++]=j; v0=v;}
  u+=n; v+=n;
 }
 tv[tn++]=m; tv[tn++]=m; cv[1+cn]=tn-cv[cn];
 if(p==tn-cv[cn]){++cv[cn]; cv[1+cn]-=2;}
 cn+=2;
 AN(t)=    *AS(t)=tn;   *zt=t;  /* cell divisions (row indices in y)            */
 AN(c)=cn; *AS(c)=cn/2; *zc=c;  /* item divisions (indices in t, # of elements) */
 R 1;
}    /* frame: all sparse; cell: 1 or more sparse, then dense */
示例#6
0
文件: vrep.c 项目: adrian17/jsource
static REPF(jtrepzdx){A p,q,x;P*wp;
 RZ(a&&w);
 if(SPARSE&AT(w)){wp=PAV(w); x=SPA(wp,e);}
 else x=jt->fill&&AN(jt->fill)?jt->fill:filler(w);
 RZ(p=repeat(ravel(rect(a)),ravel(stitch(IX(wcr?*(wf+AS(w)):1),num[-1]))));
 RZ(q=irs2(w,x,0L,wcr,0L,jtover));
 R irs2(p,q,0L,1L,wcr+!wcr,jtfrom);
}    /* (dense complex) # (dense or sparse) */
示例#7
0
文件: vcant.c 项目: EdKeith/core
static A jtcants(J jt,A a,A w,A z){A a1,q,y;B*b,*c;I*u,wr,zr;P*wp,*zp;
 RZ(a&&w&&z);
 RZ(a=grade1(a));
 wr=AR(w); wp=PAV(w); a1=SPA(wp,a);
 zr=AR(z); zp=PAV(z);
 ASSERT(wr==zr,EVNONCE);
 RZ(b=bfi(wr,a1,1));
 GA(q,B01,wr,1,0); c=BAV(q); u=AV(a); DO(wr, c[i]=b[u[i]];);
示例#8
0
SUFFIX_TREE* ST_CreateTree(const char* str, DBL_WORD length)
{
   SUFFIX_TREE*  tree;
   DBL_WORD      phase , extension;
   char          repeated_extension = 0;
   POS           pos;

   if(str == 0)
      return 0;

   /* Allocating the tree */
   tree = malloc(sizeof(SUFFIX_TREE));
   if(tree == 0)
   {
      printf("\nOut of memory.\n");
      exit(0);
   }
   heap+=sizeof(SUFFIX_TREE);

   /* Calculating string length (with an ending $ sign) */
   tree->length         = length+1;
   ST_ERROR            = length+10;
   
   /* Allocating the only real string of the tree */
   tree->tree_string = malloc((tree->length+1)*sizeof(char));
   if(tree->tree_string == 0)
   {
      printf("\nOut of memory.\n");
      exit(0);
   }
   heap+=(tree->length+1)*sizeof(char);

   memcpy(tree->tree_string+sizeof(char),str,length*sizeof(char));
   /* $ is considered a uniqe symbol */
   tree->tree_string[tree->length] = '$';
   
   /* Allocating the tree root node */
   tree->root            = create_node(0, 0, 0, 0);
   tree->root->suffix_link = 0;

   /* Initializing algorithm parameters */
   extension = 2;
   phase = 2;
   
   /* Allocating first node, son of the root (phase 0), the longest path node */
   tree->root->sons = create_node(tree->root, 1, tree->length, 1);
   suffixless       = 0;
   pos.node         = tree->root;
   pos.edge_pos     = 0;

   /* Ukkonen's algorithm begins here */
   for(; phase < tree->length; phase++)
   {
      /* Perform Single Phase Algorithm */
      SPA(tree, &pos, phase, &extension, &repeated_extension);
   }
   return tree;
}
示例#9
0
int main()
{
	int test,m,a,b,c;
	scanf("%d",&test);
	while(test--)
	{
		scanf("%d%d",&n,&m);
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				dis[i][j] = MAX;
		int spow = 0;
		for(int i=0;i<m;i++)
		{
			scanf("%d%d%d",&a,&b,&c);
			if(dis[a][b]>c)
			{
				dis[a][b] = c;
				dis[b][a] = c;
			}	
		}
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&pow[i]);
			spow += pow[i];
		}
		SPA();
			for(int j=0;j<=spow;j++)
				mn[j] = MAX;
		mn[0] = 0;
		int curm = 0;
		int hpow = spow/2+1;
		int ans = MAX;
/*		for(int i=1;i<=n;i++)
			printf("%d ",mdis[i]);
			printf("%d\n",hpow);
*/
		for(int i=1;i<=n;i++)
		{
			if(mdis[i]>=MAX)continue;
			for(int j=curm;j>=0;j--)
			{
				if(mn[j] == MAX)continue;
				if(mdis[i] + mn[j] < mn[j+pow[i]])
				{
					mn[j+pow[i]] = mdis[i] + mn[j];	
					if(j+pow[i]>=hpow)
						if(mn[j+pow[i]]<ans)
							ans = mn[j+pow[i]];
				}	
			}
			curm += pow[i];
		}
		if(ans < MAX)
			printf("%d\n",ans);
		else printf("impossible\n");
	}
	return 0;
}
示例#10
0
template <int i1, int i2, int i3, int i4, int i5, int i6, class T> complex<T>  A2q2Q2l_qmqb2mq2pqbplmlbp_eval(const eval_param<T>& ep, const mass_param_coll& masses)
{
const complex<T> spb56=SPB(i5,i6);
const complex<T> spb46=SPB(i4,i6);
const complex<T> spb43=SPB(i4,i3);
const complex<T> spb42=SPB(i4,i2);
const complex<T> spb34=SPB(i3,i4);
const complex<T> spb32=SPB(i3,i2);
const complex<T> spb31=SPB(i3,i1);
const complex<T> spb23=SPB(i2,i3);
const complex<T> spb21=SPB(i2,i1);
const complex<T> spa56=SPA(i5,i6);
const complex<T> spa34=SPA(i3,i4);
const complex<T> spa24=SPA(i2,i4);
const complex<T> spa23=SPA(i2,i3);
const complex<T> spa15=SPA(i1,i5);
const complex<T> spa13=SPA(i1,i3);
const complex<T> spa12=SPA(i1,i2);
const complex<T> pow2_spb46=(pow(spb46,2));
const complex<T> pow2_spb34=(pow(spb34,2));
const complex<T> pow2_spa15=(pow(spa15,2));
const complex<T> pow2_spa12=(pow(spa12,2));
const complex<T> spab_1_23_4=-(spa12*spb42)-spa13*spb43;
const complex<T> s234=(spa23*spb32+spa24*spb42+spa34*spb43);
const complex<T> s123=(spa12*spb21+spa13*spb31+spa23*spb32);

return(
((pow2_spa15*pow2_spb34)/(s234*spa56*spab_1_23_4*spb23)
-
(pow2_spa12*pow2_spb46)/(s123*spa23*spab_1_23_4*spb56))*complex<T>(0,1)
);
}
示例#11
0
文件: arpwatch.c 项目: einyx/arpwatch
void
process_fddi(register u_char *u, register const struct pcap_pkthdr *h,
    register const u_char *p)
{
	register struct fddi_header *fh;
	register struct ether_arp *ea;
	register u_char *sea, *sha;
	register time_t t;
	u_int32_t sia;

	fh = (struct fddi_header *)p;
	ea = (struct ether_arp *)(fh + 1);

	if (!swapped) {
		bit_reverse(fh->src, 6);
		bit_reverse(fh->dst, 6);
	}
	if (!sanity_fddi(fh, ea, h->caplen))
		return;

	/* Source MAC hardware ethernet address */
	sea = (u_char *)fh->src;

	/* Source ARP ethernet address */
	sha = (u_char *)SHA(ea);

	/* Source ARP ip address */
	BCOPY(SPA(ea), &sia, 4);

	/* Watch for bogons */
	if (isbogon(sia)) {
		dosyslog(LOG_INFO, "bogon", sia, sea, sha);
		return;
	}

	/* Watch for ethernet broadcast */
	if (MEMCMP(sea, zero, 6) == 0 || MEMCMP(sea, allones, 6) == 0 ||
	    MEMCMP(sha, zero, 6) == 0 || MEMCMP(sha, allones, 6) == 0) {
		dosyslog(LOG_INFO, "ethernet broadcast", sia, sea, sha);
		return;
	}

	/* Double check ethernet addresses */
	if (MEMCMP(sea, sha, 6) != 0) {
		dosyslog(LOG_INFO, "ethernet mismatch", sia, sea, sha);
		return;
	}

	/* Got a live one */
	t = h->ts.tv_sec;
	can_checkpoint = 0;
	if (!ent_add(sia, sea, t, NULL))
		syslog(LOG_ERR, "ent_add(%s, %s, %ld) failed",
		    intoa(sia), e2str(sea), t);
	can_checkpoint = 1;
}
示例#12
0
文件: vrep.c 项目: iocane/unbox
static REPF(jtrepzsx) {
    A q,x,y;
    I c,d,j,k=-1,m,p=0,*qv,*xv,*yv;
    P*ap;
    RZ(a&&w);
    ap=PAV(a);
    x=SPA(ap,x);
    m=AN(x);
    if(!AN(SPA(ap,a)))R repzdx(ravel(x),w,wf,wcr);
    y=SPA(ap,i);
    yv=AV(y);
    RZ(x=cvt(INT,vec(FL,2*m,AV(x))));
    xv=AV(x);
    if(equ(zero,SPA(ap,e))) {
        k=c=*(wf+AS(w));
        if(!wf&&SPARSE&AT(w)) {
            A a,y;
            I m,n,q,*v;
            P*wp;
            wp=PAV(w);
            a=SPA(wp,a);
            if(AN(a)&&!*AV(a)) {
                y=SPA(wp,i);
                v=AS(y);
                m=v[0];
                n=v[1];
                v=AV(y);
                k=m?v[(m-1)*n]+1:0;
                q=0;
                DO(m, if(q==*v)++q; else if(q<*v) {
                    k=q;
                    break;
                }
            v+=n;);
            }
示例#13
0
/*------------------------------------------------------------------------
 * arpadd - Add a RESOLVED entry to the ARP cache
 * 	N.B. Assumes interrupts disabled
 *------------------------------------------------------------------------
 */
struct	arpentry *
arpadd(struct netif *pni, struct arp *parp)
{
	struct	arpentry	*pae;

	pae = arpalloc();

	pae->ae_hwtype = parp->ar_hwtype;
	pae->ae_prtype = parp->ar_prtype;
	pae->ae_hwlen = parp->ar_hwlen;
	pae->ae_prlen = parp->ar_prlen;
	pae->ae_pni = pni;
	pae->ae_queue = EMPTY;
	memcpy(pae->ae_hwa, SHA(parp), parp->ar_hwlen);
	memcpy(pae->ae_pra, SPA(parp), parp->ar_prlen);
	pae->ae_ttl = ARP_TIMEOUT;
	pae->ae_state = AS_RESOLVED;
	return pae;
}
示例#14
0
template <class T> complex<T>  A_qGGqy_mmppp_eval(const eval_param<T>& ep, const mass_param_coll& masses){
 return(   (complex<T>(0,-1)*pow(SPA(2,1),2))/(SPA(3,2)*
SPA(5,1)*SPA(5,4))
); }
示例#15
0
  if(i==*v){s=av[u-u0]; t=wv[v-v0]; z+=s&&t?s*t:0; ++u; ++v; continue;}
  i=*v; while(i>*u&&u<uu)++u; if(u==uu)break;
  if(i==*u){s=av[u-u0]; t=wv[v-v0]; z+=s&&t?s*t:0; ++u; ++v; continue;}
 }
 NAN1;
 R scf(z);
}

static F2(jtpdtspmv){A ax,b,g,x,wx,y,yi,yj,z;B*bv;I m,n,s[2],*u,*v,*yv;P*ap,*wp,*zp;
 RZ(a&&w);
 ap=PAV(a); y=SPA(ap,i); yv=AV(y); s[0]=n=*AS(y); s[1]=1;
 GATV(yj,INT,n,2,s);
 if(DENSE&AT(w)){
  GATV(yi,INT,n,2,s); u=AV(yi); AR(yj)=1; v=AV(yj);
  DO(n, *u++=*yv++; *v++=*yv++;);
  ax=SPA(ap,x); RZ(wx=from(yj,w));
 }else{
  v=AV(yj);
  DO(n, yv++; *v++=*yv++;);
  wp=PAV(w); RZ(b=eps(yj,SPA(wp,i))); bv=BAV(b); 
  AN(yj)=*AS(yj)=*s=m=bsum(n,bv); v=AV(yj); yv=AV(y);
  GATV(yi,INT,m,2,s); u=AV(yi);
  DO(n, if(*bv++){*u++=*yv++; *v++=*yv++;}else yv+=2;);
  RZ(ax=repeat(b,SPA(ap,x))); RZ(wx=from(indexof(SPA(wp,i),yj),SPA(wp,x))); 
 }
 RZ(x=df2(yi,tymes(ax,wx),sldot(slash(ds(CPLUS)))));
 RZ(y=nub(yi));
 RZ(g=grade1(y));
 GA(z,STYPE(AT(x)),1,1,AS(a)); zp=PAV(z);
 SPB(zp,a,iv0);
 SPB(zp,e,scf(0.0));
示例#16
0
template <class T> complex<T> A_qqGGy_mpmpp_eval(const eval_param<T>& ep, const mass_param_coll& masses){
 return(  (complex<T>(0,-1)*pow(SPA(1,3),2))/
 (SPA(1,5)*SPA(2,5)*SPA(3,4))
 ); }
示例#17
0
void
arp_print(netdissect_options *ndo,
	  const u_char *bp, u_int length, u_int caplen)
{
	const struct arp_pkthdr *ap;
	u_short pro, hrd, op, linkaddr;

	ap = (const struct arp_pkthdr *)bp;
	ND_TCHECK(*ap);

	hrd = HRD(ap);
	pro = PRO(ap);
	op = OP(ap);

        
        /* if its ATM then call the ATM ARP printer
           for Frame-relay ARP most of the fields
           are similar to Ethernet so overload the Ethernet Printer
           and set the linkaddr type for linkaddr_string() accordingly */

        switch(hrd) {
        case ARPHRD_ATM2225:
            atmarp_print(ndo, bp, length, caplen);
            return;
        case ARPHRD_FRELAY:
            linkaddr = LINKADDR_FRELAY;
            break;
        default:
            linkaddr = LINKADDR_ETHER;
            break;
	}

	if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) {
		ND_PRINT((ndo, "[|ARP]"));
		ND_DEFAULTPRINT((const u_char *)ap, length);
		return;
	}

        if (!ndo->ndo_eflag) {
            ND_PRINT((ndo, "ARP, "));
        }

        /* print hardware type/len and proto type/len */
        if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||
	    PROTO_LEN(ap) != 4 ||
            HRD_LEN(ap) == 0 ||
            ndo->ndo_vflag) {
            ND_PRINT((ndo, "%s (len %u), %s (len %u)",
                      tok2str(arphrd_values, "Unknown Hardware (%u)", hrd),
                      HRD_LEN(ap),
                      tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro),
                      PROTO_LEN(ap)));

            /* don't know know about the address formats */
            if (!ndo->ndo_vflag) {
                goto out;
            }
	}

        /* print operation */
        printf("%s%s ",
               ndo->ndo_vflag ? ", " : "", 
               tok2str(arpop_values, "Unknown (%u)", op));

	switch (op) {

	case ARPOP_REQUEST:
		ND_PRINT((ndo, "who-has %s", ipaddr_string(TPA(ap))));
		if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0)
			ND_PRINT((ndo, " (%s)",
				  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap))));
		ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap))));
		break;

	case ARPOP_REPLY:
		ND_PRINT((ndo, "%s is-at %s",
                          ipaddr_string(SPA(ap)),
                          linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
		break;

	case ARPOP_REVREQUEST:
		ND_PRINT((ndo, "who-is %s tell %s",
			  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
			  linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
		break;

	case ARPOP_REVREPLY:
		ND_PRINT((ndo, "%s at %s",
			  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
			  ipaddr_string(TPA(ap))));
		break;

	case ARPOP_INVREQUEST:
		ND_PRINT((ndo, "who-is %s tell %s",
			  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
			  linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
		break;

	case ARPOP_INVREPLY:
		ND_PRINT((ndo,"%s at %s",
			  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
			  ipaddr_string(TPA(ap))));
		break;

	default:
		ND_DEFAULTPRINT((const u_char *)ap, caplen);
		return;
	}

 out:
        ND_PRINT((ndo, ", length %u", length));

	return;
trunc:
	ND_PRINT((ndo, "[|ARP]"));
}
示例#18
0
void
arp_print(register const u_char *bp, u_int length, u_int caplen)
{
	register const struct ether_arp *ap;
	register const struct ether_header *eh;
	register u_short pro, hrd, op;

	ap = (struct ether_arp *)bp;
	if ((u_char *)(ap + 1) > snapend) {
		printf("[|arp]");
		return;
	}
	if (length < sizeof(struct ether_arp)) {
		(void)printf("truncated-arp");
		default_print((u_char *)ap, length);
		return;
	}

	pro = EXTRACT_16BITS(&ap->arp_pro);
	hrd = EXTRACT_16BITS(&ap->arp_hrd);
	op = EXTRACT_16BITS(&ap->arp_op);

	if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
	    || ap->arp_hln != sizeof(SHA(ap))
	    || ap->arp_pln != sizeof(SPA(ap))) {
		(void)printf("arp-#%d for proto #%d (%d) hardware #%d (%d)",
				op, pro, ap->arp_pln,
				hrd, ap->arp_hln);
		return;
	}
	if (pro == ETHERTYPE_TRAIL)
		(void)printf("trailer-");
	eh = (struct ether_header *)packetp;
	switch (op) {

	case ARPOP_REQUEST:
		(void)printf("arp who-has %s", ipaddr_string(TPA(ap)));
		if (memcmp((char *)ezero, (char *)THA(ap), 6) != 0)
			(void)printf(" (%s)", etheraddr_string(THA(ap)));
		(void)printf(" tell %s", ipaddr_string(SPA(ap)));
		if (memcmp((char *)ESRC(eh), (char *)SHA(ap), 6) != 0)
			(void)printf(" (%s)", etheraddr_string(SHA(ap)));
		break;

	case ARPOP_REPLY:
		(void)printf("arp reply %s", ipaddr_string(SPA(ap)));
		if (memcmp((char *)ESRC(eh), (char *)SHA(ap), 6) != 0)
			(void)printf(" (%s)", etheraddr_string(SHA(ap)));
		(void)printf(" is-at %s", etheraddr_string(SHA(ap)));
		if (memcmp((char *)EDST(eh), (char *)THA(ap), 6) != 0)
			(void)printf(" (%s)", etheraddr_string(THA(ap)));
		break;

	case REVARP_REQUEST:
		(void)printf("rarp who-is %s tell %s",
			etheraddr_string(THA(ap)),
			etheraddr_string(SHA(ap)));
		break;

	case REVARP_REPLY:
		(void)printf("rarp reply %s at %s",
			etheraddr_string(THA(ap)),
			ipaddr_string(TPA(ap)));
		break;

	default:
		(void)printf("arp-#%d", op);
		default_print((u_char *)ap, caplen);
		return;
	}
	if (hrd != ARPHRD_ETHER)
		printf(" hardware #%d", hrd);
}
示例#19
0
SuffixTree_T SuffixTree_create(char* str, size_t length)
{
   SuffixTree_T tree;
   SuffixTreeIndex_T phase , extension;
   char repeated_extension = 0;
   struct SuffixTreePos pos;

   if(str == NULL) return NULL;

   /* Allocating the tree */
   tree = malloc(sizeof(struct SuffixTree_T));
   check_mem(tree);

   tree->root = NULL;

   /* Calculating string length (with an ending terminator) */
   tree->length = length+1;
   
   /* Allocating the only real string of the tree */
   tree->tree_string = malloc((tree->length+1)*sizeof(char));
   check_mem(tree->tree_string);

   memcpy(tree->tree_string+sizeof(char),str,length*sizeof(char));

   tree->tree_string[tree->length] = '$';
   
   /* Allocating the tree root node */
   tree->root = create_node(0, 0, 0, 0);
   check(tree->root, "Creation of tree root failed.");

   tree->root->suffix_link = NULL;
   tree->e = 0;

   /* Initializing algorithm parameters */
   extension = 2;
   phase = 2;
   
   /* Allocating first node, son of the root (phase 0), the longest path node */
   tree->root->left_son = create_node(tree->root, 1, tree->length, 1);
   check(tree->root->left_son, "Node creation failed.");

   suffixless       = NULL;
   pos.node         = tree->root;
   pos.edge_pos     = 0;

   /* Ukkonen's algorithm begins here */
   int success = 0;
   for(; phase < tree->length; phase++)
   {
      /* Perform Single Phase Algorithm */
      success = SPA(tree, &pos, phase, &extension, &repeated_extension);
   }
   check(success == 0, "Ukkonen's suffix tree construction algorithm failed.");

   SuffixTreeIndex_T counter = 0;
   label_nodes(tree->root, tree, &counter, 0);
   tree->num_nodes = counter;
   return tree;

error:
   SuffixTree_delete(&tree);
   return NULL;
}
示例#20
0
文件: vcant.c 项目: EdKeith/core
#include "j.h"

static F2(jtcanta);

static A jtcants(J jt,A a,A w,A z){A a1,q,y;B*b,*c;I*u,wr,zr;P*wp,*zp;
 RZ(a&&w&&z);
 RZ(a=grade1(a));
 wr=AR(w); wp=PAV(w); a1=SPA(wp,a);
 zr=AR(z); zp=PAV(z);
 ASSERT(wr==zr,EVNONCE);
 RZ(b=bfi(wr,a1,1));
 GA(q,B01,wr,1,0); c=BAV(q); u=AV(a); DO(wr, c[i]=b[u[i]];);
 SPB(zp,a,ifb(wr,c));
 SPB(zp,e,ca(SPA(wp,e)));
 RZ(y=fromr(grade1(indexof(a,a1)),SPA(wp,i)));
 RZ(q=grade1(y));
 SPB(zp,i,from(q,y));
 SPB(zp,x,from(q,canta(over(zero,increm(grade1(less(a,a1)))),SPA(wp,x))));
 R z;
}    /* w is sparse */

#define CANTA(T,exp)  \
 {T*u=(T*)zv,*v=(T*)wv;                                                  \
  DO(zn, exp; j=r-1; ++tv[j]; d+=mv[j];                                  \
  while(j&&sv[j]==tv[j]){d+=mv[j-1]-mv[j]*sv[j]; tv[j]=0; ++tv[--j];});  \
 }

static F2(jtcanta){A m,s,t,z;B b;C*wv,*zv;I*av,c,d,j,k,*mv,r,*sv,*tv,wf,wr,*ws,zn,zr;
 RZ(a&&w);
 av=AV(a); ws=AS(w); wr=AR(w); r=jt->rank?jt->rank[1]:wr; jt->rank=0;
示例#21
0
template <class T> complex<T> A_GGqqy_mpmpp_eval(const eval_param<T>& ep, const mass_param_coll& masses){
 return(  (complex<T>(0,-1)*pow(SPA(3,1),2))/
 (SPA(3,5)*SPA(4,5)*SPA(1,2))
 ); }