class Matrix { double[] data; int colons, rows; double getAt(int i, int j) { return data[i*colons + j]; } void putAt(int i, int j, double val) { data[i*colons + j] = val; } int getColons() { return colons; } int getRows() { return rows; } Matrix(int colons, int rows) { this.colons = colons; this.rows = rows; data = new double[colons*rows]; } } public class Test { static final int interations = 100000; public static void main(String[] args) { Matrix a, b, c; a = new Matrix(10,10); b = new Matrix(10,10); c = new Matrix(10,10); long start = System.currentTimeMillis(); for (int n = 0; n < interations; n++) { for (int i = 0; i < a.getColons(); i++) { for (int j = 0; j < a.getRows(); j++) { double sum = 0.0; for (int k = 0; k < b.getColons(); k++) { sum += b.getAt(j, k)*c.getAt(k, i); } a.putAt(i, j, sum); } } } System.out.println("Elapsed time for " + interations + " is " + + (System.currentTimeMillis() - start)); } }