Matrix (int height, double... values) { if (values.length == 0) throw new IllegalArgumentException("no values"); if (height <= 0) throw new IllegalArgumentException("unexpected height"); int width = values.length / height; if (width * height != values.length) throw new IllegalArgumentException("unexpected amount of values"); return new Matrix(width, height, values.clone()); }