Esempio n. 1
0
 private static SimpleFloat3 loadFC() {
   System.out.print("loading ... ");
   int nx = 256;
   int ny = 256;
   // int nz = 1000;
   int nz = 1000;
   int kz = 2000;
   SimpleFloat3 sf3;
   try {
     ArrayFile af = new ArrayFile(DATA_DIR + "CS_patient/CS_matrix.imgs", "r");
     // ArrayFile af =
     //  new ArrayFile(DATA_DIR+"FC_patient/FC_2000_2999.imgs","r");
     af.seek(175 + kz * nx * ny);
     byte[][][] b = zerobyte(nx, ny, nz);
     af.readBytes(b);
     float[][][] f = zerofloat(nz, ny, nx);
     for (int ix = 0; ix < nx; ++ix) {
       for (int iy = 0; iy < ny; ++iy) {
         for (int iz = 0; iz < nz; ++iz) {
           int i = b[iz][iy][ix];
           if (i < 0) i += 256;
           f[ix][iy][iz] = (float) i;
         }
       }
     }
     sf3 = new SimpleFloat3(f);
   } catch (IOException ioe) {
     throw new RuntimeException(ioe);
   }
   System.out.println("done");
   return sf3;
 }
Esempio n. 2
0
 private static void bench(ByteOrder order) {
   System.out.println("order=" + order);
   int n = 1000000;
   try {
     File file = File.createTempFile("junk", "dat");
     file.deleteOnExit();
     ArrayFile af = new ArrayFile(file, "rw", order, order);
     benchFloat(af, n);
     benchDouble(af, n);
     af.close();
   } catch (IOException ioe) {
     throw new RuntimeException(ioe);
   }
 }
Esempio n. 3
0
 private static void benchDouble(ArrayFile af, int n) throws IOException {
   double[] a = randdouble(n);
   double[] b = zerodouble(n);
   int nio;
   Stopwatch sw = new Stopwatch();
   sw.start();
   for (nio = 0; sw.time() < 5.0; ++nio) {
     af.seek(0);
     af.writeDoubles(a);
     af.seek(0);
     af.readDoubles(b);
   }
   sw.stop();
   for (int i = 0; i < n; ++i) if (a[i] != b[i]) throw new RuntimeException("double: i/o failure");
   double time = sw.time();
   double rate = 2.0 * 8.0e-6 * nio * n / time;
   System.out.println("double: rate=" + rate + " MB/s");
 }