int main() { int ivs[BUF_SIZE]; int niv = load(ivs); int divs[BUF_SIZE]; char k[3] = { 103, 111, 100 }; for (k[0] = 'a'; k[0] <= 'z'; ++k[0]) { for (k[1] = 'a'; k[1] <= 'z'; ++k[1]) { for (k[2] = 'a'; k[2] <= 'z'; ++k[2]) { xorc(divs, ivs, niv, k, sizeof k); if (!englishish(divs, niv)) continue; printf("%d\n", total(divs, niv)); } } } }
void comap(void) { int k; int maxkeys, icolort, maxreg, ix, iy, numtot, numcor, lastkey, doc_read, pkey; float *plist = NULL, *ptr, *dbuf, xt, yt; double davx, davx2, davy, davy2, bx, by, xmin, xmax, ymin, ymax, xr, yr, sigx, sigy, xrange, yrange; char outstr[81]; /* Set wait cursor */ waitcursor(iwin, TRUE, 79); /* Recover all the lines from the doc file and store in the dbuf array. column 1 is the key, following columns are registers. correspondence analysis may have up to 24 registers. */ doc_read = TRUE; pkey = 0; maxkeys = MYMAX(key1,key2) + 1; maxreg = MYMAX(itxreg,ityreg) + 1; dbuf = (float *) NULL; if (unsdal(docxnam, &doc_read, pkey, plist, maxreg, &dbuf, &lastkey, maxkeys,maxreg) > 0) { /* Problem retrieving doc file, assume it does not exist */ if (dbuf) free(dbuf); sprintf(outstr," Could not read document file: %s",docxnam); spout(outstr); /* unset wait cursor */ waitcursor(iwin, FALSE, 0); return; } if (lastkey < MYMIN(key1,key2)) { if (dbuf) free(dbuf); sprintf(outstr," both keys needed %d & %d > lastkey = %d", key1,key2,lastkey); spout(outstr); /* unset wait cursor */ waitcursor(iwin, FALSE, 0); return; } /* Determine maximum/minimum x and y coordinates, avg, etc; */ xmin = ymin = FLT_MAX; xmax = ymax = -xmin; davx = davx2 = davy = davy2 = 0; /* Run time allocate of memory space for nkey[], bufx, bufy */ if ( (nkey = (int *) calloc((key1 * key2), sizeof(float)) ) == (int *) NULL) { spout(" *** Could not allocate memory"); waitcursor(iwin, FALSE, 0); return; } if ( (bufx = (float *) calloc((key1 * key2), sizeof(float)) ) == (float *) NULL) { spout(" *** Could not allocate memory"); waitcursor(iwin, FALSE, 0); return; } if ( (bufy = (float *) calloc((key1 * key2), sizeof(float)) ) == (float *) NULL) { spout(" ***Could not allocate memory"); waitcursor(iwin, FALSE, 0); return; } /* Remember current color in icontx */ icolort = icolor; /* Set current color to image almost white */ wicolor(icontx,colorgo+2); /* Clear the screen */ //clearover(NULL,NULL,NULL); ptr = dbuf + (key1-1) * maxreg; nline = 0; for (k = key1; k <= key2; k++) { /* Check that the key has some registers. */ if ( (*ptr) > 0.0) { nkey[nline] = k; /* image number */ bx = *(ptr + itxreg); /* dbuf[k][itxreg] */ by = *(ptr + ityreg); /* dbuf[k][ityreg] */ /* Record bx & by */ bufx[nline] = bx; bufy[nline] = by; nline++; /* Record max and min for bx & by */ xmin = MYMIN(bx,xmin); xmax = MYMAX(bx,xmax); ymin = MYMIN(by,ymin); ymax = MYMAX(by,ymax); /* record average and standard deviation for bx & by */ davx += bx; davx2 += (double)(bx * bx); davy += by; davy2 += (double)( by * by); } ptr += maxreg; } /* for (pkey = key1; pkey <= key2; pkey++) */ /* Calculate sigma and average */ davx /= (float) nline; davy /= (float) nline; sigx = sqrt((davx2 - (davx * davx / (float) nline)) / (double) (nline - 1)); sigy = sqrt((davy2 - (davy * davy / (float) nline)) / (double) (nline - 1)); xt = 2.0 * stndrt * sigx; yt = 2.0 * stndrt * sigy; xr = xmax - xmin; yr = ymax - ymin; xrange = MYMIN(xt, xr); yrange = MYMIN(yt, yr); /* Set plot size */ ixsize = iwidex - 2; iysize = ihighx - 2; ixmar = iymar = 1; numtot = numcor = 0; /* Find scale factors */ factxa = (float) (ixsize -1) / xrange; factxb = - (xmin * factxa) + ixmar + 0.5; factya = (float) (iysize-1) / yrange; factyb = - (ymin * factya) + iymar + 0.5; for (k = 0; k < nline; k++) { ix = (bufx[k] - xmin) * factxa + ixmar + 0.5; iy = (bufy[k] - ymin) * factya + iymar + 0.5; if (ix >= ixmar && ix <= ixsize && iy >= iymar && iy <= iysize) { /* Image is inside the plot extent; find the label number */ if (sayno) { /* write image number at this location on plot */ sprintf(outstr,"%d",nkey[k]); // itsize,just, inten,ipen, overprint witext(icontx,outstr,ix,iy, 0,0, -9,2, FALSE); } else { /* Draw a permanent circle at this position */ xorc(iwin, icontx, TRUE, ix, iy, itrad); xorc(imagsav, icontx, TRUE, ix, iy, itrad); } /* Increment total number of images within plot extent */ numcor += 1; } else { /* Image is outside of plot extent */ nkey[k] = - nkey[k]; } numtot += 1; /* Increment total number of images */ } sprintf(outstr," Images: %d Images within plot: %d",numtot,numcor); spout(outstr); /* Replace current color in icontx */ wicolor(icontx,icolort); /* Initialize bin counter for this map */ nowbin = 0; /* Set flag for each bin mask */ gotbin = gotavim = gotav = FALSE; /* Cancel wait cursor */ waitcursor(iwin, FALSE, 0); /* Start masking of correspondence map */ corr_mask(0); }
void pickdraw(int leftside, int ritside, int locations, int numbers, int predicted, int iend) { char * string = NULL; int ixi, iyi, i; /* Set color to green */ wicolor(icontx,colorgo + 2); /* Draw each of the points */ for (i= 0; i < iend; i++) { if (leftside) { if( xu0[i] > nsam1l && xu0[i] < nsam2l && yu0[i] > nrow1l && yu0[i] < nrow2l) { ixi = xu0[i] + ixulli; iyi = yu0[i] + iyulli; if (locations) { /* Draw a circle at this location */ xorc(iwin, icontx,TRUE,ixi,iyi,iradi); xorc(imagsav,icontx,TRUE,ixi,iyi,iradi); } if (numbers) { /* Write marker number at this location */ string = itoa(i + 1); witext(icontx, string, ixi, iyi, 1, 0, -1, 2, FALSE); if(string) {free(string); string = (char *) NULL;} } } } if (ritside) { if( xs[i] > nsam1r && xs[i] < nsam2r && ys[i] > nrow1r && ys[i] < nrow2r) { ixi = xs[i] + ixulri; iyi = ys[i] + iyulri; if ( locations ) { /* Draw a circle at this location */ xorc(iwin,icontx, TRUE,ixi,iyi,iradi); xorc(imagsav,icontx,TRUE,ixi,iyi,iradi); } if (numbers) { /* Write marker number at this location */ string = itoa(i + 1); witext(icontx, string, ixi, iyi, 1, 0, -1, 2, FALSE); if(string) {free(string); string = (char *) NULL;} } } } if (predicted) { if( xs2[i] > nsam1r && xs2[i] < nsam2r && ys2[i] > nrow1r && ys2[i] < nrow2r) { ixi = xs2[i] + ixulri; iyi = ys2[i] + iyulri; if (locations) { /* Draw a box at this location */ xorbox(iwin, icontx,TRUE,ixi-2,iyi-2, 5,5); xorbox(imagsav,icontx,TRUE,ixi-2,iyi-2, 5,5); } if (numbers) { /* Write marker number at this location */ string = itoa(i + 1); witext(icontx, string, ixi, iyi, 1, 0, -1, 2, FALSE); if(string) {free(string); string = (char *) NULL;} } } } } /* Refresh screen */ expos_cb(NULL,NULL,NULL); }