private int dot(int[] a, int[] b) {
        assert(a.length == b.length);
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i] * b[i];
        }
        return sum;
    }