@all +tabstop

This is a discussion on @all +tabstop within the C Programming forums, part of the General Programming Boards category; Could you please tell me how many cores was the PC that u used to run the program with the ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    79

    @all +tabstop

    Could you please tell me how many cores was the PC that u used to run the program with the gaussian number generator that run at your PC but not at mine? I am still trying to find out why it doesn't go through GENER01.c when I compile it. While you take warnings for the GENER01.c code I am not taking anything for this and take only for the gauss2.c and check.c the same as yours.

    At everyone:
    Could you please try to compile this code and run it by
    gcc -o check -Wall -Wextra gauss2.c GENER01.c check.c

    GENER01.c
    Code:
    #include <stdio.h>
    #include<math.h>
    #define znew (z=36969*(z&65535)+(z>>16))
    #define wnew (w=18000*(w&65535)+(w>>16))
    #define MWC ((znew<<16)+wnew )
    #define SHR3 (jsr^=(jsr<<17), jsr^=(jsr>>13), jsr^=(jsr<<5))
    #define CONG (jcong=69069*jcong+1234567)
    #define FIB ((b=a+b),(a=b-a))
    #define KISS ((MWC^CONG)+SHR3)
    #define LFIB4 (c++,t[c]=t[c]+t[UC(c+58)]+t[UC(c+119)]+t[UC(c+178)])
    #define SWB (c++,bro=(x<y),t[c]=(x=t[UC(c+34)])-(y=t[UC(c+19)]+bro))
    #define UNI (KISS*2.328306e-10)
    #define VNI ((long) KISS)*4.656613e-10
    #define UC (unsigned char) /*a cast operation*/
    typedef unsigned long UL;
    /* Global static variables: */
    static UL z=362436069, w=521288629, jsr=123456789, jcong=380116160;
     static UL a=224466889, b=7584631, t[256];
    /* Use random seeds to reset z,w,jsr,jcong,a,b, and the table
    t[256]*/
    /*static UL x=0,y=0,bro; static unsigned char c=0;*/
    /* Example procedure to set the table, using KISS: */
    void settable(UL i1,UL i2,UL i3,UL i4,UL i5, UL i6)
    { int i; z=i1;w=i2,jsr=i3; jcong=i4; a=i5; b=i6;
    for(i=0;i<256;i=i+1) t[i]=KISS;
    }
    
    int Threepoint(){
      return(KISS%3);
    }
    int Eightpoint(){
      return(KISS%8);
    }
    int Fourpoint(){
      return(KISS%4);
    }
    
    double GENER02(double lambda){
      /* lambda > 0 */
      /* 
         function is a translation from P.E. Kloeden E. Platen and H. Schurz 
         Numerical Solution of SDE Trough Computer experiments, Springer 1994.
         page 11.
      */
      double xu;
      double Uniform();
      xu=Uniform();
      if(xu>0.0)
        xu=-log(xu)/lambda;
      else
        xu=0.0;
      return(xu);
    }     
    
    double Uniform(){
      return((double) UNI);
    }
    
    double GENER01(double sqrtDT){
      /*  *WT=-sqrtDT+2*(KISS%2)*sqrtDT; */
      if(KISS%2)
        return(-sqrtDT);
      else
        return(sqrtDT);
    }
    
    double GENER03(double sqrt3DT){
      long I;
      double Y;
      /* generate a random variable on set {1,2,3,4,5,6} with uniform prob. */
    
      I = KISS%6+1; /* six point random variable 1, 2,...,6.
    		   Each element prob. 1/6 */
      if(I>2) /* prob. 2/3 */
        Y=0.0;
      else{
        if(I==1) /* prob. 1/6 */
          Y=-sqrt3DT;
        else    /* prob. 1/6 */
          Y=sqrt3DT;
      }
      /*  printf("%g  %d\n",Y,I); */
      /*  printf("%g\n",Y); */
      return( Y );
    }
    gauss2.c

    Code:
    #include<math.h>
    
    /* Polar Marsaglia method for gaussian dist. pseudo-random no.generator*/
    
    void gauss2(double *z1,double *z2){
      double y, v1, v2,r, fac;
      double Uniform();
      r=100.0;
      while(r>1.0 || r<=0.0){
        y=Uniform();     /* rand. no [0:1] */
        v1 = 2.0*y - 1.0;                /* rand. no [-1:1] */
        y=Uniform();
        v2 = 2.0*y - 1.0;                /* rand. no [-1:1] */
        r = v1 * v1 + v2 * v2; 
        }
      fac = (sqrt( -2.0*log(r) / r));
      *z1 = v1 * fac;
      *z2 = v2 * fac; 
      return;
    }
    check.c

    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <time.h>
    #include <math.h>
    typedef unsigned long UL;
    #define pi 3.14159
    double Uniform();
    void gauss2(double *z1,double *z2);
    
    
    int main()
    
    {
    
      int i;
      int j=100;
    
     double z1, z2;
    
     UL i1, i2,i3,i4,i5,i6; /* to initialize Uniform (AND gauss2) */
        i1=time(NULL); i2= i1+23;i3= i1+243;i4= i1+26;i5= i2+28;i6= i1+27;
      settable(i1,i2,i3,i4,i5,i6);
    
        for(i=0;i<j;i++)
          {
    	printf("OK\n");
      gauss2(&z1,&z2);
      printf("%lf",z1);
    printf("ok\n"); 
         }
    }
    I would appreciate to give some feedback about this situation

  2. #2
    Registered User
    Join Date
    Apr 2010
    Posts
    79
    for those who have -32 architecture have to add -m32 to compile

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. execlp function / digital mars compiler
    By claydan7 in forum C++ Programming
    Replies: 4
    Last Post: 08-24-2009, 08:51 PM
  2. passwd program
    By cus in forum C Programming
    Replies: 13
    Last Post: 01-07-2009, 06:57 PM
  3. TabStop
    By kristoffer in forum Windows Programming
    Replies: 2
    Last Post: 04-11-2004, 10:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21