class HelloWorld { public static void read_write_3d(double [3d] z) { System.out.print("writing: "); foreach (i within z.domain()) { System.out.print("["); System.out.print(i[1]); System.out.print(", "); System.out.print(i[2]); System.out.print(", "); System.out.print(i[3]); System.out.print("] "); z[i] = i[1] * 17 + i[2] * 533 - i[3] * 991.342; } System.out.print("reading: "); foreach (i within z.domain()) { System.out.print("["); System.out.print(i[1]); System.out.print(", "); System.out.print(i[2]); System.out.print(", "); System.out.print(i[3]); System.out.print("] "); if (z[i] != i[1] * 17 + i[2] * 533 - i[3] * 991.342) System.out.println("\n\nFailure!!\n"); } System.out.println(""); } public static void main( String[] argv ) { int j; RectDomain<2> Q; double [2d] y; double [3d] z; Q = [1 : 8, 3 : 11] * [-2 : 5, 5 : 15]; Q = [1 : 8, 3 : 11] + [9, 12]; // Q = [3 : 111, -4 : 0, 12 : 19].slice(1); y = new double[[1 : 2, 1 : 2]]; z = new double[[1 : 2, 1 : 2, 1 : 2]]; // int [1d] x; // RectDomain<1> R = [1 : 10 : 3]; // x = new int[R]; // System.out.println( "Hello, world!" ); // foreach (i within R) { // int prev = (i[1] > 1) ? (i[1] - 3) : i[1]; // System.out.println(i[1]); // x[i] = x[prev] + 7; // System.out.println(x[i]); // } // System.out.println("2d test"); // Q = [1 : 3 : 1, 1 : 11 : 3]; // y = new double[Q]; // foreach (i within y.domain()) { // System.out.print("("); // System.out.print(i[1]); // System.out.print(", "); // System.out.print(i[2]); // System.out.println(")"); // y[i] = i[1] * 17 + i[2] * 533; // if (y[i] != i[1] * 17 + i[2] * 533) System.out.println("Failure!!"); // } // System.out.println("\nbounds checking test in 2d\nQ=[1 : 3, 1 : 11 : 3]\ntest domain=[1 : 2, 0 : 5]"); // foreach (i within [1 : 2, 0 : 5]) { // double z; // System.out.print("Trying ("); // System.out.print(i[1]); // System.out.print(", "); // System.out.print(i[2]); // System.out.println(")"); // z = y[i]; // } // System.out.println("3d test"); // z = new double[[1 : 3 : 1, 1 : 11 : 3, 112 : 120 : 2]]; // System.out.println("\nbounds checking test in 3d\nQ=[1 : 3 : 1, 1 : 11 : 3, 112 : 120 : 2]\ntest domain=[2 : 3, -1 : 4, 109 : 121 : 3]"); // foreach (i within [2 : 3 : 1, -1 : 4 : 1, 109 : 121 : 3]) { // double x; // System.out.print("Trying ["); // System.out.print(i[1]); // System.out.print(", "); // System.out.print(i[2]); // System.out.print(", "); // System.out.print(i[3]); // System.out.println("]"); // x = z[i]; // } z = new double[[1 : 3 : 1, 1 : 11 : 3, 112 : 122 : 2]]; read_write_3d(z); z = z.restrict([2 : 3 : 1, 1 : 5 : 3, 114 : 118 : 2]); System.out.println("restrict to [1 : 2 : 1, 1 : 5 : 3, 112 : 116 : 2]"); read_write_3d(z); } }