Browse Source

Special Functions: naming concept

ridge-regression
Christoph Ruegg 8 years ago
parent
commit
23b8cdc64b
  1. 7
      src/Numerics.Tests/SpecialFunctionsTests/BesselTests.cs
  2. 72
      src/Numerics/SpecialFunctions/Airy.cs
  3. 64
      src/Numerics/SpecialFunctions/Bessel.cs
  4. 16
      src/Numerics/SpecialFunctions/Hankel.cs
  5. 23
      src/Numerics/SpecialFunctions/Options.cs
  6. 8
      src/Numerics/SpecialFunctions/SphericalBessel.cs

7
src/Numerics.Tests/SpecialFunctionsTests/BesselTests.cs

@ -1,6 +1,5 @@
using MathNet.Numerics.UnitTests;
using System;
using NUnit.Framework;
using System;
using Complex = System.Numerics.Complex;
namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests
@ -251,7 +250,7 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests
public void BesselIRatioExact(int n, double zr, double zi, double cyr, double cyi, int decimalPlaces)
{
var z = new Complex(zr, zi);
var actual = SpecialFunctions.BesselI(n + 1, z, SpecialFunctions.Scale.Exponential) / SpecialFunctions.BesselI(n, z, SpecialFunctions.Scale.Exponential);
var actual = SpecialFunctions.BesselIScaled(n + 1, z) / SpecialFunctions.BesselIScaled(n, z);
AssertHelpers.AlmostEqualRelative(new Complex(cyr, cyi), actual, decimalPlaces);
}
@ -267,7 +266,7 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests
public void BesselKRatioExact(int n, double zr, double zi, double cyr, double cyi, int decimalPlaces)
{
var z = new Complex(zr, zi);
var actual = SpecialFunctions.BesselK(n + 1, z, SpecialFunctions.Scale.Exponential) / SpecialFunctions.BesselK(n, z, SpecialFunctions.Scale.Exponential);
var actual = SpecialFunctions.BesselKScaled(n + 1, z) / SpecialFunctions.BesselKScaled(n, z);
AssertHelpers.AlmostEqualRelative(new Complex(cyr, cyi), actual, decimalPlaces);
}

72
src/Numerics/SpecialFunctions/Airy.cs

@ -10,14 +10,12 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Airy function Ai.
/// <para>AiryAi(z) is a solution to the Airy equation, y'' - y * z = 0.</para>
/// <para>AiryAi(z, Scale.Exponential) returns Exp(zta) * AiryAi(z), where zta = (2/3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the Airy function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Airy function Ai.</returns>
public static Complex AiryAi(Complex z, Scale scale = Scale.Unity)
public static Complex AiryAi(Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCairy(z) : Amos.Cairy(z);
return Amos.Cairy(z);
}
/// <summary>
@ -26,7 +24,7 @@ namespace MathNet.Numerics
/// </summary>
/// <param name="z">The value to compute the Airy function of.</param>
/// <returns>The exponentially scaled Airy function Ai.</returns>
public static Complex ScaledAiryAi(Complex z)
public static Complex AiryAiScaled(Complex z)
{
return Amos.ScaledCairy(z);
}
@ -34,14 +32,12 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Airy function Ai.
/// <para>AiryAi(z) is a solution to the Airy equation, y'' - y * z = 0.</para>
/// <para>AiryAi(z, Scale.Exponential) returns Exp(zta) * AiryAi(z), where zta = (2/3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the Airy function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Airy function Ai.</returns>
public static double AiryAi(double z, Scale scale = Scale.Unity)
public static double AiryAi(double z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCairy(z) : AiryAi(new Complex(z, 0), scale).Real;
return AiryAi(new Complex(z, 0)).Real;
}
/// <summary>
@ -50,7 +46,7 @@ namespace MathNet.Numerics
/// </summary>
/// <param name="z">The value to compute the Airy function of.</param>
/// <returns>The exponentially scaled Airy function Ai.</returns>
public static double ScaledAiryAi(double z)
public static double AiryAiScaled(double z)
{
return Amos.ScaledCairy(z);
}
@ -58,14 +54,12 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the derivative of the Airy function Ai.
/// <para>AiryAiPrime(z) is defined as d/dz AiryAi(z).</para>
/// <para>AiryAiPrime(z, Scale.Exponential) returns Exp(zta) * AiryAiPrime(z), where zta = (2/3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the derivative of the Airy function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The derivative of the Airy function Ai.</returns>
public static Complex AiryAiPrime(Complex z, Scale scale = Scale.Unity)
public static Complex AiryAiPrime(Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCairyPrime(z) : Amos.CairyPrime(z);
return Amos.CairyPrime(z);
}
/// <summary>
@ -74,7 +68,7 @@ namespace MathNet.Numerics
/// </summary>
/// <param name="z">The value to compute the derivative of the Airy function of.</param>
/// <returns>The exponentially scaled derivative of Airy function Ai.</returns>
public static Complex ScaledAiryAiPrime(Complex z)
public static Complex AiryAiPrimeScaled(Complex z)
{
return Amos.ScaledCairyPrime(z);
}
@ -82,23 +76,21 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the derivative of the Airy function Ai.
/// <para>AiryAiPrime(z) is defined as d/dz AiryAi(z).</para>
/// <para>AiryAiPrime(z, Scale.Exponential) returns Exp(zta) * AiryAiPrime(z), where zta = (2/3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the derivative of the Airy function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The derivative of the Airy function Ai.</returns>
public static double AiryAiPrime(double z, Scale scale = Scale.Unity)
public static double AiryAiPrime(double z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCairyPrime(z) : AiryAiPrime(new Complex(z, 0), scale).Real;
return AiryAiPrime(new Complex(z, 0)).Real;
}
/// <summary>
/// Returns the expoenntially scaled derivative of the Airy function Ai.
/// Returns the exponentially scaled derivative of the Airy function Ai.
/// <para>ScaledAiryAiPrime(z) is given by Exp(zta) * AiryAiPrime(z), where zta = (2/3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the derivative of the Airy function of.</param>
/// <returns>The expoenntially scaled derivative of the Airy function Ai.</returns>
public static double ScaledAiryAiPrime(double z)
/// <returns>The exponentially scaled derivative of the Airy function Ai.</returns>
public static double AiryAiPrimeScaled(double z)
{
return Amos.ScaledCairyPrime(z);
}
@ -106,14 +98,12 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Airy function Bi.
/// <para>AiryBi(z) is a solution to the Airy equation, y'' - y * z = 0.</para>
/// <para>AiryBi(z, Scale.Exponential) returns Exp(-Abs(zta.Real)) * AiryBi(z) where zta = (2 / 3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the Airy function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Airy function Bi.</returns>
public static Complex AiryBi(Complex z, Scale scale = Scale.Unity)
public static Complex AiryBi(Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbiry(z) : Amos.Cbiry(z);
return Amos.Cbiry(z);
}
/// <summary>
@ -122,7 +112,7 @@ namespace MathNet.Numerics
/// </summary>
/// <param name="z">The value to compute the Airy function of.</param>
/// <returns>The exponentially scaled Airy function Bi(z).</returns>
public static Complex ScaledAiryBi(Complex z)
public static Complex AiryBiScaled(Complex z)
{
return Amos.ScaledCbiry(z);
}
@ -130,14 +120,12 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Airy function Bi.
/// <para>AiryBi(z) is a solution to the Airy equation, y'' - y * z = 0.</para>
/// <para>AiryBi(z, Scale.Exponential) returns Exp(-Abs(zta.Real)) * AiryBi(z) where zta = (2 / 3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the Airy function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Airy function Bi.</returns>
public static double AiryBi(double z, Scale scale = Scale.Unity)
public static double AiryBi(double z)
{
return AiryBi(new Complex(z, 0), scale).Real;
return AiryBi(new Complex(z, 0)).Real;
}
/// <summary>
@ -146,22 +134,20 @@ namespace MathNet.Numerics
/// </summary>
/// <param name="z">The value to compute the Airy function of.</param>
/// <returns>The exponentially scaled Airy function Bi.</returns>
public static double ScaledAiryBi(double z)
public static double AiryBiScaled(double z)
{
return AiryBi(new Complex(z, 0), Scale.Exponential).Real;
return AiryBiScaled(new Complex(z, 0)).Real;
}
/// <summary>
/// Returns the derivative of the Airy function Bi.
/// <para>AiryBiPrime(z) is defined as d/dz AiryBi(z).</para>
/// <para>AiryBiPrime(z, Scale.Exponential) returns Exp(-Abs(zta.Real)) * AiryBiPrime(z) where zta = (2 / 3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the derivative of the Airy function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The derivative of the Airy function Bi.</returns>
public static Complex AiryBiPrime(Complex z, Scale scale = Scale.Unity)
public static Complex AiryBiPrime(Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbiryPrime(z) : Amos.CbiryPrime(z);
return Amos.CbiryPrime(z);
}
/// <summary>
@ -170,7 +156,7 @@ namespace MathNet.Numerics
/// </summary>
/// <param name="z">The value to compute the derivative of the Airy function of.</param>
/// <returns>The exponentially scaled derivative of the Airy function Bi.</returns>
public static Complex ScaledAiryBiPrime(Complex z)
public static Complex AiryBiPrimeScaled(Complex z)
{
return Amos.ScaledCbiryPrime(z);
}
@ -178,14 +164,12 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the derivative of the Airy function Bi.
/// <para>AiryBiPrime(z) is defined as d/dz AiryBi(z).</para>
/// <para>AiryBiPrime(z, Scale.Exponential) returns Exp(-Abs(zta.Real)) * AiryBiPrime(z) where zta = (2 / 3) * z * Sqrt(z).</para>
/// </summary>
/// <param name="z">The value to compute the derivative of the Airy function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The derivative of the Airy function Bi.</returns>
public static double AiryBiPrime(double z, Scale scale = Scale.Unity)
public static double AiryBiPrime(double z)
{
return AiryBiPrime(new Complex(z, 0), scale).Real;
return AiryBiPrime(new Complex(z, 0)).Real;
}
/// <summary>
@ -194,9 +178,9 @@ namespace MathNet.Numerics
/// </summary>
/// <param name="z">The value to compute the derivative of the Airy function of.</param>
/// <returns>The exponentially scaled derivative of the Airy function Bi.</returns>
public static double ScaledAiryBiPrime(double z)
public static double AiryBiPrimeScaled(double z)
{
return AiryBiPrime(new Complex(z, 0), Scale.Exponential).Real;
return AiryBiPrimeScaled(new Complex(z, 0)).Real;
}
}
}

64
src/Numerics/SpecialFunctions/Bessel.cs

@ -10,15 +10,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Bessel function of the first kind.
/// <para>BesselJ(n, z) is a solution to the Bessel differential equation.</para>
/// <para>BesselJ(n, z, Scale.Exponential) returns Exp(-Abs(z.Imaginary)) * BesselJ(n, z).</para>
/// </summary>
/// <param name="n">The order of the Bessel function.</param>
/// <param name="z">The value to compute the Bessel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Bessel function of the first kind.</returns>
public static Complex BesselJ(double n, Complex z, Scale scale = Scale.Unity)
public static Complex BesselJ(double n, Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesj(n, z) : Amos.Cbesj(n, z);
return Amos.Cbesj(n, z);
}
/// <summary>
@ -28,7 +26,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the Bessel function.</param>
/// <param name="z">The value to compute the Bessel function of.</param>
/// <returns>The exponentially scaled Bessel function of the first kind.</returns>
public static Complex ScaledBesselJ(double n, Complex z)
public static Complex BesselJScaled(double n, Complex z)
{
return Amos.ScaledCbesj(n, z);
}
@ -36,15 +34,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Bessel function of the first kind.
/// <para>BesselJ(n, z) is a solution to the Bessel differential equation.</para>
/// <para>BesselJ(n, z, Scale.Exponential) returns Exp(-Abs(z.Imaginary)) * J(n, z).</para>
/// </summary>
/// <param name="n">The order of the Bessel function.</param>
/// <param name="z">The value to compute the Bessel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Bessel function of the first kind.</returns>
public static double BesselJ(double n, double z, Scale scale = Scale.Unity)
public static double BesselJ(double n, double z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesj(n, z) : Amos.Cbesj(n, z);
return Amos.Cbesj(n, z);
}
/// <summary>
@ -54,7 +50,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the Bessel function.</param>
/// <param name="z">The value to compute the Bessel function of.</param>
/// <returns>The exponentially scaled Bessel function of the first kind.</returns>
public static double ScaledBesselJ(double n, double z)
public static double BesselJScaled(double n, double z)
{
return Amos.ScaledCbesj(n, z);
}
@ -62,15 +58,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Bessel function of the second kind.
/// <para>BesselY(n, z) is a solution to the Bessel differential equation.</para>
/// <para>BesselY(n, z, Scale.Exponential) returns Exp(-Abs(z.Imaginary)) * BesselY(n, z).</para>
/// </summary>
/// <param name="n">The order of the Bessel function.</param>
/// <param name="z">The value to compute the Bessel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Bessel function of the second kind.</returns>
public static Complex BesselY(double n, Complex z, Scale scale = Scale.Unity)
public static Complex BesselY(double n, Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesy(n, z) : Amos.Cbesy(n, z);
return Amos.Cbesy(n, z);
}
/// <summary>
@ -80,7 +74,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the Bessel function.</param>
/// <param name="z">The value to compute the Bessel function of.</param>
/// <returns>The exponentially scaled Bessel function of the second kind.</returns>
public static Complex ScaledBesselY(double n, Complex z)
public static Complex BesselYScaled(double n, Complex z)
{
return Amos.ScaledCbesy(n, z);
}
@ -88,15 +82,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Bessel function of the second kind.
/// <para>BesselY(n, z) is a solution to the Bessel differential equation.</para>
/// <para>BesselY(n, z, Scale.Exponential) returns Exp(-Abs(z.Imaginary)) * BesselY(n, z).</para>
/// </summary>
/// <param name="n">The order of the Bessel function.</param>
/// <param name="z">The value to compute the Bessel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Bessel function of the second kind.</returns>
public static double BesselY(double n, double z, Scale scale = Scale.Unity)
public static double BesselY(double n, double z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesy(n, z) : Amos.Cbesy(n, z);
return Amos.Cbesy(n, z);
}
/// <summary>
@ -106,7 +98,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the Bessel function.</param>
/// <param name="z">The value to compute the Bessel function of.</param>
/// <returns>The exponentially scaled Bessel function of the second kind.</returns>
public static double ScaledBesselY(double n, double z)
public static double BesselYScaled(double n, double z)
{
return Amos.ScaledCbesy(n, z);
}
@ -114,15 +106,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the modified Bessel function of the first kind.
/// <para>BesselI(n, z) is a solution to the modified Bessel differential equation.</para>
/// <para>BesselI(n, z, Scale.Exponential) returns Exp(-Abs(z.Real)) * BesselI(n, z).</para>
/// </summary>
/// <param name="n">The order of the modified Bessel function.</param>
/// <param name="z">The value to compute the modified Bessel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The modified Bessel function of the first kind.</returns>
public static Complex BesselI(double n, Complex z, Scale scale = Scale.Unity)
public static Complex BesselI(double n, Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesi(n, z) : Amos.Cbesi(n, z);
return Amos.Cbesi(n, z);
}
/// <summary>
@ -132,7 +122,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the modified Bessel function.</param>
/// <param name="z">The value to compute the modified Bessel function of.</param>
/// <returns>The exponentially scaled modified Bessel function of the first kind.</returns>
public static Complex ScaledBesselI(double n, Complex z)
public static Complex BesselIScaled(double n, Complex z)
{
return Amos.ScaledCbesi(n, z);
}
@ -140,15 +130,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the modified Bessel function of the first kind.
/// <para>BesselI(n, z) is a solution to the modified Bessel differential equation.</para>
/// <para>BesselI(n, z, Scale.Exponential) returns Exp(-Abs(z.Real)) * BesselI(n, z).</para>
/// </summary>
/// <param name="n">The order of the modified Bessel function.</param>
/// <param name="z">The value to compute the modified Bessel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The modified Bessel function of the first kind.</returns>
public static double BesselI(double n, double z, Scale scale = Scale.Unity)
public static double BesselI(double n, double z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesi(n, z) : BesselI(n, new Complex(z, 0), scale).Real;
return BesselI(n, new Complex(z, 0)).Real;
}
/// <summary>
@ -158,7 +146,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the modified Bessel function.</param>
/// <param name="z">The value to compute the modified Bessel function of.</param>
/// <returns>The exponentially scaled modified Bessel function of the first kind.</returns>
public static double ScaledBesselI(double n, double z)
public static double BesselIScaled(double n, double z)
{
return Amos.ScaledCbesi(n, z);
}
@ -166,15 +154,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the modified Bessel function of the second kind.
/// <para>BesselK(n, z) is a solution to the modified Bessel differential equation.</para>
/// <para>BesselK(n, z, Scale.Exponential) returns Exp(z) * BesselK(n, z).</para>
/// </summary>
/// <param name="n">The order of the modified Bessel function.</param>
/// <param name="z">The value to compute the modified Bessel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The modified Bessel function of the second kind.</returns>
public static Complex BesselK(double n, Complex z, Scale scale = Scale.Unity)
public static Complex BesselK(double n, Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesk(n, z) : Amos.Cbesk(n, z);
return Amos.Cbesk(n, z);
}
/// <summary>
@ -184,7 +170,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the modified Bessel function.</param>
/// <param name="z">The value to compute the modified Bessel function of.</param>
/// <returns>The exponentially scaled modified Bessel function of the second kind.</returns>
public static Complex ScaledBesselK(double n, Complex z)
public static Complex BesselKScaled(double n, Complex z)
{
return Amos.ScaledCbesk(n, z);
}
@ -192,15 +178,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the modified Bessel function of the second kind.
/// <para>BesselK(n, z) is a solution to the modified Bessel differential equation.</para>
/// <para>BesselK(n, z, Scale.Exponential) returns Exp(z) * BesselK(n, z).</para>
/// </summary>
/// <param name="n">The order of the modified Bessel function.</param>
/// <param name="z">The value to compute the modified Bessel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The modified Bessel function of the second kind.</returns>
public static double BesselK(double n, double z, Scale scale = Scale.Unity)
public static double BesselK(double n, double z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesk(n, z) : Amos.Cbesk(n, z);
return Amos.Cbesk(n, z);
}
/// <summary>
@ -210,7 +194,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the modified Bessel function.</param>
/// <param name="z">The value to compute the modified Bessel function of.</param>
/// <returns>The exponentially scaled modified Bessel function of the second kind.</returns>
public static double ScaledBesselK(double n, double z)
public static double BesselKScaled(double n, double z)
{
return Amos.ScaledCbesk(n, z);
}

16
src/Numerics/SpecialFunctions/Hankel.cs

@ -10,15 +10,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Hankel function of the first kind.
/// <para>HankelH1(n, z) is defined as BesselJ(n, z) + j * BesselY(n, z).</para>
/// <para>HankelH1(n, z, Scale.Exponential) returns Exp(-z * j) * HankelH1(n, z) where j = Sqrt(-1).</para>
/// </summary>
/// <param name="n">The order of the Hankel function.</param>
/// <param name="z">The value to compute the Hankel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Hankel function of the first kind.</returns>
public static Complex HankelH1(double n, Complex z, Scale scale = Scale.Unity)
public static Complex HankelH1(double n, Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesh1(n, z) : Amos.Cbesh1(n, z);
return Amos.Cbesh1(n, z);
}
/// <summary>
@ -28,7 +26,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the Hankel function.</param>
/// <param name="z">The value to compute the Hankel function of.</param>
/// <returns>The exponentially scaled Hankel function of the first kind.</returns>
public static Complex ScaledHankelH1(double n, Complex z)
public static Complex HankelH1Scaled(double n, Complex z)
{
return Amos.ScaledCbesh1(n, z);
}
@ -36,15 +34,13 @@ namespace MathNet.Numerics
/// <summary>
/// Returns the Hankel function of the second kind.
/// <para>HankelH2(n, z) is defined as BesselJ(n, z) - j * BesselY(n, z).</para>
/// <para>HankelH2(n, z, Scale.Exponential) returns Exp(z * j) * HankelH2(n, z) where j = Sqrt(-1).</para>
/// </summary>
/// <param name="n">The order of the Hankel function.</param>
/// <param name="z">The value to compute the Hankel function of.</param>
/// <param name="scale">The option to set the scaling factor.</param>
/// <returns>The Hankel function of the second kind.</returns>
public static Complex HankelH2(double n, Complex z, Scale scale = Scale.Unity)
public static Complex HankelH2(double n, Complex z)
{
return (scale == Scale.Exponential) ? Amos.ScaledCbesh2(n, z) : Amos.Cbesh2(n, z);
return Amos.Cbesh2(n, z);
}
/// <summary>
@ -54,7 +50,7 @@ namespace MathNet.Numerics
/// <param name="n">The order of the Hankel function.</param>
/// <param name="z">The value to compute the Hankel function of.</param>
/// <returns>The exponentially scaled Hankel function of the second kind.</returns>
public static Complex ScaledHankelH2(double n, Complex z)
public static Complex HankelH2Scaled(double n, Complex z)
{
return Amos.ScaledCbesh2(n, z);
}

23
src/Numerics/SpecialFunctions/Options.cs

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MathNet.Numerics
{
public static partial class SpecialFunctions
{
public enum Scale
{
/// <summary>
/// For Bessel-related functions, no scaling factor is applied.
/// </summary>
Unity = 0,
/// <summary>
/// For Bessel-related functions, exponential scaling is applied.
/// </summary>
Exponential = 1
}
}
}

8
src/Numerics/SpecialFunctions/SphericalBessel.cs

@ -32,7 +32,7 @@ namespace MathNet.Numerics
return (n == 0) ? 1 : 0;
}
return Constants.SqrtPiOver2 * BesselJ(n + 0.5, z, Scale.Unity) / Complex.Sqrt(z);
return Constants.SqrtPiOver2 * BesselJ(n + 0.5, z) / Complex.Sqrt(z);
}
/// <summary>
@ -64,7 +64,7 @@ namespace MathNet.Numerics
return (n == 0) ? 1 : 0;
}
return Constants.SqrtPiOver2 * BesselJ(n + 0.5, z, Scale.Unity) / Math.Sqrt(z);
return Constants.SqrtPiOver2 * BesselJ(n + 0.5, z) / Math.Sqrt(z);
}
/// <summary>
@ -91,7 +91,7 @@ namespace MathNet.Numerics
return new Complex(double.NaN, double.NaN);
}
return Constants.SqrtPiOver2 * BesselY(n + 0.5, z, Scale.Unity) / Complex.Sqrt(z);
return Constants.SqrtPiOver2 * BesselY(n + 0.5, z) / Complex.Sqrt(z);
}
/// <summary>
@ -123,7 +123,7 @@ namespace MathNet.Numerics
return double.NegativeInfinity;
}
return Constants.SqrtPiOver2 * BesselY(n + 0.5, z, Scale.Unity) / Math.Sqrt(z);
return Constants.SqrtPiOver2 * BesselY(n + 0.5, z) / Math.Sqrt(z);
}
}
}

Loading…
Cancel
Save