/**
   * Specifies function being optimized.
   *
   * @param function Computes residuals and Jacobian.
   */
  public void setFunction(CoupledJacobian function) {
    internalInitialize(function.getN(), function.getM());
    this.function = function;

    jacobianVals.reshape(M, N);

    B.reshape(N, N);
    Bdiag.reshape(N, 1);
  }
 @Override
 protected void computeResiduals(double[] output) {
   function.computeFunctions(output);
 }
 @Override
 protected void setFunctionParameters(double[] param) {
   function.setInput(param);
 }