Calculation of Cap price in the CIR model.
        public void Test()
        {
            double k     = 1.0;
            double theta = 0.02;
            double sigma = 0.08;
            double r0    = 0.01;
            Vector par   = new Vector(3);

            par[0] = k;
            par[1] = theta;
            par[2] = sigma;

            double strike = 0.98;
            double noz    = 100.0;

            double T = 1.0;
            double S = 2.0;

            double callFairmat   = noz * CIRCap.BondCall(r0, 0.0, T, S, strike, par);
            double callBenchmark = 0.317304505282290;

            Console.WriteLine("CallFairmat   = " + callFairmat);
            Console.WriteLine("CallBenchmark = " + callBenchmark);

            double maxError = 1e-10;

            Assert.Less(Math.Abs(callFairmat - callBenchmark), maxError);
        }
        /// <summary>
        /// Calibration objective function:
        /// squared difference between black caps and Cox-Ingersoll-Ross caps.
        /// </summary>
        /// <param name='x'>
        /// The tested [kappa, theta, sigma] vector.
        /// </param>
        /// <returns>
        /// The distance (using the L2 norm) between
        /// black Caps and the Cox-Ingersoll-Ross Caps.
        /// </returns>
        public double Obj(DVPLI.Vector x)
        {
            Matrix cirCapMatrix = CIRCap.CIRCapMatrix(this.capMaturity, this.capRate,
                                                      this.tau, this.r0, x);
            double sum = 0;

            for (int r = 0; r < cirCapMatrix.R; r++)
            {
                for (int c = 0; c < cirCapMatrix.C; c++)
                {
                    if (this.blackCaps[r, c] != 0.0)
                    {
                        sum += Math.Pow(cirCapMatrix[r, c] - this.blackCaps[r, c], 2);
                    }
                }
            }

            return(Math.Sqrt(sum));
        }