#include #include int IBM = 1927; //SEED const int N = 1024; double rinv = 0.5/((long int)1 << 31); double pres = 2.0e-6; double rps, rpn, am, bm; double * cond, * resi, * volt, * vnew, * p, * r, * ap, *gs, *sor, *cg; double randIBM(){ //returns random numbrs on the unit interval IBM*=16807; return IBM*rinv + 0.5; } int main(){ /* INITIALIZATION */ int i; int n = 0; cond = (double*)malloc(sizeof(double)*N); volt = (double*)malloc(sizeof(double)*(N+1)); p = (double*)malloc(sizeof(double)*(N+1)); r = (double*)malloc(sizeof(double)*(N-1)); ap = (double*)malloc(sizeof(double)*(N-1)); // Burn-in for(i=0;i<1000;i++) //throwaway random numbers randIBM(); // Randomizing conductances. for (i = 0; i < N; i++) cond[i] = randIBM(); // Initialize voltages to a linear profile. for(i=0;i pres*pres){ am = 0; rpn = 0; for (i=1;i