Browse Source

Euclid: enforce inlining in for a few short functions

spatial
Christoph Ruegg 9 years ago
parent
commit
53e12fc4d5
  1. 49
      src/Numerics/Euclid.cs

49
src/Numerics/Euclid.cs

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

Loading…
Cancel
Save