/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 4.0.2
 *
 * 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 CrankNicolsonScheme {
  private transient long swigCPtr;
  private transient boolean swigCMemOwn;

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

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

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

  public CrankNicolsonScheme(double theta, FdmLinearOpComposite map, FdmBoundaryConditionSet bcSet, double relTol) {
    this(QuantLibJNI.new_CrankNicolsonScheme__SWIG_1(theta, FdmLinearOpComposite.getCPtr(map), map, FdmBoundaryConditionSet.getCPtr(bcSet), bcSet, relTol), true);
  }

  public CrankNicolsonScheme(double theta, FdmLinearOpComposite map, FdmBoundaryConditionSet bcSet) {
    this(QuantLibJNI.new_CrankNicolsonScheme__SWIG_2(theta, FdmLinearOpComposite.getCPtr(map), map, FdmBoundaryConditionSet.getCPtr(bcSet), bcSet), true);
  }

  public CrankNicolsonScheme(double theta, FdmLinearOpComposite map) {
    this(QuantLibJNI.new_CrankNicolsonScheme__SWIG_3(theta, FdmLinearOpComposite.getCPtr(map), map), true);
  }

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

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

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

}
