/// <summary>
        /// Gradient Function
        /// </summary>
        /// <param name="inputVolVec"></param>
        /// <returns></returns>
        public Vector <double> ObjGrad(Vector <double> inputVolVec)
        {
            _taskCounter = new TaskCounter();
            _grad        = new DenseVector(inputVolVec.Count);
            var result = new DenseVector(inputVolVec.Count);

            _currentInput = new DenseVector(inputVolVec.Count);
            inputVolVec.CopyTo(_currentInput);
            _gradPhase = true;
            EvaluateGrad();
            _grad.CopyTo(result);
            return(result);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="targets">Calibration targets containing swaption and caplet data</param>
 /// <param name="timeGrid">Time discretisation</param>
 /// <param name="volatilities">Volatility to be calibrated</param>
 /// <param name="parameters">Calibration parameter settings</param>
 public CalibrationObjective(CalibrationTargets targets, PedersenTimeGrid timeGrid,
                             InterestRateVolatilities volatilities, CalibrationSettings parameters)
 {
     Finished          = false;
     _gradPhase        = false;
     _iterationCounter = 0;
     _taskCounter      = new TaskCounter();
     //_currentInput = new DenseVector(0);
     _targets      = targets;
     _timeGrid     = timeGrid;
     _volatilities = volatilities;
     _parameters   = parameters;
     _hFactor      = 1.0 / (_timeGrid.ExpiryCount * (_timeGrid.TenorCount - 1));
     _vFactor      = 1.0 / ((_timeGrid.ExpiryCount - 1) * _timeGrid.TenorCount);
     _sFactor      = 1.0 / _targets.SwaptionCount;
     _cFactor      = 1.0 / _targets.CapletCount;
 }