本文整理汇总了C#中ScalarValue.Log方法的典型用法代码示例。如果您正苦于以下问题:C# ScalarValue.Log方法的具体用法?C# ScalarValue.Log怎么用?C# ScalarValue.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScalarValue
的用法示例。
在下文中一共展示了ScalarValue.Log方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Psi0asymptotic
static ScalarValue Psi0asymptotic(ScalarValue z)
{
/* coefficients in the asymptotic expansion for large z;
* let w = z^(-2) and write the expression in the form
*
* ln(z) - 1/(2z) - 1/12 w (1 + c1 w + c2 w + c3 w + ... )
*/
const double c1 = -0.1;
const double c2 = 1.0 / 21.0;
const double c3 = -0.05;
const double c4 = -1.0 / 12.0;
var zi = 1.0 / z;
var w = zi * zi;
/* Horner method evaluation of term in parentheses */
var sum = (w * (c3 / c2)) + 1.0;
sum = sum * (c2 / c1);
sum = ((sum * w) + 1.0) * c1 * w;
sum += 1.0;
/* correction added to log(z) */
var cs = sum * w;
cs = cs * c4;
cs = cs + (zi * (-0.5));
return z.Log() + cs;
}
示例2: HurwitzZeta
public static ScalarValue HurwitzZeta(ScalarValue s, ScalarValue q)
{
if (s.Re <= 1.0)
throw new YAMPArgumentRangeException("s", 1.0);
if (q.Re <= 0.0)
throw new YAMPArgumentRangeException("q", 0.0);
var max_bits = 54.0;
var ln_term0 = -s * q.Log();
var qabs = q.Abs();
var sabs = s.Abs();
var ss = s;
if ((sabs > max_bits && qabs < 1.0) || (sabs > 0.5 * max_bits && qabs < 0.25))
{
return q.Pow(-ss);
}
else if (sabs > 0.5 * max_bits && qabs < 1.0)
{
var p1 = q.Pow(-ss);
var p2 = (q / (1.0 + q)).Pow(ss);
var p3 = (q / (2.0 + q)).Pow(ss);
return p1 * (1.0 + p2 + p3);
}
/* Euler-Maclaurin summation formula
* [Moshier, p. 400, with several typo corrections]
*/
const int jmax = 12;
const int kmax = 10;
var pmax = (kmax + q).Pow(-ss);
var scp = s;
var pcp = pmax / (kmax + q);
var ans = pmax * ((kmax + q) / (s - 1.0) + 0.5);
for (var k = 0; k < kmax; k++)
{
ans += (k + q).Pow(-ss);
}
for (var j = 0; j <= jmax; j++)
{
var delta = COEFFICIENTS[j + 1] * scp * pcp;
ans += delta;
if ((delta / ans).Abs() < 0.5 * Double.Epsilon)
{
break;
}
scp *= (s + 2 * j + 1) * (s + 2 * j + 2);
pcp /= (kmax + q) * (kmax + q);
}
return ans;
}
示例3: GetValue
protected override ScalarValue GetValue(ScalarValue value)
{
return value.Log(2.0);
}