|
|
@ -30,6 +30,7 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Numerics; |
|
|
using System.Numerics; |
|
|
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
|
|
|
|
|
namespace MathNet.Numerics |
|
|
namespace MathNet.Numerics |
|
|
{ |
|
|
{ |
|
|
@ -41,6 +42,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static double Modulus(double dividend, double divisor) |
|
|
public static double Modulus(double dividend, double divisor) |
|
|
{ |
|
|
{ |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
@ -49,6 +53,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static float Modulus(float dividend, float divisor) |
|
|
public static float Modulus(float dividend, float divisor) |
|
|
{ |
|
|
{ |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
@ -57,6 +64,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static int Modulus(int dividend, int divisor) |
|
|
public static int Modulus(int dividend, int divisor) |
|
|
{ |
|
|
{ |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
@ -65,6 +75,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static long Modulus(long dividend, long divisor) |
|
|
public static long Modulus(long dividend, long divisor) |
|
|
{ |
|
|
{ |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
@ -73,6 +86,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// Canonical Modulus. The result has the sign of the divisor.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static BigInteger Modulus(BigInteger dividend, BigInteger divisor) |
|
|
public static BigInteger Modulus(BigInteger dividend, BigInteger divisor) |
|
|
{ |
|
|
{ |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
return ((dividend%divisor) + divisor)%divisor; |
|
|
@ -81,6 +97,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static double Remainder(double dividend, double divisor) |
|
|
public static double Remainder(double dividend, double divisor) |
|
|
{ |
|
|
{ |
|
|
return dividend%divisor; |
|
|
return dividend%divisor; |
|
|
@ -89,6 +108,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static float Remainder(float dividend, float divisor) |
|
|
public static float Remainder(float dividend, float divisor) |
|
|
{ |
|
|
{ |
|
|
return dividend%divisor; |
|
|
return dividend%divisor; |
|
|
@ -97,6 +119,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static int Remainder(int dividend, int divisor) |
|
|
public static int Remainder(int dividend, int divisor) |
|
|
{ |
|
|
{ |
|
|
return dividend%divisor; |
|
|
return dividend%divisor; |
|
|
@ -105,6 +130,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static long Remainder(long dividend, long divisor) |
|
|
public static long Remainder(long dividend, long divisor) |
|
|
{ |
|
|
{ |
|
|
return dividend%divisor; |
|
|
return dividend%divisor; |
|
|
@ -113,6 +141,9 @@ namespace MathNet.Numerics |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// Remainder (% operator). The result has the sign of the dividend.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static BigInteger Remainder(BigInteger dividend, BigInteger divisor) |
|
|
public static BigInteger Remainder(BigInteger dividend, BigInteger divisor) |
|
|
{ |
|
|
{ |
|
|
return dividend%divisor; |
|
|
return dividend%divisor; |
|
|
@ -123,6 +154,9 @@ namespace MathNet.Numerics |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="number">The number to very whether it's even.</param>
|
|
|
/// <param name="number">The number to very whether it's even.</param>
|
|
|
/// <returns>True if and only if it is an even number.</returns>
|
|
|
/// <returns>True if and only if it is an even number.</returns>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static bool IsEven(this int number) |
|
|
public static bool IsEven(this int number) |
|
|
{ |
|
|
{ |
|
|
return (number & 0x1) == 0x0; |
|
|
return (number & 0x1) == 0x0; |
|
|
@ -133,6 +167,9 @@ namespace MathNet.Numerics |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="number">The number to very whether it's even.</param>
|
|
|
/// <param name="number">The number to very whether it's even.</param>
|
|
|
/// <returns>True if and only if it is an even number.</returns>
|
|
|
/// <returns>True if and only if it is an even number.</returns>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static bool IsEven(this long number) |
|
|
public static bool IsEven(this long number) |
|
|
{ |
|
|
{ |
|
|
return (number & 0x1) == 0x0; |
|
|
return (number & 0x1) == 0x0; |
|
|
@ -143,6 +180,9 @@ namespace MathNet.Numerics |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="number">The number to very whether it's odd.</param>
|
|
|
/// <param name="number">The number to very whether it's odd.</param>
|
|
|
/// <returns>True if and only if it is an odd number.</returns>
|
|
|
/// <returns>True if and only if it is an odd number.</returns>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static bool IsOdd(this int number) |
|
|
public static bool IsOdd(this int number) |
|
|
{ |
|
|
{ |
|
|
return (number & 0x1) == 0x1; |
|
|
return (number & 0x1) == 0x1; |
|
|
@ -153,6 +193,9 @@ namespace MathNet.Numerics |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="number">The number to very whether it's odd.</param>
|
|
|
/// <param name="number">The number to very whether it's odd.</param>
|
|
|
/// <returns>True if and only if it is an odd number.</returns>
|
|
|
/// <returns>True if and only if it is an odd number.</returns>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static bool IsOdd(this long number) |
|
|
public static bool IsOdd(this long number) |
|
|
{ |
|
|
{ |
|
|
return (number & 0x1) == 0x1; |
|
|
return (number & 0x1) == 0x1; |
|
|
@ -163,6 +206,9 @@ namespace MathNet.Numerics |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="number">The number to very whether it's a power of two.</param>
|
|
|
/// <param name="number">The number to very whether it's a power of two.</param>
|
|
|
/// <returns>True if and only if it is a power of two.</returns>
|
|
|
/// <returns>True if and only if it is a power of two.</returns>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static bool IsPowerOfTwo(this int number) |
|
|
public static bool IsPowerOfTwo(this int number) |
|
|
{ |
|
|
{ |
|
|
return number > 0 && (number & (number - 1)) == 0x0; |
|
|
return number > 0 && (number & (number - 1)) == 0x0; |
|
|
@ -173,6 +219,9 @@ namespace MathNet.Numerics |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="number">The number to very whether it's a power of two.</param>
|
|
|
/// <param name="number">The number to very whether it's a power of two.</param>
|
|
|
/// <returns>True if and only if it is a power of two.</returns>
|
|
|
/// <returns>True if and only if it is a power of two.</returns>
|
|
|
|
|
|
#if !NET40
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
#endif
|
|
|
public static bool IsPowerOfTwo(this long number) |
|
|
public static bool IsPowerOfTwo(this long number) |
|
|
{ |
|
|
{ |
|
|
return number > 0 && (number & (number - 1)) == 0x0; |
|
|
return number > 0 && (number & (number - 1)) == 0x0; |
|
|
|