class LeastSquaresRegression {

  protected void checkData(final double[][] x, final double[][] weights, final double[] y) {
    checkData(x, y);
    if (weights != null) {
      if (weights.length == 0) {
        throw new IllegalArgumentException("No data in weights array");
      }
      if (weights.length != x.length) {
        throw new IllegalArgumentException("Independent variable and weight arrays are not the same length");
      }
      final int n = weights[0].length;
      for (final double[] w : weights) {
        if (w.length != n) {
          throw new IllegalArgumentException("Need a rectangular array of weight");
        }
      }
    }
  }

}