コード例 #1
0
ファイル: frog.c プロジェクト: compvid30/strongcrypt
void make_ikey(key_str *kp)
{   u4byte  i, j, k, ix, ll;
    u1byte  ua[16];
        
    for(i = 0; i < 8; ++i)
    {
        make_perm(kp->f_key[i].k_spu, 256);

        for(j = 0; j < 256; ++j)

            kp->i_key[i][kp->f_key[i].k_spu[j]] = (u1byte)j;

        make_perm(kp->f_key[i].k_bpu, 16);

        for(j = 0; j < 16; ++j)

            ua[j] = 0;

        for(j = ix = 0; j < 15; ++j)
        {
            if(!kp->f_key[i].k_bpu[ix])
            {
                k = ix;

                do
                {
                    k = (k + 1) & 15;
                }
                while
                    (ua[k]);

                kp->f_key[i].k_bpu[ix] = (u1byte)k; ll = k;

                while(kp->f_key[i].k_bpu[ll] != k)
                
                    ll = kp->f_key[i].k_bpu[ll];

                kp->f_key[i].k_bpu[ll] = 0;
            }

            ua[ix] = 1; ix = kp->f_key[i].k_bpu[ix];
        }

        for(j = 0; j < 16; ++j)

            if(kp->f_key[i].k_bpu[j] == ((j + 1) & 15))

                kp->f_key[i].k_bpu[j] = (u1byte)((j + 2) & 15);
    }
}
コード例 #2
0
// randomize votes
void randomize_votes() {
  assert(disp == 1); // only supported value currently
  int i, j;
  int *vote;

  vote = votes;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++)
      vote[j] = j;
    make_perm(m, vote);
    vote += m;
  }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: teodor94/programare
int main() {
    freopen("nrperm.in", "r", stdin);
    freopen("nrperm.out", "w", stdout);

    citire();

    make_perm();

    make_pascal();

    rez();

    return 0;
}
コード例 #4
0
ファイル: c_out.c プロジェクト: restrepo/CalcHEP
static int c_prog_int(void)
{
   int breaker;
   int i;
   long dfirst;
      
   if(nin+nout<=4) sumDiag=1; else sumDiag=0;   

   memerror=zeroHeep;
   mark_(&heapbeg);

   initvararray(0,'c',NULL);
  /* ======= Initialisation parth ======= */

   firstVar=nmodelvar;
   if(!strcmp( modelvars[firstVar].varname,strongconst))  firstVar--;
   prepareprocinform();
   calc_nvars_nfunc();
  /* ======= End of Initialisation ====== */

   {  outFileOpen("%sresults%cservice.c",pathtouser,f_slash); 
      labl();
      writeF("#include<math.h>\n");
      writeF("#include<complex.h>\n");                 
      writeF("#include\"num_out.h\"\n");
      writeF("#include\"num_in.h\"\n");

      writeF("double BWrange_ext=2.7;\n");
      writeF("int twidth_ext=0;\n");
      writeF("int gtwidth_ext=0;\n");
      writeF("int gswidth_ext=0;\n");
      writeF(" REAL va_ext[%d]={0};\n",nvars+nfunc+1); 
   }
   geninf("nin_ext",nin);
   geninf("nout_ext",nout);
   geninf("nprc_ext",subproc_sq);
   make_pinf();
   geninf("nvar_ext",nvars);
   geninf("nfunc_ext",nfunc);
   make_vinf();
   
   { 
      make_den_info();
      fprintf(outFile,"\nCalcHEP_interface interface_ext={ %d,\n\"%s\"\n,%d, %d, varName_ext,va_ext,"
          "%d, %d, %d, &pinf_ext, &pinfAux_ext, polarized_ext, &calcFunc_ext, &BWrange_ext,&twidth_ext,"
          "&gtwidth_ext,&gswidth_ext, &aWidth_ext, &sqme_ext,&den_info_ext,cb_ext};\n", 
      forceUG, pathtocalchep,nvars, nfunc, nin,nout,subproc_sq);

      writeF("\nCalcHEP_interface * PtrInterface_ext=&interface_ext;\n");

      outFileClose();
      outFileOpen("%sresults%csqme.c",pathtouser,f_slash); 
      labl();
      writeF("#include<stdio.h>\n");
      writeF("#include<math.h>\n");
      writeF("#include<complex.h>\n");
      writeF("#include\"num_out.h\"\n");
      writeF("#include\"num_in.h\"\n");
   }
   writeF("static int calcall[%d];\n",subproc_sq+1);
   {
   writeF("static int particles[%d]={0",1+nin+nout); 
   for(i=0;i<nin+nout;i++) writeF(",0");
   writeF("};\n");
   }
   writeF("extern DNN ");
   for(i=1;i<subproc_sq;i++)  writeF("S%d_ext,",i); 
   writeF("S%d_ext;\n",subproc_sq); 
   
   writeF("static  DNN * darr[%d]={",subproc_sq);
   for(i=1;i<subproc_sq;i++)  writeF("&S%d_ext,",i);
   writeF("&S%d_ext};\n",subproc_sq);
   
   
   fseek(catalog,0,SEEK_SET);
   { catrec  cr;
     ndiagrtot =0;
     while(FREAD1(cr,catalog)) if(cr.status==1) ndiagrtot++; 
   }
   writesubroutineinit();
   
   {  make_infbasis();
      make_perm();
      writeF("#include\"sqme.inc\"\n");
      outFileClose();
   }
   diagrcount = 0;
   inftmp = inf;
   init_stat();
   for (nsub = 1,dfirst=1; nsub <= subproc_sq; nsub++)
   {  int colors[MAXINOUT];

      if (inftmp->tot != 0)   /*  this subprocess IN archive  */
      {

         for(i=0;i<nin+nout;i++) 
         {  int l;
            locateinbase(inftmp->p_name[i], &l);
            colors[i]=prtclbase[l-1].cdim;
         }
         for(i=0;i<nin; i++) if(abs(colors[i])==3 || abs(colors[i])==6) colors[i]*=-1; 
         
         if(noCChain) for(i=0;i<nin+nout; i++) colors[i]=1; 
         
         cBasisPower=infCbases(nin+nout,colors,&nC,&cChains);
         if(cBasisPower>0)
         { 
            cCoefN=malloc(cBasisPower*sizeof(long));
            cCoefD=malloc(cBasisPower*sizeof(long));
         }
         writesubprocess(nsub,dfirst,inftmp->tot, &breaker);
         dfirst+=inftmp->tot;
         if (breaker) goto exi;
      
         if(cBasisPower)
         {
            if(cChains){free(cChains); cChains=NULL;} 
            free(cCoefN); free(cCoefD);
         }

      } else writesubprocess(nsub,dfirst,0, NULL);
      inftmp = inftmp->next;
   }
   
exi:
   clearstatistic();
   release_(&heapbeg);
   return !breaker;
}