/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (https://www.swig.org).
 * Version 4.1.1
 *
 * Do not make changes to this file unless you know what you are doing - modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package org.quantlib;

public class GMRES {
  private transient long swigCPtr;
  private transient boolean swigCMemOwn;

  protected GMRES(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(GMRES obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void swigSetCMemOwn(boolean own) {
    swigCMemOwn = own;
  }

  @SuppressWarnings("deprecation")
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        QuantLibJNI.delete_GMRES(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public Array solve(Array b, Array x0) {
    return new Array(QuantLibJNI.GMRES_solve__SWIG_0(swigCPtr, this, Array.getCPtr(b), b, Array.getCPtr(x0), x0), true);
  }

  public Array solve(Array b) {
    return new Array(QuantLibJNI.GMRES_solve__SWIG_1(swigCPtr, this, Array.getCPtr(b), b), true);
  }

  public Array solveWithRestart(long restart, Array b, Array x0) {
    return new Array(QuantLibJNI.GMRES_solveWithRestart__SWIG_0(swigCPtr, this, restart, Array.getCPtr(b), b, Array.getCPtr(x0), x0), true);
  }

  public Array solveWithRestart(long restart, Array b) {
    return new Array(QuantLibJNI.GMRES_solveWithRestart__SWIG_1(swigCPtr, this, restart, Array.getCPtr(b), b), true);
  }

  public GMRES(MatrixMultiplicationDelegate delegate, long maxIter, double relTol) {
    this(QuantLibJNI.new_GMRES__SWIG_0(MatrixMultiplicationDelegate.getCPtr(delegate), delegate, maxIter, relTol), true);
  }

  public GMRES(MatrixMultiplicationDelegate delegate, long maxIter, double relTol, SWIGTYPE_p_MatrixMultiplicationProxy preconditioner) {
    this(QuantLibJNI.new_GMRES__SWIG_1(MatrixMultiplicationDelegate.getCPtr(delegate), delegate, maxIter, relTol, SWIGTYPE_p_MatrixMultiplicationProxy.getCPtr(preconditioner)), true);
  }

}
