private Matrix cofactor() {
    if (width != height) throw new IllegalArgumentException("not a square");
    double[] result = new double[vector.getSize()];
    for (int i = 0, h = 0; h < height; h++) {
      for (int w = 0; w < width; w++, i++) {
        double value = exclude(w, h).determinant();
        result[i] = isEven(w) != isEven(h) ? -value : value;
      }
    }
    return new Matrix(width, height, result);
  }
private Matrix cofactor()