parent
255433ed94
commit
6285c904f7
|
@ -1,221 +0,0 @@
|
|||
char *malloc ();
|
||||
|
||||
main ()
|
||||
{
|
||||
char *buf1;
|
||||
int i;
|
||||
int cnt;
|
||||
|
||||
buf1 = malloc (8193);
|
||||
|
||||
read (0, buf1, 8192);
|
||||
|
||||
for (i = 500; i > 0; i--)
|
||||
cnt = shift (buf1, 8192, '\n');
|
||||
printf ("%d ", cnt);
|
||||
|
||||
for (i = 500; i > 0; i--)
|
||||
cnt = shift_xor (buf1, 8192, '\n');
|
||||
printf ("%d ", cnt);
|
||||
|
||||
for (i = 500; i > 0; i--)
|
||||
cnt = bitfield (buf1, 8192, '\n');
|
||||
printf ("%d ", cnt);
|
||||
|
||||
for (i = 500; i > 0; i--)
|
||||
cnt = char_autoincr (buf1, 8192, '\n');
|
||||
printf ("%d ", cnt);
|
||||
|
||||
for (i = 500; i > 0; i--)
|
||||
cnt = xorand (buf1, 8192, '\n');
|
||||
printf ("%d ", cnt);
|
||||
}
|
||||
|
||||
shift (b1, n, c)
|
||||
int *b1;
|
||||
int n;
|
||||
char c;
|
||||
{
|
||||
int nn;
|
||||
int cnt = 0;
|
||||
int w1;
|
||||
|
||||
for (nn = n / (4 * 4); nn > 0; nn--)
|
||||
{
|
||||
w1 = *b1++;
|
||||
if ((char)w1 == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
w1 = *b1++;
|
||||
if ((char)w1 == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
w1 = *b1++;
|
||||
if ((char)w1 == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
w1 = *b1++;
|
||||
if ((char)w1 == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
if ((char)(w1 >>= 8) == c) cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
shift_xor (b1, n, c)
|
||||
int *b1;
|
||||
int n;
|
||||
char c;
|
||||
{
|
||||
int nn;
|
||||
int cnt = 0;
|
||||
int w1;
|
||||
int cccc = (c << 24) | (c << 16) | (c << 8) | c;
|
||||
|
||||
for (nn = n / (4 * 4); nn > 0; nn--)
|
||||
{
|
||||
w1 = *b1++ ^ cccc;
|
||||
if ((char)w1 == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
w1 = *b1++ ^ cccc;
|
||||
if ((char)w1 == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
w1 = *b1++ ^ cccc;
|
||||
if ((char)w1 == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
w1 = *b1++ ^ cccc;
|
||||
if ((char)w1 == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
if ((char)(w1 >>= 8) == 0) cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
typedef
|
||||
struct
|
||||
{
|
||||
unsigned b0:8;
|
||||
unsigned b1:8;
|
||||
unsigned b2:8;
|
||||
unsigned b3:8;
|
||||
} foo;
|
||||
|
||||
bitfield (b1, n, c)
|
||||
foo *b1;
|
||||
int n;
|
||||
char c;
|
||||
{
|
||||
int nn;
|
||||
int cnt = 0;
|
||||
register foo w1;
|
||||
|
||||
for (nn = n / (4 * 4); nn > 0; nn--)
|
||||
{
|
||||
w1 = *b1++;
|
||||
if (w1.b0 == c) cnt++;
|
||||
if (w1.b1 == c) cnt++;
|
||||
if (w1.b2 == c) cnt++;
|
||||
if (w1.b3 == c) cnt++;
|
||||
w1 = *b1++;
|
||||
if (w1.b0 == c) cnt++;
|
||||
if (w1.b1 == c) cnt++;
|
||||
if (w1.b2 == c) cnt++;
|
||||
if (w1.b3 == c) cnt++;
|
||||
w1 = *b1++;
|
||||
if (w1.b0 == c) cnt++;
|
||||
if (w1.b1 == c) cnt++;
|
||||
if (w1.b2 == c) cnt++;
|
||||
if (w1.b3 == c) cnt++;
|
||||
w1 = *b1++;
|
||||
if (w1.b0 == c) cnt++;
|
||||
if (w1.b1 == c) cnt++;
|
||||
if (w1.b2 == c) cnt++;
|
||||
if (w1.b3 == c) cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
char_autoincr (b1, n, c)
|
||||
char *b1;
|
||||
int n;
|
||||
char c;
|
||||
{
|
||||
int cnt = 0;
|
||||
char *bend = b1 + n;
|
||||
*bend = c;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
while (*b1++ != c)
|
||||
;
|
||||
cnt++;
|
||||
if (b1 > bend)
|
||||
break;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
xorand (b1, n, c)
|
||||
int *b1;
|
||||
int n;
|
||||
unsigned char c;
|
||||
{
|
||||
int xm = ((int) c << 24) | ((int) c << 16) | ((int) c << 8) | ((int) c);
|
||||
byte_match_count2 (b1, n, xm, 0xff000000, 0xff0000, 0xff00, 0xff);
|
||||
}
|
||||
|
||||
byte_match_count2 (buf, n, xm, m1, m2, m3, m4)
|
||||
int *buf;
|
||||
int n;
|
||||
uint m1, m2, m3, m4;
|
||||
{
|
||||
int w, cnt = 0;
|
||||
int *bp;
|
||||
|
||||
n /= 4;
|
||||
|
||||
buf[n] = xm;
|
||||
|
||||
bp = buf;
|
||||
while (bp < buf + n)
|
||||
{
|
||||
w = *bp++ ^ xm;
|
||||
cnt += ((m1 & w) == 0);
|
||||
cnt += ((m2 & w) == 0);
|
||||
cnt += ((m3 & w) == 0);
|
||||
cnt += ((m4 & w) == 0);
|
||||
|
||||
w = *bp++ ^ xm;
|
||||
cnt += ((m1 & w) == 0);
|
||||
cnt += ((m2 & w) == 0);
|
||||
cnt += ((m3 & w) == 0);
|
||||
cnt += ((m4 & w) == 0);
|
||||
|
||||
w = *bp++ ^ xm;
|
||||
cnt += ((m1 & w) == 0);
|
||||
cnt += ((m2 & w) == 0);
|
||||
cnt += ((m3 & w) == 0);
|
||||
cnt += ((m4 & w) == 0);
|
||||
|
||||
w = *bp++ ^ xm;
|
||||
cnt += ((m1 & w) == 0);
|
||||
cnt += ((m2 & w) == 0);
|
||||
cnt += ((m3 & w) == 0);
|
||||
cnt += ((m4 & w) == 0);
|
||||
}
|
||||
return cnt;
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/* EXTRA_OPTIONS: -fcaller-saves */
|
||||
|
||||
extern char *malloc();
|
||||
|
||||
main()
|
||||
{
|
||||
char w[1000];
|
||||
int i, j, nres, t[1000];
|
||||
float dv, (**dmat)[4][4];
|
||||
short at1, at2;
|
||||
|
||||
nres = 200;
|
||||
|
||||
for (i = 0; i < nres; i++)
|
||||
{
|
||||
w[i] = rand() & 15;
|
||||
t[i] = 0;
|
||||
}
|
||||
|
||||
dmat = (float (**)[4][4]) malloc(nres * sizeof(*dmat));
|
||||
if (!dmat)
|
||||
return 1;
|
||||
for (i = 0; i < nres; i++)
|
||||
{
|
||||
dmat[i] = (float (*)[4][4]) malloc(nres * sizeof(**dmat));
|
||||
if (!dmat[i])
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < nres; i++)
|
||||
for (j = i; j < nres; j++)
|
||||
for (at1 = 0; at1 <= 3; at1++)
|
||||
for (at2 = 0; at2 <= 3; at2++)
|
||||
if (i != j || at1 != at2)
|
||||
if ((w[i] & (1 << at1)) && (w[j] & (1 << at2)))
|
||||
{
|
||||
dv = 20.0 * (rand() & 32767) / 32768.0;
|
||||
dmat[i][j][at1][at2] = dmat[j][i][at2][at1] = dv;
|
||||
}
|
||||
else
|
||||
dmat[i][j][at1][at2] = dmat[j][i][at2][at1] = 999.0;
|
||||
else
|
||||
dmat[i][j][at1][at2] = 0.0;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
const int h (double value);
|
||||
const double scalb (double x, int n);
|
||||
const double logb (double x);
|
||||
static const double a = 0;
|
||||
|
||||
double f (y, x)
|
||||
double y, x;
|
||||
{
|
||||
static const double zero=0, one=1, small=1.0E-9, big=1.0E18;
|
||||
double t,z,sy,sx,hi,lo;
|
||||
int k,m;
|
||||
|
||||
if (x!=x)
|
||||
return x;
|
||||
if (y!=y)
|
||||
return y;
|
||||
|
||||
sy = g (one);
|
||||
sx = g (one);
|
||||
|
||||
if (x==1)
|
||||
{
|
||||
y=g (y);
|
||||
t=y;
|
||||
if (h (t))
|
||||
goto begin;
|
||||
}
|
||||
|
||||
if (y==zero)
|
||||
return (sx==one)?y:g (a);
|
||||
|
||||
if (x==zero)
|
||||
return g (a);
|
||||
|
||||
if (!h (x))
|
||||
if (!h (y))
|
||||
return g ((sx==one)?a:3*a);
|
||||
else
|
||||
return g ((sx==one)?zero:a);
|
||||
|
||||
if (!h (y))
|
||||
return g (a);
|
||||
|
||||
x=g (x);
|
||||
y=g (y);
|
||||
if ((m=(k=logb (y))- logb (x)) > 60)
|
||||
t=big+big;
|
||||
else if (m < -80)
|
||||
t=y/x;
|
||||
else
|
||||
{
|
||||
t = y/x;
|
||||
y = scalb (y,-k);
|
||||
x=scalb (x,-k);
|
||||
}
|
||||
|
||||
begin:
|
||||
if (t < 2.4375)
|
||||
{
|
||||
k = 4 * (t+0.0625);
|
||||
switch (k)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
if (t < small)
|
||||
{
|
||||
big + small;
|
||||
return g ((sx>zero)?t:a-t);
|
||||
}
|
||||
hi = zero; lo = zero; break;
|
||||
|
||||
case 2:
|
||||
hi = a; lo = a;
|
||||
z = x+x;
|
||||
t = ((y+y) - x) / (z + y); break;
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
hi = a; lo = zero;
|
||||
t = (y - x) / (x + y); break;
|
||||
|
||||
default:
|
||||
hi = a; lo = a;
|
||||
z = y-x; y=y+y+y; t = x+x;
|
||||
t = ((z+z)-x) / (t + y); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = a; lo = zero;
|
||||
|
||||
if (t <= big)
|
||||
t = - x / y;
|
||||
else
|
||||
{
|
||||
big+small;
|
||||
t = zero;
|
||||
}
|
||||
}
|
||||
|
||||
z = t*(z*(a+z*(a+z*(a+z*(a+z*(a+z*(a+z*(a+z*(a+z*(a+z*(a+z*a)))))))))));
|
||||
|
||||
return g ((sx>zero)?z:a-z);
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
extern unsigned short statesCount;
|
||||
extern short cn_cadrstates[38][37];
|
||||
extern short coutstate[38][37][5];
|
||||
extern short ccostate[38][37][5];
|
||||
extern short cdel_E[38][37][5];
|
||||
extern short cn[38][37][5][3];
|
||||
extern short cd[38][37][5][3];
|
||||
|
||||
extern short c[4][37];
|
||||
|
||||
extern double vrandNext[64];
|
||||
|
||||
f (unsigned long long maddrOutState[37][8 * 8],
|
||||
int maddrIndices[8 * 8],
|
||||
int delta_E[8 * 8],
|
||||
int after_x_hash[8 * 8],
|
||||
int after_y_hash[8 * 8],
|
||||
int after_z_hash[8 * 8],
|
||||
int nActivePlane)
|
||||
{
|
||||
int class[8 * 8];
|
||||
int ccoeff[8 * 8];
|
||||
int nx[8 * 8];
|
||||
int ny[8 * 8];
|
||||
int nz[8 * 8];
|
||||
int phat[8 * 8];
|
||||
int i;
|
||||
int inState;
|
||||
|
||||
for (inState = 0; inState < statesCount; inState++) {
|
||||
long long Nf[8 * 8];
|
||||
long long Ns[8 * 8];
|
||||
long long Nb[8 * 8];
|
||||
int bbState[8 * 8];
|
||||
int not_flag_p[8 * 8];
|
||||
int j;
|
||||
int max_cadrstates = 0;
|
||||
|
||||
for (i = 0; i < nActivePlane; i++) {
|
||||
int in = maddrIndices[i];
|
||||
int k = cn_cadrstates[class[in]][inState];
|
||||
|
||||
if (k > max_cadrstates)
|
||||
max_cadrstates = k;
|
||||
}
|
||||
|
||||
for (j = 0; j < max_cadrstates; j++) {
|
||||
int coState[8 * 8];
|
||||
int N_co[8 * 8];
|
||||
for (i = 0; i < nActivePlane; i++) {
|
||||
int in = maddrIndices[i];
|
||||
int k = cn_cadrstates[class[in]][inState];
|
||||
|
||||
if (j < k-1) {
|
||||
long long numer = (nx[in] * cn[class[in]][inState][j][0] +
|
||||
ny[in] * cn[class[in]][inState][j][1] +
|
||||
nz[in] * cn[class[in]][inState][j][2]);
|
||||
long long denom = (nx[in] * cd[class[in]][inState][j][0] +
|
||||
ny[in] * cd[class[in]][inState][j][1] +
|
||||
nz[in] * cd[class[in]][inState][j][2]);
|
||||
long long Nj = ((denom == 0) ? 0 : (((((long long)(const64(0,0x10000)) * numer * Ns[in]) / denom) + (long long)(((unsigned) vrandNext[in]) & 0xffff)) >> 16));
|
||||
int outState = coutstate[class[in]][inState][j];
|
||||
int this_coState = ccostate[class[in]][inState][j];
|
||||
int del_E = cdel_E[class[in]][inState][j];
|
||||
int old_Ns = Ns[in];
|
||||
|
||||
maddrOutState[outState][in] += Nj;
|
||||
Ns[in] -= Nj;
|
||||
delta_E[in] += Nj * del_E;
|
||||
if (not_flag_p[in]) {
|
||||
after_x_hash[in] += Nj * c[0][outState];
|
||||
after_y_hash[in] += Nj * c[1][outState];
|
||||
after_z_hash[in] += Nj * c[2][outState];
|
||||
}
|
||||
coState[in] = this_coState;
|
||||
N_co[in] = Nj;
|
||||
}
|
||||
else if (j == k-1) {
|
||||
long long Nj = Ns[in];
|
||||
int outState = coutstate[class[in]][inState][j];
|
||||
int this_coState = ccostate[class[in]][inState][j];
|
||||
int del_E = cdel_E[class[in]][inState][j];
|
||||
maddrOutState[outState][in] += Nj;
|
||||
delta_E[in] += Nj * del_E;
|
||||
coState[in] = this_coState;
|
||||
N_co[in] = Nj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue