/* KSEQ.C: procedure to return an integer location of an array element * whose location is given by vector of indices, i.e. it returns * the integer k from the inputs (i1,...,id)=vect' * in the following do-loop * i=0; do until i > d; k=0; if (i ==1); k=vect[d]; else; k=k+(vect[d-i+1]-1)*prodc(gridnum[d-i+2:d]); endif; i=i+1; endo; * * Input vectors: * * vect: a dx1 vector of indices (i1,i2,...,id) where 1 <= ij <= nj * * gridnum: a dx1 vector of upper bounds (n1,n2,...,nd) * * John Rust, University of Maryland, April 2003 */ int kseq(int *vect,int *gridnum,int d) { int i,j,k,pg; for (i=1; i<=d; i++) { if (i==1) { k=vect[d-1]; } else { pg=gridnum[d-i+1]; for (j=2; j