public static void MyDF(object rateSet)
    {
        object[] o = (object[])rateSet;

        RateSet rs        = (RateSet)o[0];
        RateSet myRateSet = new RateSet((Date)o[1]);

        foreach (RateSet r in rs)
        {
            myRateSet.Add(r.V, r.M.GetPeriodStringFormat(), r.T);
        }

        Date dfDate = new Date(2025, 8, 15);

        double fixing = (double)o[2];

        #region building curve

        SingleCurveBuilderSmoothingFwd <OnLogDf, SimpleCubicInterpolator> C = new SingleCurveBuilderSmoothingFwd <OnLogDf, SimpleCubicInterpolator>(myRateSet, fixing);

        Console.WriteLine("Ref. {0:D}: DF: {1:F5}", myRateSet.refDate.DateValue, C.DF(dfDate));

        #endregion building curve
    }
    // Check if the process will match the starting inputs
    public static void CheckInputsVs3m()
    {
        #region Inputs
        // Start input
        Date refDate = (new Date(DateTime.Now)).mod_foll();

        // I populate markets rates set: from file, from real time, ...
        RateSet mktRates = new RateSet(refDate);

        // Depos
        mktRates.Add(2.243e-2, "1m", BuildingBlockType.EURDEPO);
        mktRates.Add(2.435e-2, "3m", BuildingBlockType.EURDEPO);

        // Swap Vs 3M
        mktRates.Add(2.869e-2, "1Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(3.316e-2, "2Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(3.544e-2, "3Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(3.745e-2, "4Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(3.915e-2, "5Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.057e-2, "6Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.175e-2, "7Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.273e-2, "8Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.362e-2, "9Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.442e-2, "10Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.589e-2, "12Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.750e-2, "15Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.835e-2, "20Y", BuildingBlockType.EURSWAP3M);
        mktRates.Add(4.787e-2, "25Y", BuildingBlockType.EURSWAP3M);

        #endregion end Inputs

        // Uncomment to chose the curve
        // SingleCurveBuilderStandard<OnLogDf, LinearInterpolator> C = new SingleCurveBuilderStandard<OnLogDf, LinearInterpolator>(mktRates, OneDimensionInterpolation.Linear);
        double firstFixing = 1.435e-2; SingleCurveBuilderSmoothingFwd <OnLogDf, LinearInterpolator> C = new SingleCurveBuilderSmoothingFwd <OnLogDf, LinearInterpolator>(mktRates, firstFixing);
        // SingleCurveBuilderInterpBestFit<OnLogDf, LinearInterpolator> C = new SingleCurveBuilderInterpBestFit<OnLogDf, LinearInterpolator>(mktRates);

        #region print output
        IEnumerable <BuildingBlock> BBArray = mktRates.GetArrayOfBB();

        // Only Given Swap from BBArray
        IEnumerable <BuildingBlock> OnlyGivenDepo = from c in BBArray
                                                    where c.GetType().BaseType == typeof(OnePaymentStyle)
                                                    select c;

        Console.WriteLine(C.ToString());

        Console.WriteLine("Recalc Df at Ref Date: {0}", C.DF(refDate));

        foreach (OnePaymentStyle BB in OnlyGivenDepo)
        {
            double yf       = refDate.YF(BB.endDate, BB.dayCount);
            double df       = C.DF(BB.endDate);
            double CalcRate = ((1 / df) - 1) / yf;
            Console.WriteLine("{0}  Input Rate: {1}  Recalc Rate: {2}", BB.Tenor.GetPeriodStringFormat(), BB.rateValue, CalcRate);
        }

        // Only Given Swap from BBArray
        IEnumerable <BuildingBlock> OnlyGivenSwap = from c in BBArray
                                                    where c.GetType().BaseType == typeof(SwapStyle)
                                                    select c;

        foreach (SwapStyle BB in OnlyGivenSwap)
        {
            // fixed leg data
            double[] yfFixLeg = BB.scheduleLeg1.GetYFVect(BB.swapLeg1.DayCount); // fixed is leg 1

            // dfs array of fixed lag
            Date[] dfDates = BB.scheduleLeg1.payDates; // serial date of fixed lag (each dates we should find df)

            // initialise array for df
            double[] dfFixLeg = new double[dfDates.Length];

            // calculate df
            for (int i = 0; i < dfDates.Length; i++)
            {
                dfFixLeg[i] = C.DF(dfDates[i]);
            }

            // Interpolation Methods for Curve Construction PATRICK S. HAGAN & GRAEME WEST Applied Mathematical Finance,Vol. 13, No. 2, 89–129, June 2006
            // Formula 2) page 4
            double CalcRate = Formula.ParRate(yfFixLeg, dfFixLeg); // Calculate par rate

            Console.WriteLine("{0}  Input Rate: {1}  Recalc Rate: {2}", BB.Tenor.GetPeriodStringFormat(), BB.rateValue, CalcRate);
        }
        #endregion end print output
    }