Exemplo n.º 1
0
        private static double CalculateLgSigma(double p, double sigmam, double sigmat, double pc, double s, double t)
        {
            var var = new P1Var(sigmam, sigmat, pc, s, t);

            if (!_sp1Hash.TryGetValue(var, out var p1))
            {
                p1 = CalculateP1(sigmam, sigmat, pc, s, t);
                _sp1Hash.Add(var, p1);
            }
            double p2 = CalculateP2(p1, pc, s, t);

            if (p < p1)
            {
                return(CalculateLgSigmaLeft(p, sigmam, pc, s));
            }
            else if (p > p2)
            {
                return(CalculateLgSigmaRight(p, sigmat, pc, t));
            }
            else
            {
                double lgsp1 = CalculateLgSigmaLeft(p1, sigmam, pc, s);
                double lgsp2 = CalculateLgSigmaRight(p2, sigmat, pc, t);
                return(lgsp1 + (lgsp2 - lgsp1) * (p - p1) / (p2 - p1));
            }
        }
Exemplo n.º 2
0
		private static double CalculateLgSigma(double p, double sigmam, double sigmat, double pc, double s, double t)
		{
			P1Var var = new P1Var(sigmam, sigmat, pc, s, t);
			double p1;
			if (!_sp1Hash.TryGetValue(var, out p1))
			{
				p1 = CalculateP1(sigmam, sigmat, pc, s, t);
				_sp1Hash.Add(var, p1);
			}
			double p2 = CalculateP2(p1, pc, s, t);

			if (p < p1)
			{
				return CalculateLgSigmaLeft(p, sigmam, pc, s);
			}
			else if (p > p2)
			{
				return CalculateLgSigmaRight(p, sigmat, pc, t);
			}
			else
			{
				double lgsp1 = CalculateLgSigmaLeft(p1, sigmam, pc, s);
				double lgsp2 = CalculateLgSigmaRight(p2, sigmat, pc, t);
				return lgsp1 + (lgsp2 - lgsp1) * (p - p1) / (p2 - p1);
			}
		}