Pelsser.PelsserCache.PelsserCache C# (CSharp) Method

PelsserCache() public method

Constructor to create a new instance of the PelsserCache.
public PelsserCache ( double t, double s, SquaredGaussianModel p_instance ) : System
t double The first date parameter this element is referenced to.
s double The second date parameter this element is referenced to.
p_instance SquaredGaussianModel /// The instance to the this cache references to. ///
return System
        public PelsserCache(double t, double s, SquaredGaussianModel p_instance)
        {
            this.instance = p_instance;

            double[] btT;

            // Integral calculation is always done with daily intervals.
            int ipy = 252;

            double cached_dt = this.instance.CacheDates[1] - this.instance.CacheDates[0];

            // Indices representing t and s on the mDates discretization.
            if (this.instance.CacheDates[this.instance.CacheDates.Length - 1] < s || 1.0 / cached_dt < ipy)
            {
                double dt = 1.0 / ipy;
                double[] newDates = new double[(int)(1 + s * ipy)];
                for (int j = 0; j < newDates.Length; j++)
                    newDates[j] = j * dt;

                this.instance.CalculateValueForCache(newDates);
            }

            int ti = DVPLDOM.AdaptiveTimeDiscretization.DiscreteTime(t, this.instance.CacheDates);
            int si = DVPLDOM.AdaptiveTimeDiscretization.DiscreteTime(s, this.instance.CacheDates);
            double delta = this.instance.CacheDates[1] - this.instance.CacheDates[0];

            btT = this.instance.B(ti, si, delta);
            this.A = this.instance.A(ti, si, delta, btT);
            if (btT.Length > 0)
            {
                this.B = btT[0];
            }

            this.CtT0 = this.instance.C(s - t);
        }
PelsserCache