/*--------------------------------------------------- * file: dwz2dp.c * purpose: * usage: * inputs: dw.p*.bin z.p*.bin P * outputs: dp.p*sbin * version: 1.0 * author: newman@uci.edu * date: 8/10/07 * NOTE: binary matrices are all (c-style) zero offset *-------------------------------------------------*/ #include #include #include #include #include #include "topiclib.h" /*========================================== * main *========================================== */ int main(int argc, char* argv[]) { int P, T, Np, Npz, Dp, Tmax=0; int p, i, chk, n2=2, n1=1; int *d, *w, *z; int **dp; FILE *fin; char fname[32]; if (argc == 1) { fprintf(stderr, "usage: %s P T\n", argv[0]); exit(-1); } P = atoi(argv[1]); assert(P>0); T = atoi(argv[2]); assert(T>0); for (p = 0; p < P; p++) { // read dw.p*.bin sprintf(fname,"dw.p%d.bin",p); fin = fopen(fname,"r"); assert(fin); assert(fread(&n2, sizeof(int),1,fin)); assert(n2==2); assert(fread(&Np, sizeof(int),1,fin)); assert(Np>0); d = ivec(Np); assert(d); w = ivec(Np); assert(w); chk = fread(d,sizeof(int),Np,fin); assert(chk==Np); chk = fread(w,sizeof(int),Np,fin); assert(chk==Np); fclose(fin); printf("... read %s, Np = %d\n", fname, Np); // read z.p*.bin sprintf(fname,"z.p%d.bin",p); fin = fopen(fname,"r"); assert(fin); assert(fread(&n1, sizeof(int),1,fin)); assert(n1==1); assert(fread(&Npz, sizeof(int),1,fin)); assert(Npz>0); assert(Npz==Np); z = ivec(Np); assert(z); chk = fread(z,sizeof(int),Np,fin); assert(chk==Np); chk = imax(Np,z); assert(chk