Matrix (int size) { if (size <= 0) throw new IllegalArgumentException("unexpected size"); double[] array = new double[size * size]; for (int index = 0, i = 0; i < size; i++, index += size + 1) array[index] = 1; return new Matrix(size, size, array); }