void *Z_Realloc(void *ptr, size_t n, int tag, void **user) { void *p = (Z_Malloc)(n, tag, user DA(file, line)); if (ptr) { memblock_t *block = (memblock_t *)((uint8_t*) ptr - HEADER_SIZE); memcpy(p, ptr, n <= block->size ? n : block->size); (Z_Free)(ptr DA(file, line)); if (user) // in case Z_Free nullified same user *user=p; } return p; }
double QuadQuality(const Vertex & a,const Vertex &b,const Vertex &c,const Vertex &d) { // calcul de 4 angles -- R2 A((R2)a),B((R2)b),C((R2)c),D((R2)d); R2 AB(B-A),BC(C-B),CD(D-C),DA(A-D); // Move(A),Line(B),Line(C),Line(D),Line(A); const Metric & Ma = a; const Metric & Mb = b; const Metric & Mc = c; const Metric & Md = d; double lAB=Norme2(AB); double lBC=Norme2(BC); double lCD=Norme2(CD); double lDA=Norme2(DA); AB /= lAB; BC /= lBC; CD /= lCD; DA /= lDA; // version aniso double cosDAB= Ma(DA,AB)/(Ma(DA)*Ma(AB)),sinDAB= Det(DA,AB); double cosABC= Mb(AB,BC)/(Mb(AB)*Mb(BC)),sinABC= Det(AB,BC); double cosBCD= Mc(BC,CD)/(Mc(BC)*Mc(CD)),sinBCD= Det(BC,CD); double cosCDA= Md(CD,DA)/(Md(CD)*Md(DA)),sinCDA= Det(CD,DA); double sinmin=Min(Min(sinDAB,sinABC),Min(sinBCD,sinCDA)); // cout << A << B << C << D ; // cout << " sinmin " << sinmin << " " << cosDAB << " " << cosABC << " " << cosBCD << " " << cosCDA << endl; // rattente(1); if (sinmin<=0) return sinmin; return 1.0-Max(Max(Abs(cosDAB),Abs(cosABC)),Max(Abs(cosBCD),Abs(cosCDA))); }
void *(Z_Realloc)(void *ptr, size_t n, int tag, void **user #ifdef INSTRUMENTED , const char *file, int line #endif ) { void *p = (Z_Malloc)(n, tag, user DA(file, line)); if (ptr) { memblock_t *block = (memblock_t *)((char *) ptr - HEADER_SIZE); memcpy(p, ptr, n <= block->size ? n : block->size); (Z_Free)(ptr DA(file, line)); if (user) // in case Z_Free nullified same user *user=p; } return p; }
char *(Z_Strdup)(const char *s, int tag, void **user #ifdef INSTRUMENTED , const char *file, int line #endif ) { return strcpy((Z_Malloc)(strlen(s)+1, tag, user DA(file, line)), s); }
virtual int draw(Pint _pos,bool _active=true,dxDMode _mode=dxDMode()){ // dx::TmpGlobalStd gstd(_pos+dx::getGlobalStd()); dx::TmpDrawArea DA(dxDArea(Rint(_pos,_pos+size))&dx::getDrawArea()); // dx::TmpDrawMode DM(_mode+dx::getDrawMode()); // dx::draw(_pos,dxoBox(size,dxHLS(0,128,128)),128); dxO dxo(_pos,_active,_mode,this); return (*pDrawFunc)(dxo); }
inline DA _convert_array_from_variant(const Variant& p_variant) { switch(p_variant.get_type()) { case Variant::ARRAY: { return _convert_array<DA,Array >( p_variant.operator Array () ); } case Variant::RAW_ARRAY: { return _convert_array<DA,DVector<uint8_t> >( p_variant.operator DVector<uint8_t> () ); } case Variant::INT_ARRAY: { return _convert_array<DA,DVector<int> >( p_variant.operator DVector<int> () ); } case Variant::REAL_ARRAY: { return _convert_array<DA,DVector<real_t> >( p_variant.operator DVector<real_t> () ); } case Variant::STRING_ARRAY: { return _convert_array<DA,DVector<String> >( p_variant.operator DVector<String> () ); } case Variant::VECTOR2_ARRAY: { return _convert_array<DA,DVector<Vector2> >( p_variant.operator DVector<Vector2> () ); } case Variant::VECTOR3_ARRAY: { return _convert_array<DA,DVector<Vector3> >( p_variant.operator DVector<Vector3> () ); } case Variant::COLOR_ARRAY: { return _convert_array<DA,DVector<Color> >( p_variant.operator DVector<Color>() ); } default: { return DA(); } } return DA(); }
void *(Z_Calloc)(size_t n1, size_t n2, int tag, void **user #ifdef INSTRUMENTED , const char *file, int line #endif ) { return (n1*=n2) ? memset((Z_Malloc)(n1, tag, user DA(file, line)), 0, n1) : NULL; }
virtual int draw(Pint _pos,bool _active=true,dxDMode _mode=dxDMode()){ if(!_active)_mode+=Passive; dx::drawBox(_pos,_pos+size,Clr,1,_mode+In); dx::drawBox(_pos,_pos+size,Clr,0,_mode+Out); dx::drawBox(_pos+Pint(0,dx::getFontSize()*-1),_pos+Pint(size.x,0),Clr,1,_mode+Out); dx::drawStr(_pos+Pint(2,dx::getFontSize()*-1),name,dxRGB(255,255,255),_mode+Out); dx::TmpDrawArea DA(dxDArea(Rint(_pos,_pos+size))&dx::getDrawArea()); dxO dxo(_pos,_active,_mode,this); return drawIn(dxo,pDrawFunc); }
SuffixArray(string _a, int m) : a(" " + _a), N(a.length()), m(m), SA(N), LCP(N), x(N), y(N), w(max(m, N)), c(N) { a[0] = 0; DA(); kasaiLCP(); #define REF(X) { rotate(X.begin(), X.begin()+1, X.end()); X.pop_back(); } REF(SA); REF(LCP); a = a.substr(1, a.size()); for(int i = 0; i < (int) SA.size(); ++i) --SA[i]; #undef REF }
virtual int draw(Pint _pos,bool _active=true,dxDMode _mode=dxDMode()){ // if(status<0)return 0; // else if(status==0)_mode+=Passive; if(!_active)_mode+=Passive; dx::drawBox(_pos,_pos+size,Clr,1,_mode+In); dx::drawBox(_pos,_pos+size,Clr,0,_mode+Out); dx::TmpDrawArea DA(dxDArea(Rint(_pos,_pos+size))&dx::getDrawArea()); // dxO dxo(_pos,_mode,status>0,this); dxO dxo(_pos,_active,_mode,this); return drawIn(dxo,pDrawFunc); }
int main() { int i,j,k,len,maxlen; int l,r,mid; freopen("poj3294.txt","r",stdin); freopen("poj3294ans.txt","w",stdout); while (scanf("%d",&n) && n) { scanf("%s",s[0]); sum[0]=strlen(s[0]); maxlen=sum[0]; if (n==1) { printf("%s\n\n",s[0]); continue; } for (i=1;i<n;i++) { scanf("%s",s[i]); sum[i]=sum[i-1]+strlen(s[i])+1; } k=0; for (i=0;i<n;i++) { len=strlen(s[i]); for (j=0;j<len;j++) num[k++]=s[i][j]-'a'+100; num[k++]=i; } m=k-1; DA(num,sa,rank,k,130); CalcHeight(num,sa,height,k-1); l=0; r=m; while (l<r) { mid=(l+r+1)/2; if (Check(mid,0)) l=mid; else r=mid-1; } if (l==0) printf("?\n\n"); else { Check(l,1); printf("\n"); } } return 0; }
void decode(const char *str) { char at = START; while(*str){ if (*str == '.') at = DO(at); else if (*str == '-') at = DA(at); else { if (at != START) putchar(at); at = START; }; ++str; }; if (at != START) putchar(at); putchar('\n'); }
int main() { int n,i,j; freopen("poj3581.txt","r",stdin); freopen("poj3581ans.txt","w",stdout); scanf("%d",&n); for (i=n-1; i>=0; i--) { scanf("%d",&s[i]); dat[i].data=s[i]; dat[i].id=i; } QSort(0,n-1); tmp[0]=1; for (i=1; i<n; i++) if (dat[i].data==dat[i-1].data) tmp[i]=tmp[i-1]; else tmp[i]=i+1; for (i=0; i<n; i++) num[dat[i].id]=tmp[i]; num[n]=0; DA(num,sa,rank,n+1,n+5); //找第一节 for (i=1; i<=n; i++) if (sa[i]>1) break; Print(sa[i],n-1); //剩下的部分复制一次在后面 for (j=0; j<sa[i]; j++) num[sa[i]+j]=num[j]; n=2*sa[i]; num[n]=0; DA(num,sa,rank,n+1,n+5); for (i=1; i<=n; i++) if (sa[i]<n/2 && sa[i]>0) break; Print(sa[i],n/2-1); Print(0,sa[i]-1); return 0; }
int main() { int i; freopen("poj3261.txt","r",stdin); freopen("poj3261ans.txt","w",stdout); while (scanf("%d%d",&n,&k)!=EOF) { for (i=0;i<n;i++) scanf("%d",&num[i]); num[n]=0; DA(num,sa,rank,n+1,10000); CalcHeight(num,sa,height,n); BinSearch(1,n); printf("%d\n",ans); } }
int main(){ int N,K,i,Ans=0; scanf("%d%d",&N,&K); for(i=0;i<N;++i) scanf("%d",s+i); DA(s,SA,N,Rank=tmparray[0],tmparray[1],tmparray[2],tmparray[3]); GetHeight(s,Height,SA,Rank,N); std::deque<int*> q; --K; for(i=0;i<=N;++i){ while(!q.empty()&&*q.back()>Height[i]) q.pop_back(); q.push_back(Height+i); if(Height+(i-K)==q.front()) q.pop_front(); if(i>K&&!q.empty()) maxi(Ans,*q.front()); } printf("%d\n",Ans); }
int hyphy20g_init(struct file *sHandle, int optLoopback) { char drvconf[256] = DRV_CONF_FILE; struct file *conf_file = NULL; char cfgbuf[512]; int cfglen = 0; mm_segment_t old_fs; // first of all get the configuration for pos conf_file = filp_open(drvconf, O_RDONLY, 0); if (IS_ERR(conf_file)) { DA((KERN_ERR "Error reading qnf_mc20p.conf!\n")); } else { old_fs = get_fs(); set_fs(KERNEL_DS); cfglen = conf_file->f_op->read(conf_file, cfgbuf, 1024, &conf_file->f_pos); cfgbuf[cfglen] = '\0'; set_fs(old_fs); } if (conf_file != NULL) filp_close(conf_file, NULL); sscanf(cfgbuf, "%u, %u, %u, %u, %u, %u", &mc20p_lineType, &mc20p_sonetScram, &mc20p_payloadScram, &mc20p_fcsMode, &mc20p_minPkt, &mc20p_maxPkt); initHyphy20gGlobal(sHandle); initHyphy20g(sHandle, mc20p_lineType, 0, optLoopback); clientProv(sHandle, 0, mc20p_lineType); clientProv(sHandle, 1, mc20p_lineType); return 0; }
void suffixArray () { m = 256; N = strlen (str); DA (); kasaiLCP (); }
static INT4 DataPathEnable(struct file *sHandle, INT4 lineType, INT4 cpblp) { INT4 type = 4; int chan, pifChan, lineChan; // it's for 10GE line interface if (lineType == 0) { // no loopback if (cpblp == 0) { for (chan = 0; chan < 2; chan++) { pifChan = chan + 147 + 1; lineChan = chan + 16; if(hyPhy20gCpbChnlProv(sHandle, 128, lineChan, 0, pifChan, 0, 1, 640, 1280, 1920, 0, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlProv failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlEnable(sHandle, lineChan) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlEnable failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlProv(sHandle, 128, pifChan, 0, lineChan, 0, 1, 640, 1280, 1920, type, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlProv failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlEnable(sHandle, pifChan) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlEnable failed!\n")); return -EFAULT; } } // for (chan = 0; chan < 2; chan++) } // if (cpblp == 0) else { for (chan = 0; chan < 2; chan++) { pifChan = chan + 147 + 1; lineChan = chan + 16; if(hyPhy20gCpbChnlProv(sHandle, 128, lineChan, 0, lineChan, 0, 1, 640, 1280, 1920, 0, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlProv failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlEnable(sHandle, lineChan) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlEnable failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlProv(sHandle, 128, pifChan, 0, pifChan, 0, 1, 640, 1280, 1920, type, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlProv failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlEnable(sHandle, pifChan) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlEnable failed!\n")); return -EFAULT; } } // for (chan = 0; chan < 2; chan++) } } else if (lineType == 2) { // no loopback if (cpblp == 0) { for (chan = 0; chan < 2; chan++) { pifChan = chan + 147 + 1; lineChan = (chan == 0) ? 19 : 83; if(hyPhy20gCpbChnlProv(sHandle, 64, lineChan, 0, pifChan, 0, 1, 320, 640, 960, 0, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlProv failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlEnable(sHandle, lineChan) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlEnable failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlProv(sHandle, 64, pifChan, 0, lineChan, 0, 1, 320, 640, 960, type, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlProv failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlEnable(sHandle, pifChan) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlEnable failed!\n")); return -EFAULT; } #if 0 if(hyPhy20gWrite(sHandle, 0x4928344 + (pifChan - 147) * 4, ((3 << 1) + 1)) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gWrite failed!\n")); return -EFAULT; } #endif } // for (chan = 0; chan < 2; chan++) } else { for (chan = 0; chan < 2; chan++) { pifChan = chan + 147 + 1; lineChan = (chan == 0) ? 19 : 83; if(hyPhy20gCpbChnlProv(sHandle, 64, lineChan, 0, lineChan, 0, 1, 320, 640, 960, 0, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlProv failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlEnable(sHandle, lineChan) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlEnable failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlProv(sHandle, 64, pifChan, 0, pifChan, 0, 1, 320, 640, 960, type, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlProv failed!\n")); return -EFAULT; } if(hyPhy20gCpbChnlEnable(sHandle, pifChan) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[DataPathEnable]: hyPhy20gCpbChnlEnable failed!\n")); return -EFAULT; } // if (hyPhy20gCpb } // for (chan = 0; chan < 2; chan++) } } return HYPHY20G_SUCCESS; }
static INT4 gfpConfig(struct file *sHandle, INT4 xfislice) { UINT4 hdrData[4]; if(hyPhy20gGfpInit(sHandle, xfislice, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpInit failed!\n")); return -EFAULT; } // encaps, fcs, if(hyPhy20gGfpHdlcGrpChInitRx(sHandle, xfislice, 1, 0, 0, 1, mc20p_fcsMode, 1, 0, 0, 1, mc20p_payloadScram) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpHdlcGrpChInitRx failed!\n")); return -EFAULT; } if(hyPhy20gGfpHdlcGrpChInitTx(sHandle, xfislice, 1, 0, 0, 1, 1, 0, 0, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpHdlcGrpChInitTx failed!\n")); return -EFAULT; } if(hyPhy20gGfpSonetSysClkCfg(sHandle, xfislice, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpSonetSysClkCfg failed!\n")); return -EFAULT; } if(hyPhy20gGfpGenericFilterCfg(sHandle, xfislice, 0, 0, 0xf, 0, 0x0, 0, 0, 0, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpGenericFilterCfg failed!\n")); return -EFAULT; } if(hyPhy20gGfpGenericFilterCfg(sHandle, xfislice, 0, 1, 0xf, 0, 0x0, 0, 0, 0, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpGenericFilterCfg failed!\n")); return -EFAULT; } hdrData[0] = hdrData[1] = hdrData[2] = hdrData[3] = 0; if(hyPhy20gGfpHdlcPrependCfg(sHandle, xfislice, 0, 4, hdrData, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpHdlcPrependCfg failed!\n")); return -EFAULT; } // CPB GFP port configuration if(hyPhy20gWrite(sHandle, (0x49285D8 + xfislice * 0x100), 0x0000087d) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gWrite failed!\n")); return -EFAULT; } if(hyPhy20gWrite(sHandle, (0x4921590 + xfislice * 0x800), 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gWrite failed!\n")); return -EFAULT; } if(hyPhy20gGfpRxChAdd(sHandle, xfislice, 0, 0, 0, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpRxChAdd failed!\n")); return -EFAULT; } if(hyPhy20gGfpTxChAdd(sHandle, xfislice, 0, 0, 4) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[gfpConfig]: hyPhy20gGfpTxChAdd failed!\n")); return -EFAULT; } return HYPHY20G_SUCCESS; }
char *Z_Strdup(const char *s, int tag, void **user) { return strcpy((Z_Malloc)(strlen(s)+1, tag, user DA(file, line)), s); }
DA(const DA &Other = DA(0)) : Field1(Other.Field1), Field2(Other.Field2) {}
static INT4 Client10GPOSConf(struct file *sHandle, INT4 xfislice, INT4 sonetslicegrp) { int i; UINT4 block; UINT4 reg_data; gfpConfig(sHandle, xfislice); //Line Interface if(hyPhy20gXfiSerdesInit(sHandle, xfislice, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GPOSConf]: hyPhy20gXfiSerdesInit failed!\n")); return -EFAULT; } // OC192 rate if(hyPhy20gXfiRateCfg(sHandle, xfislice, 1, 0, 0, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GPOSConf]: hyPhy20gXfiRateCfg failed!\n")); return -EFAULT; } //Transport Service Configuration for ( i = 0 ; i < 4; i++) { // four slices for one sts192 if(hyPhy20gSonetInit(sHandle, sonetslicegrp*4 + i, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GPOSConf]: hyPhy20gSonetInit failed!\n")); return -EFAULT; } hyPhy20gRead(sHandle, (0x4940054 + (sonetslicegrp*4 + i)*0x1000), ®_data); if (mc20p_sonetScram == 1) reg_data &= 0xffffffcf; // bit 5, bit 4 is TDS, RDDS else reg_data |= 0x30; hyPhy20gWrite(sHandle, (0x4940054 + (sonetslicegrp*4 + i)*0x1000), reg_data); } //Cross Point (line interface to sonet, first time) block = sonetslicegrp + 2; if(hyPhy20gSonetLnXfiSfiDataPathCfg(sHandle, xfislice, block, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GPOSConf]: hyPhy20gSonetLnXfiSfiDataPathCfg failed!\n")); return -EFAULT; } //Configure SONET/SDH if(hyPhy20gSonetSts192FrmrCfg(sHandle, sonetslicegrp, 4) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GPOSConf]: hyPhy20gSonetSts192FrmrCfg failed!\n")); return -EFAULT; } // additional function, not in the flow chart, totally unkown!!! if(hyPhy20gSonetPohPslPdiCfg(sHandle, sonetslicegrp*4, 0, 0, 0, 0x16, 0, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GPOSConf]: hyPhy20gSonetPohPslPdiCfg failed!\n")); return -EFAULT; } // optionally, process OC192 in WIS WAN, maybe not needed if(hyPhy20gSonetLnSonetSysDataPathCfg(sHandle, sonetslicegrp, sonetslicegrp, 1, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GPOSConf]: hyPhy20gSonetLnSonetSysDataPathCfg failed!\n")); return -EFAULT; } //Cross Point (line interface to sonet, second time) block = sonetslicegrp + 2; if(hyPhy20gSonetLnXfiSfiDataPathCfg(sHandle, xfislice, block, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GPOSConf]: hyPhy20gSonetLnXfiSfiDataPathCfg failed!\n")); return -EFAULT; } return HYPHY20G_SUCCESS; }
void EncodingEDSRSA(char *M_fname, char *nA_fname, char *eA_fname, char *dA_fname, char *nB_fname, char *eB_fname, char *dB_fname) { std::ifstream in(M_fname); int *M_hash = (int*)md5(&in), i; BigInt M(intToChar(M_hash[3])), NA(nA_fname, false), EA(eA_fname, false), DA(dA_fname, false); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[2])); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[1])); M *= BigInt("10000000000"); M += BigInt(intToChar(M_hash[0])); BigInt NB(nB_fname, false), EB(eB_fname, false), DB(dB_fname, false); BigInt Signature("1"), Code("1"), Encode("1"), CheckSign("1"); BigInt DegreeNet[RNet]; DegreeNet[0] = M; DegreeNet[0] %= NA; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= NA; } BigInt degreeNum[RNet]; degreeNum[0] = BigInt("1"); for(int i = 1; i < RNet; i++) degreeNum[i] = degreeNum[i-1] * BigInt("2"); BigInt I("0"); for(int j = RNet-1; j >= 0;) { if(DA >= I + degreeNum[j]) { Signature *= DegreeNet[j]; Signature %= NA; I += degreeNum[j]; } else j--; } ////////////////////////////// DegreeNet[0] = Signature; DegreeNet[0] %= NB; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= NB; } I = BigInt("0"); for(int j = RNet-1; j >= 0;) { if(EB >= I + degreeNum[j]) { Code *= DegreeNet[j]; Code %= NB; I += degreeNum[j]; } else j--; } ////////////////////////////// DegreeNet[0] = Code; DegreeNet[0] %= NB; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= NB; } I = BigInt("0"); for(int j = RNet-1; j >= 0;) { if(DB >= I + degreeNum[j]) { Encode *= DegreeNet[j]; Encode %= NB; I += degreeNum[j]; } else j--; } ////////////////////////////// DegreeNet[0] = Encode; DegreeNet[0] %= NA; for(i = 1; i < RNet; i++) { DegreeNet[i] = DegreeNet[i-1] * DegreeNet[i-1]; DegreeNet[i] %= NA; } I = BigInt("0"); for(int j = RNet - 1; j >= 0;) { if(EA >= I + degreeNum[j]) { CheckSign *= DegreeNet[j]; CheckSign %= NA; I += degreeNum[j]; } else j--; } ////////////////////////////// M.TextWrite("hash.txt"); Code.TextWrite("code.txt"); Encode.TextWrite("encode.txt"); CheckSign.TextWrite("checksign.txt"); if( M % NA == CheckSign) std::cout<<"OK\n"; else std::cout<<"NOT OK\n"; }
static INT4 PifXAUIConf(struct file *sHandle, int optLoopback) { int i; // standard xaui if(hyPhy20gPifInit(sHandle, 8, 2, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifInit failed!\n")); return -EFAULT; } // According to SW driver manual, the following functions should be AFTER hyPhy20gPifInit for (i=0; i < 8; i++) { if(hyPhy20gPifSerdesInit(sHandle, i, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifSerdesInit failed!\n")); return -EFAULT; } if(hyPhy20gPifRateCfg(sHandle, i, 1, 0, 0, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifRateCfg failed!\n")); return -EFAULT; } } // dir = 0 if(hyPhy20gPifFlowCtrlInit(sHandle, 0, 2, 2, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifFlowCtrlInit failed!\n")); return -EFAULT; } // dir = 1 if(hyPhy20gPifFlowCtrlInit(sHandle, 1, 2, 2, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifFlowCtrlInit failed!\n")); return -EFAULT; } if(hyPhy20gPifXauiInit(sHandle, 1, 4, 2, 128, 128) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifXauiInit failed!\n")); return -EFAULT; } for (i=0; i < 2; i++) { if(hyPhy20gPifStdXauiCpbChnlCfg(sHandle, i, i+148) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifStdXauiCpbChnlCfg failed!\n")); return -EFAULT; } } if(hyPhy20gPifIntfEnable(sHandle, 1, 0x1F) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifIntfEnable failed!\n")); return -EFAULT; } // calling the following function when you want to do XAUI loopback if (optLoopback) { if(hyPhy20gPifSerdesDiagLpbk(sHandle, 0xFF, 0xFF) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifSerdesDiagLpbk failed!\n")); return -EFAULT; } } //hyPhy20gPifChnlFcMap(); // Enabling Data Paths if(hyPhy20gPifTxChnlEnable(sHandle, 1, 1, 1, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifTxChnlEnable failed!\n")); return -EFAULT; } if(hyPhy20gPifTxChnlEnable(sHandle, 2, 1, 2, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[PifXAUIConf]: hyPhy20gPifTxChnlEnable failed!\n")); return -EFAULT; } return HYPHY20G_SUCCESS; }
// According to SW driver manual, the following sequence is correct static INT4 Client10GELANConf(struct file *sHandle, INT4 xfislice, INT4 hscislice) { //Step 1. Line Interface if(hyPhy20gXfiSerdesInit(sHandle, xfislice, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gXfiSerdesInit failed!\n")); return -EFAULT; } if(hyPhy20gXfiRateCfg(sHandle, xfislice, 2, 0, 0, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gXfiRateCfg failed!\n")); return -EFAULT; } //Step 2. Cross Point (line interface to hsci) if(hyPhy20gSonetLnXfiSfiDataPathCfg(sHandle, xfislice, hscislice, 0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gSonetLnXfiSfiDataPathCfg failed!\n")); return -EFAULT; } //Step 3. Client Configuration (HSCI) if(hyPhy20gHsciInit(sHandle, hscislice, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gHsciInit failed!\n")); return -EFAULT; } if(hyPhy20gEnetComHsciInit(sHandle, hscislice, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gEnetComHsciInit failed!\n")); return -EFAULT; } // crcAppend, PadEn if(hyPhy20gHsci10GeLanTxxgCfg(sHandle, hscislice, 0xc, 1, 1, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gEnetComHsciInit failed!\n")); return -EFAULT; } // oversizeResp = 0, crcStrip = 0, shortPktEn = 0 if(hyPhy20gHsci10GeLanRxxgCfg(sHandle, hscislice, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0x4, 0, 0, 0, 0, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gEnetComHsciInit failed!\n")); return -EFAULT; } if(hyPhy20gHsci10GeLanSetFrameSizes(sHandle, hscislice, mc20p_maxPkt, mc20p_minPkt, mc20p_maxPkt) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gEnetComHsciInit failed!\n")); return -EFAULT; } if(hyPhy20gHsciDataPathEnable(sHandle, hscislice, 0, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gHsciDataPathEnable failed!\n")); return -EFAULT; } if(hyPhy20gHsciDataPathEnable(sHandle, hscislice, 1, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[Client10GELANConf]: hyPhy20gHsciDataPathEnable failed!\n")); return -EFAULT; } return HYPHY20G_SUCCESS; }
/******************************************************************************* lineType: 0 - 10GELAN 1 - 10GEWAN 2 - 10GPOS cpblp: 0 - no loopback inside cpb 1 - loopback inside cpb ********************************************************************************/ static INT4 initHyphy20g(struct file *sHandle, INT4 lineType, INT4 cpblp, INT4 xauilp) { // Init each module if(hyPhy20gEnetComDeviceInit(sHandle, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gEnetComDeviceInit failed!\n")); return -EFAULT; } if(hyPhy20gTseInit(sHandle, 0, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gTseInit failed!\n")); return -EFAULT; } if(hyPhy20gCpbInit(sHandle, 0, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gCpbInit failed!\n")); return -EFAULT; } if (lineType == 0) { // line to cpb if(hyPhy20gCpbIntfInit(sHandle, 0, 16, 32, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gCpbIntfInit failed!\n")); return -EFAULT; } } else if (lineType == 2) { // line to cpb GFP A if(hyPhy20gCpbIntfInit(sHandle, 1, 16, 32, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gCpbIntfRateAwareInit failed!\n")); return -EFAULT; } // line to cpb GFP B if(hyPhy20gCpbIntfInit(sHandle, 2, 16, 32, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gCpbIntfRateAwareInit failed!\n")); return -EFAULT; } } // pif to cpb if(hyPhy20gCpbIntfInit(sHandle, 3, 16, 32, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gCpbIntfInit failed!\n")); return -EFAULT; } // WCI_MODE = 0 read clear mode if(hyPhy20gWrite(sHandle, 0x49630A0, 0x0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gWrite failed!\n")); return -EFAULT; } if(hyPhy20gWrite(sHandle, 0x49630A4, 0x0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gWrite failed!\n")); return -EFAULT; } if(hyPhy20gWrite(sHandle, 0x49630A8, 0x0) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[initMeta20g]: hyPhy20gWrite failed!\n")); return -EFAULT; } PifXAUIConf(sHandle, xauilp); DataPathEnable(sHandle, lineType, cpblp); return HYPHY20G_SUCCESS; }
/* Send the page to the printer. For now, just send the whole image. */ static int ljet5_print_page(gx_device_printer * pdev, FILE * prn_stream) { gs_memory_t *mem = pdev->memory; uint line_size = gdev_mem_bytes_per_scan_line((gx_device *) pdev); uint line_size_words = (line_size + W - 1) / W; uint out_size = line_size + (line_size / 127) + 1; word *line = (word *)gs_alloc_byte_array(mem, line_size_words, W, "ljet5(line)"); byte *out = gs_alloc_bytes(mem, out_size, "ljet5(out)"); int code = 0; int lnum; stream fs; stream *const s = &fs; byte buf[200]; /* arbitrary */ if (line == 0 || out == 0) { code = gs_note_error(gs_error_VMerror); goto done; } s_init(s, mem); swrite_file(s, prn_stream, buf, sizeof(buf)); /* Write the page header. */ { static const byte page_header[] = { pxtBeginPage, DUSP(0, 0), DA(pxaPoint), pxtSetCursor }; static const byte mono_header[] = { DUB(eGray), DA(pxaColorSpace), DUB(e8Bit), DA(pxaPaletteDepth), pxt_ubyte_array, pxt_ubyte, 2, 0xff, 0x00, DA(pxaPaletteData), pxtSetColorSpace }; static const byte gray_header[] = { DUB(eGray), DA(pxaColorSpace), pxtSetColorSpace }; px_write_page_header(s, (gx_device *)pdev); px_write_select_media(s, (gx_device *)pdev, NULL, NULL, 0, false, false); PX_PUT_LIT(s, page_header); if (pdev->color_info.depth == 1) PX_PUT_LIT(s, mono_header); else PX_PUT_LIT(s, gray_header); } /* Write the image header. */ { static const byte mono_image_header[] = { DA(pxaDestinationSize), DUB(eIndexedPixel), DA(pxaColorMapping), DUB(e1Bit), DA(pxaColorDepth), pxtBeginImage }; static const byte gray_image_header[] = { DA(pxaDestinationSize), DUB(eDirectPixel), DA(pxaColorMapping), DUB(e8Bit), DA(pxaColorDepth), pxtBeginImage }; px_put_us(s, pdev->width); px_put_a(s, pxaSourceWidth); px_put_us(s, pdev->height); px_put_a(s, pxaSourceHeight); px_put_usp(s, pdev->width, pdev->height); if (pdev->color_info.depth == 1) PX_PUT_LIT(s, mono_image_header); else PX_PUT_LIT(s, gray_image_header); } /* Write the image data, compressing each line. */ for (lnum = 0; lnum < pdev->height; ++lnum) { int ncompr; static const byte line_header[] = { DA(pxaStartLine), DUS(1), DA(pxaBlockHeight), DUB(eRLECompression), DA(pxaCompressMode), pxtReadImage }; code = gdev_prn_copy_scan_lines(pdev, lnum, (byte *) line, line_size); if (code < 0) goto fin; px_put_us(s, lnum); PX_PUT_LIT(s, line_header); ncompr = gdev_pcl_mode2compress_padded(line, line + line_size_words, out, true); px_put_data_length(s, ncompr); px_put_bytes(s, out, ncompr); } /* Finish up. */ fin: spputc(s, pxtEndImage); spputc(s, pxtEndPage); sflush(s); done: gs_free_object(mem, out, "ljet5(out)"); gs_free_object(mem, line, "ljet5(line)"); return code; }
/******************************************************************************* First step init function *******************************************************************************/ INT4 initHyphy20gGlobal(struct file *sHandle) { int i; char firmware[256] = DRV_FIRMWARE_FILE; if (hyPhy20gPcieInit(sHandle, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[framer_open]: hyPhy20PcieInit failed!\n")); return -EFAULT; } for (i = 0; i < 5; i++) { if (hyPhy20gDcsuInit(sHandle, i) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[hyPhy_open]: hyPhy20gDcsuInit failed!\n")); return -EFAULT; } } if (hyPhy20gCreateCtxt(sHandle) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[hyPhy_open]: hyPhy20gCreateCtxt failed!\n")); return -EFAULT; } // fread & jumpAddr is for rev.4.2 if (hyPhy20gFwDownload(sHandle, (STRING *)firmware, 0xA0000400) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[hyPhy_open]: hyPhy20gFwDownload failed!\n")); return -EFAULT; } if (hyPhy20gHostMsgInit(sHandle, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[hyPhy_open]: hyPhy20gHostMsgInit failed!\n")); return -EFAULT; } // 2013.04.15 add this for dev.07.07 if (hyPhy20gHostMsgFwOp(sHandle, 1) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[hyPhy_open]: hyPhy20gHostMsgFwOp failed!\n")); return -EFAULT; } for (i = 0; i < 32; i++) // put unused resources into lowest energy state { if (hyPhy20gBackplaneSerdesInit(sHandle, i, 2) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[hyPhy_open]: hyPhy20gBackplaneSerdesInit failed!\n")); return -EFAULT; } } for (i = 0; i < 16; i++) // put unused resources into lowest energy state { if (hyPhy20gSfpSerdesInit(sHandle, i, 2) != HYPHY20G_SUCCESS) { DA((KERN_ERR "[hyPhy_open]: hyPhy20gSfpSerdesInit failed!\n")); return -EFAULT; } } return HYPHY20G_SUCCESS; }
void setOrdinaryMaterial(int m){ CA(m) = (1 - SIGMA(m)*deltaT/(2*EPSR(m)*EPSNOT )) / ( 1 + SIGMA(m)*deltaT /(2*EPSR(m)*EPSNOT)); CB(m) = (deltaT/(EPSR(m)*EPSNOT*DELTA)) / ( 1 + SIGMA(m) * deltaT /(2*EPSR(m)*EPSNOT)); DA(m) = (1 - SIGMA(m)*deltaT/(2*MUR(m)*MUNOT)) / ( 1 + SIGMA(m) * deltaT /(2*MUR(m)*MUNOT)); DB(m) = (deltaT/(MUR(m)*MUNOT*DELTA)) / ( 1 + SIGMA(m)*deltaT /(2*MUR(m)*MUNOT)); } // end setOrdinaryMaterial
static void pl330_getposition(u32 dma_chan, dma_addr_t *src, dma_addr_t *dst) { *src = readl(pl330_data.base + SA(dma_chan)); *dst = readl(pl330_data.base + DA(dma_chan)); }