/* ----------------------------------------------------------------------------
 * 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 ImplicitEulerScheme {
  private transient long swigCPtr;
  private transient boolean swigCMemOwn;

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

  protected static long getCPtr(ImplicitEulerScheme 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_ImplicitEulerScheme(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public ImplicitEulerScheme(FdmLinearOpComposite map, FdmBoundaryConditionSet bcSet, double relTol, ImplicitEulerScheme.SolverType solverType) {
    this(QuantLibJNI.new_ImplicitEulerScheme__SWIG_0(FdmLinearOpComposite.getCPtr(map), map, FdmBoundaryConditionSet.getCPtr(bcSet), bcSet, relTol, solverType.swigValue()), true);
  }

  public ImplicitEulerScheme(FdmLinearOpComposite map, FdmBoundaryConditionSet bcSet, double relTol) {
    this(QuantLibJNI.new_ImplicitEulerScheme__SWIG_1(FdmLinearOpComposite.getCPtr(map), map, FdmBoundaryConditionSet.getCPtr(bcSet), bcSet, relTol), true);
  }

  public ImplicitEulerScheme(FdmLinearOpComposite map, FdmBoundaryConditionSet bcSet) {
    this(QuantLibJNI.new_ImplicitEulerScheme__SWIG_2(FdmLinearOpComposite.getCPtr(map), map, FdmBoundaryConditionSet.getCPtr(bcSet), bcSet), true);
  }

  public ImplicitEulerScheme(FdmLinearOpComposite map) {
    this(QuantLibJNI.new_ImplicitEulerScheme__SWIG_3(FdmLinearOpComposite.getCPtr(map), map), true);
  }

  public void step(Array a, double t) {
    QuantLibJNI.ImplicitEulerScheme_step(swigCPtr, this, Array.getCPtr(a), a, t);
  }

  public void setStep(double dt) {
    QuantLibJNI.ImplicitEulerScheme_setStep(swigCPtr, this, dt);
  }

  public long numberOfIterations() {
    return QuantLibJNI.ImplicitEulerScheme_numberOfIterations(swigCPtr, this);
  }

  public final static class SolverType {
    public final static ImplicitEulerScheme.SolverType BiCGstab = new ImplicitEulerScheme.SolverType("BiCGstab");
    public final static ImplicitEulerScheme.SolverType GMRES = new ImplicitEulerScheme.SolverType("GMRES");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static SolverType swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + SolverType.class + " with value " + swigValue);
    }

    private SolverType(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private SolverType(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private SolverType(String swigName, SolverType swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static SolverType[] swigValues = { BiCGstab, GMRES };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
