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

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

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

  public CmsMarket(PeriodVector swapLengths, SwapIndexVector swapIndexes, IborIndex iborIndex, QuoteHandleVectorVector bidAskSpreads, CmsCouponPricerVector pricers, YieldTermStructureHandle discountingTS) {
    this(QuantLibJNI.new_CmsMarket(PeriodVector.getCPtr(swapLengths), swapLengths, SwapIndexVector.getCPtr(swapIndexes), swapIndexes, IborIndex.getCPtr(iborIndex), iborIndex, QuoteHandleVectorVector.getCPtr(bidAskSpreads), bidAskSpreads, CmsCouponPricerVector.getCPtr(pricers), pricers, YieldTermStructureHandle.getCPtr(discountingTS), discountingTS), true);
  }

  public void reprice(SwaptionVolatilityStructureHandle volStructure, double meanReversion) {
    QuantLibJNI.CmsMarket_reprice(swigCPtr, this, SwaptionVolatilityStructureHandle.getCPtr(volStructure), volStructure, meanReversion);
  }

  public PeriodVector swapTenors() {
    return new PeriodVector(QuantLibJNI.CmsMarket_swapTenors(swigCPtr, this), false);
  }

  public PeriodVector swapLengths() {
    return new PeriodVector(QuantLibJNI.CmsMarket_swapLengths(swigCPtr, this), false);
  }

  public Matrix impliedCmsSpreads() {
    return new Matrix(QuantLibJNI.CmsMarket_impliedCmsSpreads(swigCPtr, this), false);
  }

  public Matrix spreadErrors() {
    return new Matrix(QuantLibJNI.CmsMarket_spreadErrors(swigCPtr, this), false);
  }

  public Matrix browse() {
    return new Matrix(QuantLibJNI.CmsMarket_browse(swigCPtr, this), true);
  }

  public double weightedSpreadError(Matrix weights) {
    return QuantLibJNI.CmsMarket_weightedSpreadError(swigCPtr, this, Matrix.getCPtr(weights), weights);
  }

  public double weightedSpotNpvError(Matrix weights) {
    return QuantLibJNI.CmsMarket_weightedSpotNpvError(swigCPtr, this, Matrix.getCPtr(weights), weights);
  }

  public double weightedFwdNpvError(Matrix weights) {
    return QuantLibJNI.CmsMarket_weightedFwdNpvError(swigCPtr, this, Matrix.getCPtr(weights), weights);
  }

  public SWIGTYPE_p_DisposableT_Array_t weightedSpreadErrors(Matrix weights) {
    return new SWIGTYPE_p_DisposableT_Array_t(QuantLibJNI.CmsMarket_weightedSpreadErrors(swigCPtr, this, Matrix.getCPtr(weights), weights), true);
  }

  public SWIGTYPE_p_DisposableT_Array_t weightedSpotNpvErrors(Matrix weights) {
    return new SWIGTYPE_p_DisposableT_Array_t(QuantLibJNI.CmsMarket_weightedSpotNpvErrors(swigCPtr, this, Matrix.getCPtr(weights), weights), true);
  }

  public SWIGTYPE_p_DisposableT_Array_t weightedFwdNpvErrors(Matrix weights) {
    return new SWIGTYPE_p_DisposableT_Array_t(QuantLibJNI.CmsMarket_weightedFwdNpvErrors(swigCPtr, this, Matrix.getCPtr(weights), weights), true);
  }

}
