Back to index

radiance  4R0+20100331
Defines | Functions | Variables
urind.c File Reference
#include "copyright.h"
#include "random.h"

Go to the source code of this file.

Defines

#define NBITS   32 /* number of bits in an integer */
#define bitcount(i)

Functions

int urind (int s, int i)

Variables

static const char RCSid [] = "$Id: urind.c,v 2.4 2003/07/17 09:21:29 schorsch Exp $"
static char bctab [256]

Define Documentation

#define bitcount (   i)
Value:
(bctab[(i)>>24&0xff]+bctab[(i)>>16&0xff]+ \
                            bctab[(i)>>8&0xff]+bctab[(i)&0xff])

Definition at line 33 of file urind.c.

#define NBITS   32 /* number of bits in an integer */

Definition at line 11 of file urind.c.


Function Documentation

int urind ( int  s,
int  i 
)

Definition at line 42 of file urind.c.

{
       register int  ss, k;
       int  left;

       ss = s*1103515245 + 12345;
       left = 0;
       for (k = i/NBITS; k--; ) {
              left += bitcount(ss);
              ss = ss*1103515245 + 12345;
       }
       for (k = i&(NBITS-1); k--; ss >>= 1)
              left += ss & 1;
       if (ss & 1)
              return(s-left-1);
       return(s-left+i);
}

Variable Documentation

char bctab[256] [static]
Initial value:
 {
              0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
              1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
              1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
              2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
              1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
              2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
              2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
              3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
              1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
              2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
              2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
              3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
              2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
              3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
              3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
              4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
       }

Definition at line 13 of file urind.c.

const char RCSid[] = "$Id: urind.c,v 2.4 2003/07/17 09:21:29 schorsch Exp $" [static]

Definition at line 2 of file urind.c.