本文整理汇总了C#中ScalarValue.Pow方法的典型用法代码示例。如果您正苦于以下问题:C# ScalarValue.Pow方法的具体用法?C# ScalarValue.Pow怎么用?C# ScalarValue.Pow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScalarValue
的用法示例。
在下文中一共展示了ScalarValue.Pow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <summary>
/// Calculates a single Newton fractal value.
/// </summary>
/// <param name="x">The x value.</param>
/// <param name="y">The y value.</param>
/// <returns>The result (color value 0..1).</returns>
public override double Run(double x, double y)
{
var iter = 0;
var maxiter = MaxIterations;
ScalarValue zn = new ScalarValue(x, y);
ScalarValue pz = ScalarValue.One;
ScalarValue pzd = ScalarValue.Zero;
if(x != 0 || y != 0)
{
while ((iter < maxiter) && pz.AbsSquare() > 1e-8)
{
pz = zn.Pow(new ScalarValue(3)) - 1.0;
pzd = 3.0 * zn.Square();
zn = zn - pz / pzd;
iter++;
}
}
return Math.Max((double)(maxiter - iter * Colors) / (double)maxiter, 0.0);
}
示例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: Zernike
static ScalarValue Zernike(int n, int m, ScalarValue rho)
{
if (n < 0)
throw new YAMPArgumentRangeException("n");
if ((m < 0) || (m > n))
throw new YAMPArgumentRangeException("m", "n >= m >= 0");
// n and m have the same parity
if ((n - m) % 2 != 0)
{
return ScalarValue.Zero;
}
// R00
if (n == 0)
{
return ScalarValue.One;
}
var absrho = rho.Abs();
if ((absrho < 0.0) || (absrho > 1.0))
throw new YAMPNotConvergedException("zernike");
// R^{m}_m
var r2 = rho.Pow(new ScalarValue(m));
if (n == m)
{
return r2;
}
// R^{m+1}_{m+1}
var k = m;
var r1 = r2 * rho;
while (true)
{
k += 2;
// *
// \
// * recurrence involving two lesser m's
// /
// *
// 2n R^{m+1}_{n-1} = (n+m) R^{m}_{n-2} + (n-m) R^{m}_{n}
var r0 = ((2 * k) * rho * r1 - (k + m) * r2) / (k - m);
if (k == n)
{
return r0;
}
// *
// /
// * recurrence involving two greater m's
// \
// *
//
var rp = (2 * (k + 1) * rho * r0 - (k - m) * r1) / (k + m + 2);
r2 = r0;
r1 = rp;
}
}