Beispiel #1
0
        /// <summary>
        /// Vectorial version of method a.
        /// </summary>
        /// <param name="i">The discrete time-step.</param>
        /// <param name="x">The actual state matrix.</param>
        /// <param name="a">The output drift matrix.</param>
        public unsafe void va(int i, Matrix x, Matrix a)
        {
            // Gets the reference to the state and drift components.
            VectorNP x1 = new VectorNP(x.GetRowReference(0));
            VectorNP x2 = new VectorNP(x.GetRowReference(1));

            VectorNP a1 = new VectorNP(a.GetRowReference(0));
            VectorNP a2 = new VectorNP(a.GetRowReference(1));

            if (transformedSimulation)
            {
                VectorNP delta_r = this.theta[i] - alpha1 * x1;
                if (DVPLI.SolverAssumptions.UseRiskNeutralMeasure)
                {
                    delta_r += this.driftAdjustment.vfV();
                }

                delta_r.CopyTo(a1);
            }
            else
            {
                // Does a straight simulation.
                VectorNP delta_r = this.theta[i] + x2 - alpha1 * x1;
                delta_r.CopyTo(a2);
            }

            VectorNP delta_r2 = -alpha2 * x1;

            delta_r2.CopyTo(a2);
        }
        /// <summary>
        /// This function defines the drift in the Pelsser Markov process.
        /// The formula to calculate the A component is
        /// A = - alpha * previous State.
        /// This is the version which handles a vectorial execution.
        /// </summary>
        /// <param name="i">The parameter is not used.</param>
        /// <param name="x">The state Matrix at the previous state.</param>
        /// <param name="a">The output of the function.</param>
        public void va(int i, Matrix x, Matrix a)
        {
            VectorNP x1  = new VectorNP(x.GetRowReference(0));
            VectorNP tmp = -this.alpha1Temp * x1;

            tmp.CopyTo(a);
        }
Beispiel #3
0
 /// <summary>
 /// This function defines the volatility in the Pelsser markov process.
 /// The formula to calculate the B component is
 /// B = sigma.
 /// This is the version which handles a vectorial execution.
 /// </summary>
 /// <param name="i">The parameter is not used.</param>
 /// <param name="x">The parameter is not used.</param>
 /// <param name="b">The output of the function.</param>
 public void vb(int i, Matrix x, Matrix b)
 {
     VectorNP tmp = new VectorNP(b);
     b.Fill(this.sigma1Temp);
 }
Beispiel #4
0
 /// <summary>
 /// This function defines the drift in the Pelsser Markov process.
 /// The formula to calculate the A component is
 /// A = - alpha * previous State.
 /// This is the version which handles a vectorial execution.
 /// </summary>
 /// <param name="i">The parameter is not used.</param>
 /// <param name="x">The state Matrix at the previous state.</param>
 /// <param name="a">The output of the function.</param>
 public void va(int i, Matrix x, Matrix a)
 {
     VectorNP x1 = new VectorNP(x.GetRowReference(0));
     VectorNP tmp = -this.alpha1Temp * x1;
     tmp.CopyTo(a);
 }
        /// <summary>
        /// This function defines the volatility in the Pelsser markov process.
        /// The formula to calculate the B component is
        /// B = sigma.
        /// This is the version which handles a vectorial execution.
        /// </summary>
        /// <param name="i">The parameter is not used.</param>
        /// <param name="x">The parameter is not used.</param>
        /// <param name="b">The output of the function.</param>
        public void vb(int i, Matrix x, Matrix b)
        {
            VectorNP tmp = new VectorNP(b);

            b.Fill(this.sigma1Temp);
        }
        /// <summary>
        /// Vectorial version of method a.
        /// </summary>
        /// <param name="i">The discrete time-step.</param>
        /// <param name="x">The actual state matrix.</param>
        /// <param name="a">The output drift matrix.</param>
        public unsafe void va(int i, Matrix x, Matrix a)
        {
            // Gets the reference to the state and drift components.
            VectorNP x1 = new VectorNP(x.GetRowReference(0));
            VectorNP x2 = new VectorNP(x.GetRowReference(1));

            VectorNP a1 = new VectorNP(a.GetRowReference(0));
            VectorNP a2 = new VectorNP(a.GetRowReference(1));

            if (transformedSimulation)
            {
                VectorNP delta_r = this.theta[i] - alpha1 * x1;
                if (DVPLI.SolverAssumptions.UseRiskNeutralMeasure)
                    delta_r += this.driftAdjustment.vfV();

                delta_r.CopyTo(a1);
            }
            else
            {
                // Does a straight simulation.
                VectorNP delta_r = this.theta[i] + x2 - alpha1 * x1;
                delta_r.CopyTo(a2);
            }

            VectorNP delta_r2 = -alpha2 * x1;
            delta_r2.CopyTo(a2);
        }