コード例 #1
0
ファイル: main.cpp プロジェクト: dlfivefifty/Ultraspherical
void smallbandExample()
{
    cout << "SMALL BAND" <<endl;
    
    clock_t t1; clock_t t2;
    
    long n = 40;
    double bin[n];
    
    for (int i = 0; i < n; ++i)
        bin[i] = 1.;
    
    toC2Series(bin, n);
    
    
    vector<double> b;
    
    b.push_back(1);
    b.push_back(1);
    
    for(long i = 0; i < n; i++)
        b.push_back(bin[i]);
    
    printvec(b);
    
    vector<double> a;
    a.push_back(10); a.push_back(2); a.push_back(3);
    
    FilledBandedMatrix *drbnd = DirichletD2ConvertMultiplicationMatrix(NULL,&a);
    
    
    //        drbnd.print();
    
    
    drbnd->increaseSize();
    
    t1 = clock();
    
    vector<double> c = QRSolve(drbnd,b);
    
    t2 = clock();
    //            printvec(b);
    float tottime = ((float)(t2-t1)/CLOCKS_PER_SEC);
    cout<<"{"<<c.size()<<", "<<tottime<<"},"<<endl;
    
    printvec(c);
    
    delete drbnd;
}
コード例 #2
0
ファイル: Shell.c プロジェクト: Einath/AProg_Practices
void main(int argc, char argv[]){

  int v[LVECT], i; 
  printf("Vector de números aleatorios:\n");
  srand(getpid()); 
  for(i=0; i<LVECT; i++){
    v[i]=rand()%10;
  }
   printvec(v);
  printf("\n");
  printf("Vector ordenado:\n"); 
  shell(v); 
  printvec(v); 
  printf("\nShellsort finalizado [%d elementos]\n", LVECT); 
}
コード例 #3
0
ファイル: testarrays.cpp プロジェクト: glotglutton/EPP
void testpermutearray(){

    std::vector<unsigned int> v(9), sigma(9);
    std::srand(std::time(0));
    for(int i = 0; i < v.size(); ++i){
        v[i]    = i;
        sigma[i]= i;
    }
    sigma   = std::vector<unsigned int>({2,3,4,1,0,7,5,6,8});
    std::random_shuffle(v.begin(), v.end());
    std::random_shuffle(v.begin(), v.end());
    std::random_shuffle(v.begin(), v.end());
    printvec(v);
    printvec(sigma);
    permutearray(v, sigma);

}
コード例 #4
0
ファイル: testarrays.cpp プロジェクト: glotglutton/EPP
void testrotatearray(){

    std::vector<u32> sigma(9);
    std::srand(std::time(0));
    sigma   = std::vector<u32>({2,3,4,1,0,7,8,6,5});
    printvec(sigma);
    rotatearray(sigma, 3);

}
コード例 #5
0
ファイル: testarrays.cpp プロジェクト: glotglutton/EPP
void testnextpermutation(){

    std::vector<u32> sigma(9);
    std::srand(std::time(0));
    sigma   = std::vector<u32>({2,3,4,1,0,7,8,6,5});
    printvec(sigma);
    nextpermutation(sigma);

}
コード例 #6
0
ファイル: testarrays.cpp プロジェクト: glotglutton/EPP
void testinversepermutation(){

    std::vector<unsigned int> sigma(9);
    std::srand(std::time(0));
    sigma   = std::vector<unsigned int>({2,3,4,1,0,7,5,6,8});
    printvec(sigma);
    inversepermutation(sigma);

}
コード例 #7
0
ファイル: Ej3.c プロジェクト: Einath/AProg_Practices
void main(){
  int N, i; /*vector de trabajo y vector resultado*/
  int p, k;
  srand(getpid());
  /*generamos un p aleatorio
  srand(getpid()); la semilla será el Pid del proceso

  int p=(rand()%(LVECT-2))+1;   rango de p: [1, x] , x es la longitud del vector -1 (k-ésimo elemento)

  generamos un k aleatorio

  int k=rand()%(LVECT-1);  rango de k: [0, LVECT -1] */
  printf("Introduzca un valor para N:\n");
  scanf("%d", &N);

  int v[N]; 
  p=N/2;    

  printf("Introduzca un valor para K:\n");
  scanf("%d", &k);

  int inf=k-p/2;
  int sup=k+(p-p/2);

  printf("\nVector de números aleatorios:\n"); 
  for (i=0; i<N; i++){
    v[i]=rand()%100;
    printf("%d\t", v[i]);
  }

  int copia[N]; 
  for(i=0; i< N; i++)
    copia[i]=v[i];
  printf("\nVector ordenado con QS:\n");
  QS(copia, 0, N-1);
  printvec(copia, N);


  printf("\n\ninf: %d\nsup: %d\n", inf, sup);
  pk(v, p, inf, sup, k);
  printf("\n");
  printvec(v, N);

}
コード例 #8
0
ファイル: direct.c プロジェクト: rui314/threading
static void loop(char *inst) {
  void *table[] = { &&L0, &&L1, &&L2, &&L3, &&L4, &&L5, &&L6, &&L7, &&L8, &&L9, &&L10, &&L11, &&L12, &&L13, &&L14, &&L15 };

  void **addrs = malloc(LEN * sizeof(void *));
  for (int i = 0; i < LEN; i++)
    addrs[i] = table[inst[i]];

  clock_gettime(CLOCK_REALTIME, &start);
#define NEXT goto *(*addrs++)
  NEXT;
L0: return;
L1: for (int i = 0; i < LOOP; i++) vec[1]++; NEXT;
L2: for (int i = 0; i < LOOP; i++) vec[2]++; NEXT;
L3: for (int i = 0; i < LOOP; i++) vec[3]++; NEXT;
L4: for (int i = 0; i < LOOP; i++) vec[4]++; NEXT;
L5: for (int i = 0; i < LOOP; i++) vec[5]++; NEXT;
L6: for (int i = 0; i < LOOP; i++) vec[6]++; NEXT;
L7: for (int i = 0; i < LOOP; i++) vec[7]++; NEXT;
L8: for (int i = 0; i < LOOP; i++) vec[8]++; NEXT;
L9: for (int i = 0; i < LOOP; i++) vec[9]++; NEXT;
L10: for (int i = 0; i < LOOP; i++) vec[10]++; NEXT;
L11: for (int i = 0; i < LOOP; i++) vec[11]++; NEXT;
L12: for (int i = 0; i < LOOP; i++) vec[12]++; NEXT;
L13: for (int i = 0; i < LOOP; i++) vec[13]++; NEXT;
L14: for (int i = 0; i < LOOP; i++) vec[14]++; NEXT;
L15: for (int i = 0; i < LOOP; i++) vec[15]++; NEXT;
}

void printvec() {
  for (int i = 0; i < 16; i++)
    printf("%d ", vec[i]);
  printf("\n");
}

void printtime() {
  struct timespec end;
  clock_gettime(CLOCK_REALTIME, &end);
  long t1 = start.tv_sec * 1000 * 1000 * 1000 + start.tv_nsec;
  long t2 = end.tv_sec * 1000 * 1000 * 1000 + end.tv_nsec;
  printf("time: %f\n", (t2 - t1) / 1e9);
}

int main(int argc, char **argv) {
  char *inst = malloc(LEN);
  for (int i = 0; i < LEN - 1;) {
    int op = rand() & 15;
    if (op == 0) continue;
    inst[i++] = op;
  }
  inst[LEN - 1] = 0;
  loop(inst);
  printvec();
  printtime();
  return 0;
}
コード例 #9
0
ファイル: main.cpp プロジェクト: incredibleray/randomcpp
int cutstock::processRequest(vector<int> & requests, pipeStock & state) {
	
	cout << "processing remaining requests\n";
	printvec(requests);
	
	cout << "at state\n";
	printdvec(state);
	
	// static int memHit=0;
	
	if (requests.empty()) return state.size();
	
	
	
	int nextReq=requests.back();
	requests.pop_back();
	
	set<int> numPipes;
	
	for (int i=0; i<state.size()+1; i++) {
		
		if (i == state.size() || checkPipe(state[i], nextReq)) {
			pipeStock newState=state;
			vector<int> newReq=requests;
			
			if (i == state.size()) {
				pipe p;
				newState.push_back(p);
			}
			newState[i].push_back(nextReq);
			int stocks;
			//search memory
			if (m.find(mapIndex(newState)) != m.end()) {
				stocks=m.find(mapIndex(newState))->second;
				memHit++;
			}
			else {
			//if not found in memory, go through recursion
				stocks=processRequest(newReq, newState);
			//record it in memory
				m[mapIndex(newState)]=stocks;
			}
			
			numPipes.insert(stocks);
			
			
// 			numPipes.insert(processRequest(newReq, newState));
		}
	}
	
	set<int>::iterator it=numPipes.begin();
	return *it;
		
}
コード例 #10
0
ファイル: test-pbkdf2.c プロジェクト: phlay/sfet
int main()
{
	uint8_t check[64];
	int i;

	/* test pbkdf2 */
	for (i = 0; i < tablenum; i++) {
		pbkdf2_hmac_sha512(check, 64,
				   (uint8_t*)table[i].passwd, strlen(table[i].passwd),
				   (uint8_t*)table[i].salt, strlen(table[i].salt),
				   table[i].c);

		if (memcmp(check, table[i].dk, 64) != 0) {
			printf("test nr. %d failed\n", i+1);
			printvec("is", check, 64);
			printvec("should", table[i].dk, 64);
			return 1;
		}
	}

	return 0;
}
コード例 #11
0
ファイル: P2.c プロジェクト: Einath/AProg_Practices
void main(){
  int v[LVECT], i; /*vector de trabajo y vector resultado*/
  int p, k;
  srand(getpid());
  printf("Introduzca un valor para P:\n");
  scanf("%d", &p); 
  printf("Introduzca un valor para K:\n");
  scanf("%d", &k)
;
  int inf=k-p/2; /*Límite inferior*/
  if(inf<0)
    inf=0;

  int sup=k+(p-p/2);/*Límite superior*/
  if(sup>=LVECT)
    sup=LVECT-1;

  printf("\nVector de números aleatorios:\n"); /*Generamos el vector de números aleatorios valores 0-999*/ 
  for (i=0; i<LVECT; i++){
    v[i]=rand()%1000;
    printf("%d\t", v[i]);
  }

  int copia[LVECT];   /*Vector copia para comparar resultado final*/
  for(i=0; i< LVECT; i++)
    copia[i]=v[i];
  printf("\nVector ordenado con QS:\n");
  QS(copia, 0, LVECT-1);
  printvec(copia, LVECT);

  printf("\n\ninf: %d\nsup: %d\n\n", inf, sup);
  printf("K-esimo elemento: %d\n", copia[k]);

  pk(v, p, inf, sup, k); /*Llamada al método pk*/

  printf("====RESULTADO====\n");
  for(i=inf; i<=sup; i++){
      printf("%d\t", v[i]);
  }
  printf("\n\n");
}
コード例 #12
0
ファイル: Ej3.c プロジェクト: Einath/AProg_Practices
void pk (int v[], int p, int inf, int sup, int k){
  /*algoritmo p-k*/
  int pivote, li, ls, low, up;
  int i=0;
  li=0;
  ls=LVECT-1;
  low=k-inf;
  up=sup-k;


  pivote=Divide(v, li, ls); 

  while(res[sup-inf-1]<0){

    if((inf<=pivote)&&(pivote<=sup) ){
      res[i]=v[pivote];
      i++;
      pivote=Divide(v, li, pivote-1);
      pivote=Divide(v, pivote+1, ls);
    }

    if(pivote>=sup){
      ls=pivote -1;
      pivote=Divide(v, li, ls); 
    }

    if(pivote<=inf){
      li=pivote +1;
      pivote=Divide(v, li, ls); 
    }
  }

  printf("\n===RESULTADO===\n");
  printvec(res, sup-inf);
  printf("\n");
}
コード例 #13
0
ファイル: intvec.c プロジェクト: andoma/libsvc
int main(void)
{
  intvec_t v = {};

  intvec_insert_sorted(&v, 5);
  printvec(&v);
  intvec_insert_sorted(&v, 3);
  printvec(&v);
  intvec_insert_sorted(&v, 7);
  printvec(&v);
  intvec_insert_sorted(&v, 1);
  printvec(&v);
  intvec_insert_sorted(&v, 11);
  printvec(&v);
  intvec_insert_sorted(&v, 7);
  printvec(&v);
  intvec_insert_sorted(&v, 7);
  printvec(&v);
  intvec_insert_sorted(&v, 7);
  printvec(&v);
  intvec_insert_sorted(&v, 7);
  printvec(&v);
  intvec_insert_sorted(&v, 7);
  printvec(&v);
  intvec_insert_sorted(&v, 7);
  printvec(&v);
  intvec_insert_sorted(&v, 7);
  printvec(&v);
  intvec_insert_sorted(&v, 1);
  printvec(&v);
  intvec_insert_sorted(&v, 1);
  printvec(&v);
  intvec_insert_sorted(&v, 1);
  printvec(&v);
  intvec_insert_sorted(&v, 1);
  printvec(&v);
  intvec_insert_sorted(&v, 0);
  printvec(&v);
  intvec_insert_sorted(&v, 11);
  printvec(&v);
  intvec_insert_sorted(&v, 12);
  printvec(&v);
  intvec_insert_sorted(&v, 13);
  printvec(&v);

  printf("Find %d = %d\n", 0, intvec_find(&v, 0));
  printf("Find %d = %d\n", 7, intvec_find(&v, 7));
  printf("Find %d = %d\n", 8, intvec_find(&v, 8));
  printf("Find %d = %d\n", 12, intvec_find(&v, 12));
  printf("Find %d = %d\n", 1200, intvec_find(&v, 1200));
  printf("Find %d = %d\n", -120, intvec_find(&v, -120));
  intvec_reset(&v);
}
コード例 #14
0
ファイル: mat4test.cpp プロジェクト: porglezomp/graphicsmath
void printmat(const mat4 &m) {
	printvec(m.getRow(0));
	printvec(m.getRow(1));
	printvec(m.getRow(2));
	printvec(m.getRow(3));
}
コード例 #15
0
ファイル: test.cpp プロジェクト: yjfdl123/leetcode
int main(){
    vector<int> data = readdata();
    printvec(data);
    return 0;
};
コード例 #16
0
ファイル: lmfdrv_.c プロジェクト: jnorthrup/jmodelica
/* Main program */
int main(int argc, char **argv)
{

    int i,ic,k,m,n,ntries;
    int info;

    int ma[60];
    int na[60];
    int nf[60];
    int nj[60];
    int np[60];
    int nx[60];

    real factor,fnorm1,fnorm2,tol;

    real fnm[60];
    real fvec[65];
    real x[40];

    int iwa[40];
    real wa[65*40+5*40+65];
    const int lwa = 65*40+5*40+65;
    const int i1 = 1;

    tol = sqrt(__minpack_func__(dpmpar)(&i1));

    ic = 0;

    for (;;) {
        scanf("%5d%5d%5d%5d\n", &lmdiftest.nprob, &n, &m, &ntries);
/*
         read (nread,50) nprob,n,m,ntries
   50 format (4i5)
*/
        if (lmdiftest.nprob <= 0.)
            break;
        factor = 1.;

        for (k = 0; k < ntries; ++k, ++ic) {
            lmdipt(n,x,lmdiftest.nprob,factor);

            ssqfcn(m,n,x,fvec,lmdiftest.nprob);

            fnorm1 = __minpack_func__(enorm)(&m,fvec);

            printf("\n\n\n\n      problem%5d      dimensions%5d%5d\n\n", lmdiftest.nprob, n, m);
/*
            write (nwrite,60) nprob,n,m
   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
     *         )
*/

            lmdiftest.nfev = 0;
            lmdiftest.njev = 0;

            __minpack_func__(lmdif1)(fcn,&m,&n,x,fvec,&tol,&info,iwa,wa,&lwa);

            ssqfcn(m,n,x,fvec,lmdiftest.nprob);

            fnorm2 = __minpack_func__(enorm)(&m,fvec);

            np[ic] = lmdiftest.nprob;
            na[ic] = n;
            ma[ic] = m;
            nf[ic] = lmdiftest.nfev;
            lmdiftest.njev /= n;
            nj[ic] = lmdiftest.njev;
            nx[ic] = info;

            fnm[ic] = fnorm2;

            printf("\n      initial l2 norm of the residuals%15.7e\n"
                   "\n      final l2 norm of the residuals  %15.7e\n"
                   "\n      number of function evaluations  %10d\n"
                   "\n      number of Jacobian evaluations  %10d\n"
                   "\n      exit parameter                  %10d\n"
                   "\n      final approximate solution\n\n",
                   (double)fnorm1, (double)fnorm2, lmdiftest.nfev, lmdiftest.njev, info);
            printvec(n, x);
/*
            write (nwrite,70)
     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
     *        33h final l2 norm of the residuals  , d15.7 // 5x,
     *        33h number of function evaluations  , i10 // 5x,
     *        33h number of jacobian evaluations  , i10 // 5x,
     *        15h exit parameter, 18x, i10 // 5x,
     *        27h final approximate solution // (5x, 5d15.7))
*/

            factor *= 10.;

        }

    }

    printf("\f summary of %d calls to lmdif1: \n\n", ic);
/*
      write (nwrite,80) ic
   80 format (12h1summary of , i3, 16h calls to lmdif1 /)
*/
    printf("\n\n nprob   n    m   nfev  njev  info  final L2 norm \n\n");
/*
      write (nwrite,90)
   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
*/

    for (i = 0; i < ic; ++i) {
        printf("%5d%5d%5d%6d%6d%6d%16.7e\n",
               np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]);
/*
         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
  100 format (3i5, 3i6, 1x, d15.7)
*/

    }
    exit(0);
}
コード例 #17
0
ファイル: testpf.c プロジェクト: gap-packages/cohomolo
int 
main (void)
{ short i,j,m,n,y,np,nb,mxp,ord,im,len,*p,*q;
  int quot;
  int chct;
  char nt,f,id,eq,fault,flnm[80];
reenter:
  printf("Do you wish to read permutations from a file (y/n)?  ");
  if (getchar()=='y')
  { f=1; snl();
    printf("Input filename:    "); scanf("%s",flnm); snl();
    if ((ip=fopen(flnm,"r"))==0)
    { fprintf(stderr,"Cannot open %s.\n",flnm); goto reenter; }
    fscanf(ip,"%hd%hd%hd%hd",&npt,&np,&nb,&m); seeknln();
    if (nb!=0) 
    { if (nb>=mb)
      { fprintf(stderr,"Too many base points. Increase MB.\n"); return(-1);}
      for (i=1;i<=nb;i++) fscanf(ip,"%hd",base+i);
      seeknln();
    }
    if (m!=0) seeknln();
  }
  else
  { f=0; snl(); printf("Input npt:   "); scanf("%hd",&npt); snl(); nb=0; }
  if (npt>mpt) {fprintf(stderr,"npt too big. Increase NPT.\n"); exit(1); }
  quot=psp/npt; if (quot>mp) mxp=mp; else mxp=quot;
  printf("Perm nos 1 - %d can be read. Perm no 0 is always the identity\n",
          mxp-1);
  for (i=0;i<mxp;i++) { pptr[i]=perm-1+npt*i; pno[i]=0; }
  p=pptr[0]; for (i=1;i<=npt;i++) p[i]=i;
  pno[0]=1;
  if (f)
  { if (np>=mxp)
    { fprintf(stderr,"Not enough perm space to read perms from file.");
      fprintf(stderr," Increase PSP (or MP).\n"); exit(1);
    }
    for (i=1;i<=np;i++)
    { if (readperm(pptr[i])==2)
      { fprintf(stderr,"Perm no %i is not a permutation.\n"); exit(1);}
      pno[i]=1; seeknln();
    }
    fclose(ip);
  }

  while(1)
  { printf("Choose option. Print 'l' for list.\n");
    scanf("%s",opt);
    if (strcmp(opt,"l")==0)
    { snl();
      printf("rp  n                = read perm no n.\n");
      printf("pp  n                = print perm no n.\n");
      printf("ppc  n               = print perm no n in cycles.\n");
      printf("inv m n              = calc inverse p[n] of p[m].\n");
      printf("pr n l i(1)...i(l)   = calc prod p[n] of p[i(1)]...p[i(l)].\n");
      printf("im m x               = print image of point x under p[m].\n");
      printf("fp n                 = print fixed pts of p[n].\n");
      printf("fpn l i(1)...i(l)    = print common fixed pts of p[i(1)],...,p[i(l)].\n");
      printf("cyc n x              = print cycle of point x under p[n].\n");
      printf("ord n                = print order of p[n].\n");
      printf("orb l i(1)...i(l)    = print orbits of p[i(1)]...p[i(l)].\n");
      printf("rb                   = read in a base for the group.\n");
      printf("op filename          = output some perms to 'filename'.\n");
      printf("opord filename       = output some perms to 'filename' and\n");
      printf("                       compute order of group they generate.\n");
      printf("                      (Only works if base known for G!).\n");
      printf("rf n filename        = read in additional perms from filename\n");
      printf("                       starting at perm. no. n.\n");
      printf("q                    = quit.\n");
    }
    else if (strcmp(opt,"rp")==0)
    { scanf("%hd",&n); snl();
      if (n<=0 || n>=mxp)  fprintf(stderr,"Invalid perm.no %d.\n",n);
      else
      { while (rp(pptr[n])==2)
        { fprintf(stderr,"That is not a permutation. Try again!\n"); snl(); }
        pno[n]=1;
      }
    }
    else if (strcmp(opt,"pp")==0)
    { scanf("%hd",&n); snl();
      if (n<0 || n>=mxp || pno[n]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",n); continue;}
      p=pptr[n];
      for (i=1;i<=npt;i++) printf("%4d",p[i]); printf("\n");
    }
    else if (strcmp(opt,"ppc")==0)
    { scanf("%hd",&n); snl();
      if (n<0 || n>=mxp || pno[n]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",n); continue;}
      for (i=1;i<=npt;i++) orb[i]=1;
      p=pptr[n]; id=1;
      chct=0;
      for (m=1;m<=npt;m++) if (orb[m])
      { if ((im=p[m])!=m)
        { id=0; orb[im]=0; printf("(%d,%d",m,im);
          chct += (num_digits(m)+num_digits(im)+2);
          while ((im=p[im])!=m)
          { if (chct>=75) { printf(",\n%d",im); chct=num_digits(im);}
            else {printf(",%d",im); chct += (1+num_digits(im));}
            orb[im]=0;
          }
          printf(")");
          chct++;
          if (chct>=72) { printf("\n"); chct=0;}
        }
      }
      if (id) printf("Perm no %d is the identity.\n",n);
      else printf("\n");
    }
    else if (strcmp(opt,"inv")==0)
    { scanf("%hd%hd",&m,&n); snl();
      if (m<0 || m>=mxp || pno[m]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",m); continue;}
      if (n<=0 || n>=mxp)
      { fprintf(stderr,"Invalid perm. no. %d.\n",n); continue;}
      invert(pptr[m],pptr[n]); pno[n]=1;
    }
    else if (strcmp(opt,"pr")==0)
    { scanf("%hd%hd",&m,cp);
      if (m<=0 || m>=mxp)
      { fprintf(stderr,"Invalid perm no. %d\n",m);snl(); continue;}
      fault=0;
      for (i=1;i<= *cp;i++)
      { scanf("%hd",cp+i); n= *(cp+i);
        if (n<0 || n>=mxp || pno[n]==0)
        { fprintf(stderr,"Perm no %d is not defined.\n",n);fault=1; snl();
          break;
        }
      }
      if (fault) continue;
      snl();
      p=pptr[m];
      for (i=1;i<=npt;i++) p[i]=image(i);
      pno[m]=1;
    }
    else if (strcmp(opt,"im")==0)
    { scanf("%hd%hd",&n,&i); snl();
      if (n<0 || n>=mxp || pno[n]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",n); continue;}
      if (i<=0 || i>npt)
      { fprintf(stderr,"Inappropriate point %d.\n",i); continue;}
      printf("%d\n",pptr[n][i]);
    }
    else if (strcmp(opt,"fp")==0)
    { scanf("%hd",&n); snl();
      if (n<0 || n>=mxp || pno[n]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",n); continue;}
      p=pptr[n]; nt=1;
      for (i=1;i<=npt;i++) if (p[i]==i) { nt=0; printf("%4d",i);}
      if (nt) printf("No fixed points.\n"); else printf("\n");
    }
    else if (strcmp(opt,"fpn")==0)
    { scanf("%hd",cp);
      fault=0;
      for (i=1;i<= *cp;i++)
      { scanf("%hd",cp+i); n= *(cp+i);
        if (n<0 || n>=mxp || pno[n]==0)
        { fprintf(stderr,"Perm no %d is not defined.\n",n); fault=1; snl();
          break;
        }
      }
      if (fault) continue;
      snl(); nt=1;
      for (n=1;n<=npt;n++)
      { f=1;
        for (i=1;i<= *cp;i++) if (pptr[cp[i]][n]!=n) { f=0; break;}
        if (f) { nt=0; printf("%4d",n); }
      }
      if (nt) printf("No fixed points.\n"); else printf("\n");
    }
    else if (strcmp(opt,"cyc")==0)
    { scanf("%hd%hd",&n,&i); snl();
      if (i<=0 || i>npt)
      { fprintf(stderr,"Inappropriate point %d.\n",i); continue;}
      if (n<0 || n>=mxp || pno[n]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",n); continue;}
      p=pptr[n];
      if ((im=p[i])==i) printf("%d is fixed under p[%d].\n",i,n);
      else
      { printf("(%d,%d",i,im);
        while ((im=p[im])!=i) printf(",%d",im);
        printf(")\n");
      }
    }
    else if (strcmp(opt,"ord")==0)
    { scanf("%hd",&n); snl();
      if (n<0 || n>=mxp || pno[n]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",n); continue;}
      p=pptr[n]; id=1;
      for (i=1;i<=npt;i++) orb[i]=1;
      ord=1;
      for (m=1;m<=npt;m++) if (orb[m])
      { if ((im=p[m])!=m)
        { id=0; orb[im]=0; len=2;
          while ((im=p[im])!=m) { orb[im]=0; len++; }
          ord=lcm(ord,len);
        }
      }
      if (id) printf("Perm no %d is the identity.\n",n);
      else printf("%d\n",ord);
    }
    else if (strcmp(opt,"orb")==0)
    { scanf("%hd",cp);
      fault=0;
      for (i=1;i<= *cp;i++)
      { scanf("%hd",cp+i); n= *(cp+i);
        if (n<0 || n>=mxp || pno[n]==0)
        { fprintf(stderr,"Perm no %d is not defined.\n",n); fault=1; snl();
          break;
        }
      }
      if (fault) continue;
      snl();
      allorbs();
    }
    else if (strcmp(opt,"eq")==0)
    { scanf("%hd%hd",&m,&n); snl();
      if (n<0 || n>=mxp || pno[n]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",n); continue;}
      if (m<0 || m>=mxp || pno[m]==0)
      { fprintf(stderr,"Perm no %d is not defined.\n",m); continue;}
      p=pptr[m]; q=pptr[n]; eq=1;
      for (i=1;i<=npt;i++) if (p[i]!=q[i]) {eq=0; break;}
      if (eq) printf("Permutations are equal.\n");
      else printf("Permutations are not equal on point %d.\n",i);
    }
    else if (strcmp(opt,"rb")==0)
    { snl(); printf("Input base points, preceded by their number.\n");
      scanf("%hd",&nb);
      if (nb>=mb)
      { fprintf(stderr,"Too many base points. Increase MB.\n"); return(-1);}
      for (i=1;i<=nb;i++) scanf("%hd",base+i);
      snl();
    }
    else if ((y=strcmp(opt,"opord"))==0 || strcmp(opt,"op")==0)
    { if (y==0 && nb==0)
      { fprintf(stderr,"Order can only be computed when base is known.\n");
        continue;
      }
      scanf("%s",flnm); snl(); op=fopen(flnm,"w");
      printf("Input perm nos to be saved, preceded by their number.\n");
      scanf("%hd",&n); fprintf(op,"%3d %4d%4d%4d\n",npt,n,nb,0);
      if (nb!=0)
      if (npt>=10000)
      { for (i=1;i<=nb;i++) fprintf(op,"%6d",base[i]); fprintf(op,"\n");}
      else
      if (npt>=1000)
      { for (i=1;i<=nb;i++) fprintf(op,"%5d",base[i]); fprintf(op,"\n");}
      else
      { for (i=1;i<=nb;i++) fprintf(op,"%4d",base[i]); fprintf(op,"\n");}
      f=0;
      for (i=1;i<=n;i++)
      { scanf("%hd",&m);
        if (m<0 || m>=mxp || pno[m]==0)
        { printf("Perm no %d is not defined.\n",m);
          fclose(op); snl(); unlink(flnm); f=1; break;
        }
        printvec(pptr[m],0);
      }
      if (f) continue;
      snl(); fclose(op);
      if (y==0)
      { sprintf(sysstring,"cp %s optxxx.ip",flnm);
        system(sysstring); system("gprun -b optxxx ip ip");
        unlink("optxxx.ip");
      }
    }
    else if (strcmp(opt,"rf")==0)
    { scanf("%hd",&n); scanf("%s",flnm); snl();
      if ((ip=fopen(flnm,"r"))==0)
      { fprintf(stderr,"Cannot open %s.\n",flnm); continue; }
      fscanf(ip,"%hd%hd%hd%hd",&i,&np,&j,&m); seeknln();
      if (i!=npt)
      { fprintf(stderr,"npt does not agree.\n"); fclose(ip); continue;}
      if (j!=0) seeknln();
      if (m!=0) seeknln();
      if (n<=0 || np+n-1>=mxp)
      { fprintf(stderr,"Not enough perm space to read perms from file.");
        fclose(ip); continue;
      }
      for (i=1;i<=np;i++)
      { if (readperm(pptr[i+n-1])==2)
        { fprintf(stderr,"Perm no %i is not a permutation.\n");
          pno[i+n-1]=0; break;
        }
        pno[i+n-1]=1; seeknln();
      }
      fclose(ip);
    }
    else if (strcmp(opt,"q")==0) {snl(); break;}
    else {printf("Invalid option.\n"); snl();}
  }
  exit(0);
}
コード例 #18
0
ファイル: mcgeo.c プロジェクト: fgregg/watershed-cuts
int32_t main()
{
  mat33 m, mr, mp;
  vec3 b;
  vec3 sol;

  mat22 m2, mr2, mp2;
  vec2 b2;
  vec2 sol2;

  triangle t;

  mesh * msh;

  m[0][0] = 1.0;
  m[0][1] = 2.0;
  m[0][2] = 3.0;
  m[1][0] = 1.0;
  m[1][1] = 5.0;
  m[1][2] = 6.0;
  m[2][0] = 2.0;
  m[2][1] = 3.0;
  m[2][2] = 1.0;
  b[0] = 10.0;
  b[1] = 5.0;
  b[2] = 15.0;

  printmat((double *)m, 3, 3);
  printvec(b, 3);

  if (solsyst3(m, b, sol) == 0)
    printf("determinant nul\n");

  printvec(sol, 3);

  multmat3vec3(m, sol, b);

  printvec(b, 3);

  invmat3(m, mr);

  printmat((double *)mr, 3, 3);

  multmat3mat3(m, mr, mp);

  printmat((double *)mp, 3, 3);

  m2[0][0] = 1.0;
  m2[0][1] = 2.0;
  m2[1][0] = 1.0;
  m2[1][1] = 5.0;
  b2[0] = 10.0;
  b2[1] = 5.0;

  printmat((double *)m2, 2, 2);
  printvec(b2, 2);

  if (solsyst2(m2, b2, sol2) == 0)
    printf("determinant nul\n");

  printvec(sol2, 2);

  multmat2vec2(m2, sol2, b2);

  printvec(b2, 2);

  invmat2(m2, mr2);

  printmat((double *)mr2, 2, 2);

  multmat2mat2(m2, mr2, mp2);

  printmat((double *)mp2, 2, 2);

  t.xa = 1.0;
  t.ya = 1.0;
  t.xb = 2.0;
  t.yb = 1.0;
  t.xc = 1.0;
  t.yc = 2.0;

  if (inittriangle(&t) == 0)
    printf("mauvais triangle\n");

  printtriangle(&t);

  msh = readmesh("essai.msh");
  printmesh(msh);  
  freemesh(msh);  

}
コード例 #19
0
ファイル: main.cpp プロジェクト: dlfivefifty/Ultraspherical
int main(int argc, const char * argv[])
{
    
    if (argc > 1) {
        switch (argv[1][0]) {
            case 'c':
                cosbandExample();
                return 0;
            case 's':
                smallbandExample();
                return 0;
            case 'a':
                airyExample();
                return 0;
            default:
                break;
        }
    }
    
    if(argc < 4) {
        cout <<endl<< "Usage: "<<endl<<endl<<"\t\tultraspherical cm cp a0 a1 ... an"<<endl<<endl<<"solves the ODE "<<endl<<endl<<"\t\tu'' + (a0 T_0(x) + ... + an T_n(x)) u = 0, u(-1) = cm, u(1) = cp"<<endl<<endl;
        
        return 0;
    }
    
    
    vector<double> args;
    vector<double> b;
    double a;
    sscanf(argv[1],"%lf",&a);    
    b.push_back(a);
    sscanf(argv[2],"%lf",&a);    
    b.push_back(a);          
    b.push_back(0);
    
    for (int i = 3; i < argc; i++) {
        sscanf(argv[i],"%lf",&a);
        args.push_back(a);
    }
    

    
    FilledBandedMatrix *drbnd = DirichletD2ConvertMultiplicationMatrix(&args, &args);

    
    drbnd->increaseSize();
//    drbnd->print();
    
    
    
    
    vector<double> c = QRSolve(drbnd,b);
    
    printvec(c);
    
//    string args(argv[0]);
    
    

    

    
    delete drbnd;
    
    
//    cosbandExample();


    
    return 0;
}
コード例 #20
0
ファイル: hybdrv.c プロジェクト: jnorthrup/jmodelica
/* Main program */
int main(int argc, char **argv)
{

    int i,ic,k,n,ntries;
    struct refnum hybrdtest;
    int info;

    int na[60];
    int nf[60];
    int nj[60];
    int np[60];
    int nx[60];

    real factor,fnorm1,fnorm2,tol;

    real fnm[60];
    real fvec[40];
    real x[40];

    real wa[2660];
    const int lwa = 2660;

    tol = sqrt(__cminpack_func__(dpmpar)(1));

    ic = 0;

    for (;;) {
        scanf("%5d%5d%5d\n", &hybrdtest.nprob, &n, &ntries);
        if (hybrdtest.nprob <= 0.)
            break;

        factor = 1.;

        for (k = 0; k < ntries; ++k, ++ic) {
            hybipt(n,x,hybrdtest.nprob,factor);

            vecfcn(n,x,fvec,hybrdtest.nprob);

            fnorm1 = __cminpack_func__(enorm)(n,fvec);

            printf("\n\n\n\n      problem%5d      dimension%5d\n\n", hybrdtest.nprob, n);

            hybrdtest.nfev = 0;
            hybrdtest.njev = 0;

            info = __cminpack_func__(hybrd1)(fcn,&hybrdtest,n,x,fvec,tol,wa,lwa);

            fnorm2 = __cminpack_func__(enorm)(n,fvec);

            np[ic] = hybrdtest.nprob;
            na[ic] = n;
            nf[ic] = hybrdtest.nfev;
            hybrdtest.njev /= n;
            nj[ic] = hybrdtest.njev;
            nx[ic] = info;

            fnm[ic] = fnorm2;

            printf("\n      initial l2 norm of the residuals%15.7e\n"
                   "\n      final l2 norm of the residuals  %15.7e\n"
                   "\n      number of function evaluations  %10d\n"
                   "\n      number of Jacobian evaluations  %10d\n"
                   "\n      exit parameter                  %10d\n"
                   "\n      final approximate solution\n\n",
                   (double)fnorm1, (double)fnorm2, hybrdtest.nfev, hybrdtest.njev, info);
            printvec(n, x);

            factor *= 10.;

        }

    }

    printf("\f summary of %d calls to hybrd1\n", ic);
    printf("\n nprob   n    nfev   njev  info  final l2 norm\n\n");
    for (i = 0; i < ic; ++i) {
        printf("%4d%6d%7d%7d%6d%16.7e\n",
               np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]);
    }
    exit(0);
}
コード例 #21
0
ファイル: model.cpp プロジェクト: mifumagalli/cluster-cloc
void model::mix_sfr_grid(double err){
   sfr_err = err;
   vector<double> wgts_y;
   //calculate the vector the determines the weights for the mixing
   double fac = 1./(sfr_err*sqrt(2*3.14159265359));
   long zero_ind=99999999999, ct=0;
   long num_ind=0;
   double diff_val=0;
   for(int i =0;i<(long)sfr_gridx.size();i++){
      if(sfr_gridx[i]-sfr_gridx[0] > 5*sfr_err){
         num_ind = i;
         diff_val = sfr_gridx[i]-sfr_gridx[0];
         break;
      }
   }
//   cout<<diff_val<<endl;
   for(double xx= -diff_val;xx<diff_val + sfr_step*.98; xx+=sfr_step){  
          if(fabs(xx) < 1e-8) zero_ind=ct;
          ct++;
          wgts_y.push_back(fac*exp(-0.5*(xx*xx)/(sfr_err*sfr_err)));
   }
   printvec(wgts_y, "wgts_y.txt");
   //calculate some stuff to do the mixing
   long xsz = (long) sfr_gridx.size();
   long wgts_ysz = (long) wgts_y.size();
   long wgts_wing = wgts_ysz - zero_ind-1; // we go +- wgts_wing of central point
   //define the mixed_sfr_grid and size it appropriately
   mixed_sfr_grid.resize(sfr_gridx.size());
   for(int i=0; i<(long)sfr_gridx.size();i++){
         mixed_sfr_grid[i].resize(x.size());
   } //things get automatically intiailized to 0
   if(wgts_ysz != wgts_wing*2+1){
     cout<<"model::mix_sfr_grid wgts is not the right dimension.. logic bug"<<endl;
     cout<<wgts_ysz<<"\t"<<wgts_wing<<"\t"<<zero_ind<<endl;
     exit(1);
   }
   double sum=0;
   double buffer;
   for(int i=0; i<(long)sfr_gridx.size();i++){ //loop over SFR
         sum=0;
         //find the sum of the wgts for renormalization later
         for(int j= max((long)0,i-wgts_wing); j< min(i+wgts_wing, xsz-1); j++){
             sum += wgts_y[j-i+zero_ind];
         }
//if(sum == 0){
//cout<<"WTF"<<endl;
//cout<<sum<<endl;
//exit(1);
//}
         for(int j= max((long)0,i-wgts_wing); j< min(i+wgts_wing, xsz-1); j++){
             //loop over smoothing kernel
             for(int k =0;k<(long)x.size();k++){
                buffer = wgts_y[j-i+zero_ind]*sfr_grid[j][k];
                if(buffer != buffer) buffer =0;
                mixed_sfr_grid[i][k] += buffer;
             }
         }
         //divide by the sum from above
         for(int k =0;k<(long)x.size();k++){
            mixed_sfr_grid[i][k] /= sum;
         }
   }

    
}
コード例 #22
0
ファイル: pagerank-mpi.c プロジェクト: Blother/Strawman_MPI
int main(int argc, char* argv[]){
    MPI_Init(0,0);
    double start, elapsed, elapsed2, local_elapsed;
    int iters; 
    
    /* get size and rank */
    int g_size;
    int my_rank;
    MPI_Comm_size(MPI_COMM_WORLD, &g_size);
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

    /* get args */
    int n = 100;
    double d = 0.85; // damping variable
    double eps = 0.000000001;
    if (argc <= 1 || argc > 4) {
        printf("usage: %s num-pages damping-factor(0.85) epsilon(0.0001)\n", argv[0]);
        return 0;
    }
    if (argc > 1) 
        n = atoi(argv[1]);
    if (argc > 2) 
        d = atof(argv[2]);
    if (argc > 3) 
        eps = atof(argv[3]);

    /* initialize y0 and y */
    double *y0  = (double *) malloc(n*sizeof(double));
    double *y  = (double *) malloc(n*sizeof(double));
    uniform(y0, n);
    memset(y, 0, sizeof (double) * n);
    
    
    struct SparseMatrixHandle S;
    struct SparseMatrixHandle local_S;
    int *sizes = NULL, *offsets = NULL;

    if (my_rank == 0) {
        printf("initial probabilities\n");
        printvec(y0, n);

        randomLM(&S, n);//, my_rank); // The link matrix 

        if (n <= 100) writeSM(&S, 50);  

        printf("dimension is %d, nnz is %d, damper is %f, epsilon is %g\n\n",
                S.coldim, S.nnz, d, eps);
        int i = 0; 
        /* fill sizes and offsets for scatter */
        sizes = (int *) malloc (sizeof(int) * g_size);
        offsets = (int *) malloc (sizeof(int) * g_size);
        for ( ; i < g_size; i++) {
            offsets[i] = offset(i, g_size, S.nnz);
            sizes[i] = size (i, g_size, S.nnz);
        }
    }

    /* broadcast everything dimensions and nnz */
    MPI_Bcast(&S.coldim, 1, MPI_INT, 0, MPI_COMM_WORLD);
    MPI_Bcast(&S.rowdim, 1, MPI_INT, 0, MPI_COMM_WORLD);
    MPI_Bcast(&S.nnz, 1, MPI_INT, 0, MPI_COMM_WORLD);
    
    /* broadcast C */
    double *C = (double *) malloc(S.coldim*sizeof(double));
    if (my_rank == 0) scale(C, &S);
    MPI_Bcast(C, S.coldim, MPI_DOUBLE, 0, MPI_COMM_WORLD);

    /* initialize local_S */
    local_S.nnz = size (my_rank, g_size, S.nnz); 
    local_S.coldim = S.coldim;
    local_S.rowdim = S.rowdim;
    local_S.val = (double *) malloc (sizeof(double) * local_S.nnz);
    local_S.row = (int *) malloc (sizeof(int) * local_S.nnz);
    local_S.col = (int *) malloc (sizeof(int) * local_S.nnz);

    /* Scatter attributes */
    MPI_Scatterv(S.val, sizes, offsets, MPI_DOUBLE, local_S.val, local_S.nnz, MPI_DOUBLE, 0, MPI_COMM_WORLD);
    MPI_Scatterv(S.col, sizes, offsets, MPI_INT, local_S.col, local_S.nnz, MPI_INT, 0, MPI_COMM_WORLD);
    MPI_Scatterv(S.row, sizes, offsets, MPI_INT, local_S.row, local_S.nnz, MPI_INT, 0, MPI_COMM_WORLD);
    
    /* do it */
    start = MPI_Wtime();
    iters = solve(&local_S, C, d, y0, y, eps, strawman_mvpSM);
    local_elapsed = MPI_Wtime() - start;
    
    /* reduce time with MAX to get total time */
    MPI_Reduce (&local_elapsed, &elapsed, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
    
    /* print it out */
    if (my_rank == 0) {
        printf("final (page rank) probabilities, %d iterations in time %f\n", 
                iters, elapsed);
        printvec(y, n); printf("\n");
        free(sizes);
        free(offsets);
    }
    
    /* let them all freeee */

    free(C); 
    free(y); 
    free(y0);
    free(local_S.val);
    free(local_S.row);
    free(local_S.col);

    MPI_Finalize();
    return 0;
}
コード例 #23
0
ファイル: chkdrv.c プロジェクト: jnorthrup/jmodelica
/* Main program */
int main(int argc, char **argv)
{
    /* Initialized data */
    const int a[14] = { 0,0,0,1,0,0,0,1,0,0,0,0,1,0 };
    real cp = .123;
    /* Local variables */
    int i, n;
    real x1[10], x2[10];
    int na[14], np[14];
    real err[10];
    int lnp;
    real fjac[10*10];
    const int ldfjac = 10;
    real diff[10];
    real fvec1[10], fvec2[10];
    int nprob;
    real errmin[14], errmax[14];

    for (;;) {
        scanf("%5d%5d\n", &nprob, &n);
        if (nprob <= 0) {
            break;
        }

        hybipt(n,x1,nprob,1.);
        for(i=0; i<n; ++i) {
            x1[i] += cp;
            cp = -cp;
        }

        printf("\n\n\n      problem%5d      with dimension%5d   is  %c\n\n", nprob, n, a[nprob-1]?'T':'F');

        __cminpack_func__(chkder)(n,n,x1,NULL,NULL,ldfjac,x2,NULL,1,NULL);
        vecfcn(n,x1,fvec1,nprob);
        errjac(n,x1,fjac,ldfjac,nprob);
        vecfcn(n,x2,fvec2,nprob);
        __cminpack_func__(chkder)(n,n,x1,fvec1,fjac,ldfjac,NULL,fvec2,2,err);

        errmin[nprob-1] = err[0];
        errmax[nprob-1] = err[0];
        for(i=0; i<n; ++i) {
            diff[i] = fvec2[i] - fvec1[i];
            if (errmin[nprob-1] > err[i])
                errmin[nprob-1] = err[i];
            if (errmax[nprob-1] < err[i])
                errmax[nprob-1] = err[i];
        }

        np[nprob-1] = nprob;
        lnp = nprob;
        na[nprob-1] = n;

        printf("\n      first function vector   \n\n");
        printvec(n, fvec1);
        printf("\n\n      function difference vector\n\n");
        printvec(n, diff);
        printf("\n\n      error vector\n\n");
        printvec(n, err);
    }

    printf("\f summary of %3d tests of chkder\n", lnp);
    printf("\n nprob   n    status     errmin         errmax\n\n");

    for (i = 0; i < lnp; ++i) {
        printf("%4d%6d      %c   %15.7e%15.7e\n",
               np[i], na[i], a[i]?'T':'F', (double)errmin[i], (double)errmax[i]);
    }
    exit(0);
}
コード例 #24
0
ファイル: count5.cpp プロジェクト: maxatkin/CDT-dimer-counter
void printCDTskel(vector<vector<unsigned int> > cdt_skel){
  for(unsigned int i = 0; i < cdt_skel.size(); i++){
    printvec(cdt_skel[i]);
  }
  cout << endl;
}
コード例 #25
0
ファイル: main.cpp プロジェクト: incredibleray/randomcpp
int main() {

// typedef map<char, int> charCnt;
// typedef map<string,  charCnt> occurMap;
// set<int> s;
// 
// s.insert(3);
// s.insert(9);
// s.insert(31);
// s.insert(34);
// 
// set<int>::iterator it=s.begin();
// 
// list<int> v1, v2;
// 
// v1.push_back(2);
// v1.push_back(4);
// 
// v2.push_back(4);
// v2.push_back(2);
// // v2.push_back(6);
// 
// cout << *it << "\n";
// 
// list<int> v3=v1;
// list<int> v4=v2;
// 
// pipeStock vs1, vs2;
// vs1.push_back(v1);
// vs1.push_back(v2);
// vs2.push_back(v4);
// vs2.push_back(v3);
// 
// if (v1 == v2) cout << "two vectors are the same" << "\n";
// v1.sort();
// v2.sort();
// if (v1 == v2) cout << "two vectors are the same" << "\n";
// 
// if (vs1 == vs2) cout << "two lists of lists are the same" << "\n";
// vs1.sort();
// vs2.sort();
// if (vs1 == vs2) cout << "two lists of lists are the same" << "\n";
pipeStock ps(2);

ps[1].push_back(2);
ps[0].push_back(4);

pipe p(2), q;
p[0]=4;

ps.push_back(p);
ps.push_back(q);
p[0]=6;

ps[3].push_back(11);

cout << ps[1][0] << "\n";
cout << ps[0][0] << "\n";
cout << ps[2][0] << "\n";
cout << ps[3][0] << "\n";
cout << ps.size() << "\n";

p.push_back(3);
printvec(p);

printdvec(ps);

cutstock cs(10);

pipeStock sps=cs.mapIndex(ps);

printdvec(sps);

const int arr[] = {4,1, 3,4, 9, 2, 3, 5,7,1, 1, 2, 8};
vector<int> r (arr, arr + sizeof(arr) / sizeof(arr[0]) );
// cout << "creating pipe stock of size " <<  r.size() << "\n";
// pipeStock s(r.size());
pipeStock s;
cout << cs.processRequest(r, s) << "\n";
cout << "memory hits " << cs.memHit << "\n";
// occurMap m;
// 
// charCnt c;
// ifstream f("tomasc.txt");
// string ftext, line;
// 
//   if (f.is_open())
//   {
//   	int i=0;
//     while (i < 20 && getline (f,line) )
//     {
// //       cout << line << '\n';
//       ftext+=line;
// //       ftext+='\n';
//       ftext+=' ';
//       i++;
//     }
//     f.close();
//   }
//   
//   transform(ftext.begin(), ftext.end(), ftext.begin(), ::tolower);
// //   cout << ftext << '\n';
//   
// c['a']=1;
// 
// m["bc"]=c;
// m["bc"]['b']=m["bc"]['b']+1;
// 
// cout << m["bc"]['a'] << "\n";
// cout << m["bc"]['b'] << "\n";
// 
// charCnt cc;
// cc['c']=2;
// cc['d']=4;
// cc['z']=1;
// cc['d']=7;
// 
// cout <<  countAll(cc) << "\n" << cc['d'] << "\n";
// 	
// charCnt cc2=cc;
// cc2['x']=3;
// 
// cout <<  countAll(cc) << "\n" << countAll(cc2) << "\n" << cc['x'] << "\n";
// 	
// charCnt::const_iterator it2 = cc.begin();
// advance(it2, 1);
// cout <<  it2->first << " " << it2->second << "\n";
// 
// markovModel mmdl(6);
// 
// // mmdl.addOccurence("acd", 'b');
// 
// // mmdl.printMap();
// 
// 
// 
// mmdl.countOccurrence(ftext);
// // mmdl.printMap();
// 
// cout << "--------------------------------------------------------\n";
// 
// 
// mmdl.constructProbMap();
// // mmdl.printProbMap();
// 
// cout << mmdl.mostFrequent() << "\n";
// 
// vector<double> v=mmdl.probVector("he ");
// 
// for( std::vector<double>::const_iterator i = v.begin(); i != v.end(); ++i)
//     std::cout << *i << ' ';
// 
// cout <<  "\n" << mmdl.randomGeneration(mmdl.mostFrequent(), 10) << "\n";
// 
// cout <<  "\n" << mmdl.randomGeneration(mmdl.mostFrequent(), 10) << "\n";
// 
// char ca='a';
// char& cr=ca;
// char cb=cr;
// cout << cb << "\n";
// cb='b';
// cout << ca << cr << "\n";


// cout << "Hello\n"; 
return 0; }