import Jama.*; import Jama.examples.MagicSquareExample; /** Example of use of Matrix Class, limit magic squares. **/ public class MagicSquareLimit { public static final int dim = 3; // dimension public static int iters = 100000; // iterations public static int iters1 = 5; public static void main (String argv[]) { for (int i = 1; i <= iters1; i++) { long start = System.currentTimeMillis(); Matrix M = MagicSquareExample.magic(dim).times(1.0 / (dim*(dim*dim + 1)/2)); Matrix C = M.copy(); for (int j = 1; j <= iters; j++) { C = M.times(C); } C.print(2, 3); long end = System.currentTimeMillis(); System.out.println("Total time = "+ (end-start)*0.001); } } }