public void Initialise()
 {
     _iterationCount   = 0;
     Finished          = false;
     _evaluateGradient = false;
     _mc      = new MyCounter();
     _hFactor = 1.0 / (_param.NumberOfExpiries * (_param.NumberOfTenors - 1));
     _vFactor = 1.0 / ((_param.NumberOfExpiries - 1) * _param.NumberOfTenors);
     _sFactor = 1.0 / _param.NumberOfSwaptions;
     _cFactor = 1.0 / _param.NumberOfCaplets;
 }
        public Vector <double> ObjGrad(Vector <double> x)//, Vector f
        {
            _mc        = new MyCounter();
            _gradient  = new DenseVector(x.Count);
            _xGradient = new DenseVector(x.Count);
            //if (f == null)
            var f = new DenseVector(x.Count);

            x.CopyTo(_xGradient);
            _evaluateGradient = true;
            EvaluateGrad();
            _gradient.CopyTo(f);
            return(f);
        }