Class Algebra
Contains algebraic and general-purpose mathematical functions.
Inherited Members
Namespace: TheXDS.MCART.Math
Assembly: MCART.dll
Syntax
public static class Algebra
Methods
| Edit this page View SourceAreNegative<T>(IEnumerable<T>)
Returns true if all numbers are negative.
Declaration
public static bool AreNegative<T>(this IEnumerable<T> values) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | values | Numbers to check. |
Returns
Type | Description |
---|---|
bool | true if all numbers in the collection are negative, false otherwise. |
Type Parameters
Name | Description |
---|---|
T |
AreNegative<T>(params T[])
Returns true if all numbers are negative.
Declaration
public static bool AreNegative<T>(params T[] values) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | values | Numbers to check. |
Returns
Type | Description |
---|---|
bool | true if all numbers in the collection are negative, false otherwise. |
Type Parameters
Name | Description |
---|---|
T |
AreNotZero<T>(IEnumerable<T>)
Returns true if all numbers are not equal to zero.
Declaration
public static bool AreNotZero<T>(this IEnumerable<T> x) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | x | Numbers to check. |
Returns
Type | Description |
---|---|
bool | true if all numbers in the collection are not equal to zero, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of elements to check. |
AreNotZero<T>(params T[])
Returns true if all numbers are not equal to zero.
Declaration
public static bool AreNotZero<T>(params T[] x) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | x | Numbers to check. |
Returns
Type | Description |
---|---|
bool | true if all numbers in the collection are not equal to zero, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of elements to check. |
ArePositive<T>(IEnumerable<T>)
Returns true if all numbers are positive.
Declaration
public static bool ArePositive<T>(this IEnumerable<T> values) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | values | Numbers to check. |
Returns
Type | Description |
---|---|
bool | true if all numbers in the collection are positive, false otherwise. |
Type Parameters
Name | Description |
---|---|
T |
ArePositive<T>(params T[])
Returns true if all numbers are positive.
Declaration
public static bool ArePositive<T>(params T[] values) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | values | Numbers to check. |
Returns
Type | Description |
---|---|
bool | true if all numbers in the collection are positive, false otherwise. |
Type Parameters
Name | Description |
---|---|
T |
AreValid(IEnumerable<double>)
Determines if a collection of double are valid operable real numbers.
Declaration
public static bool AreValid(this IEnumerable<double> values)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<double> | values | Collection of double to check. |
Returns
Type | Description |
---|---|
bool | true if all elements of |
AreValid(IEnumerable<float>)
Determines if a collection of float are valid operable real numbers.
Declaration
public static bool AreValid(this IEnumerable<float> values)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<float> | values | Collection of float to check. |
Returns
Type | Description |
---|---|
bool | true if all elements of |
AreValid(params double[])
Determines if a collection of double are valid operable real numbers.
Declaration
public static bool AreValid(params double[] values)
Parameters
Type | Name | Description |
---|---|---|
double[] | values | Collection of double to check. |
Returns
Type | Description |
---|---|
bool | true if all elements of |
AreValid(params float[])
Determines if a collection of float are valid operable real numbers.
Declaration
public static bool AreValid(params float[] values)
Parameters
Type | Name | Description |
---|---|---|
float[] | values | Collection of float to check. |
Returns
Type | Description |
---|---|
bool | true if all elements of |
AreZero<T>(IEnumerable<T>)
Returns true if all numbers are equal to zero.
Declaration
public static bool AreZero<T>(this IEnumerable<T> values) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | values | Numbers to check. |
Returns
Type | Description |
---|---|
bool | true if all numbers in the collection are equal to zero, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of elements to check. |
AreZero<T>(params T[])
Returns true if all numbers are equal to zero.
Declaration
public static bool AreZero<T>(params T[] values) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | values | Numbers to check. |
Returns
Type | Description |
---|---|
bool | true if all numbers in the collection are equal to zero, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of elements to check. |
IsPrime(in byte)
Checks if a number is prime.
Declaration
public static bool IsPrime(this in byte number)
Parameters
Type | Name | Description |
---|---|---|
byte | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrime(in short)
Checks if a number is prime.
Declaration
public static bool IsPrime(this in short number)
Parameters
Type | Name | Description |
---|---|---|
short | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrime(in int)
Checks if a number is prime.
Declaration
public static bool IsPrime(this in int number)
Parameters
Type | Name | Description |
---|---|---|
int | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrime(in long)
Checks if a number is prime using trial division.
Declaration
public static bool IsPrime(this in long number)
Parameters
Type | Name | Description |
---|---|---|
long | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrime(in sbyte)
Checks if a number is prime.
Declaration
[CLSCompliant(false)]
public static bool IsPrime(this in sbyte number)
Parameters
Type | Name | Description |
---|---|---|
sbyte | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrime(in ushort)
Checks if a number is prime.
Declaration
[CLSCompliant(false)]
public static bool IsPrime(this in ushort number)
Parameters
Type | Name | Description |
---|---|---|
ushort | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrime(in uint)
Checks if a number is prime.
Declaration
[CLSCompliant(false)]
public static bool IsPrime(this in uint number)
Parameters
Type | Name | Description |
---|---|---|
uint | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrimeMp(in byte)
Checks if a number is prime using trial division, executing the operation on all processors in the system.
Declaration
public static bool IsPrimeMp(this in byte number)
Parameters
Type | Name | Description |
---|---|---|
byte | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrimeMp(in short)
Checks if a number is prime using trial division, executing the operation on all processors in the system.
Declaration
public static bool IsPrimeMp(this in short number)
Parameters
Type | Name | Description |
---|---|---|
short | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrimeMp(in int)
Checks if a number is prime using trial division, executing the operation on all processors in the system.
Declaration
public static bool IsPrimeMp(this in int number)
Parameters
Type | Name | Description |
---|---|---|
int | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrimeMp(long)
Checks if a number is prime using trial division, executing the operation on all processors in the system.
Declaration
public static bool IsPrimeMp(this long number)
Parameters
Type | Name | Description |
---|---|---|
long | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrimeMp(in sbyte)
Checks if a number is prime using trial division, executing the operation on all processors in the system.
Declaration
[CLSCompliant(false)]
public static bool IsPrimeMp(this in sbyte number)
Parameters
Type | Name | Description |
---|---|---|
sbyte | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrimeMp(in ushort)
Checks if a number is prime using trial division, executing the operation on all processors in the system.
Declaration
[CLSCompliant(false)]
public static bool IsPrimeMp(this in ushort number)
Parameters
Type | Name | Description |
---|---|---|
ushort | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsPrimeMp(in uint)
Checks if a number is prime using trial division, executing the operation on all processors in the system.
Declaration
[CLSCompliant(false)]
public static bool IsPrimeMp(this in uint number)
Parameters
Type | Name | Description |
---|---|---|
uint | number | Number to check. |
Returns
Type | Description |
---|---|
bool |
IsTwoPow(in byte)
Determines if the value is a power of 2.
Declaration
public static bool IsTwoPow(in byte value)
Parameters
Type | Name | Description |
---|---|---|
byte | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
IsTwoPow(in short)
Determines if the value is a power of 2.
Declaration
public static bool IsTwoPow(in short value)
Parameters
Type | Name | Description |
---|---|---|
short | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
IsTwoPow(in int)
Determines if the value is a power of 2.
Declaration
public static bool IsTwoPow(in int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
IsTwoPow(in long)
Determines if the value is a power of 2.
Declaration
public static bool IsTwoPow(in long value)
Parameters
Type | Name | Description |
---|---|---|
long | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
IsTwoPow(in sbyte)
Determines if the value is a power of 2.
Declaration
[CLSCompliant(false)]
public static bool IsTwoPow(in sbyte value)
Parameters
Type | Name | Description |
---|---|---|
sbyte | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
IsTwoPow(in ushort)
Determines if the value is a power of 2.
Declaration
[CLSCompliant(false)]
public static bool IsTwoPow(in ushort value)
Parameters
Type | Name | Description |
---|---|---|
ushort | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
IsTwoPow(in uint)
Determines if the value is a power of 2.
Declaration
[CLSCompliant(false)]
public static bool IsTwoPow(in uint value)
Parameters
Type | Name | Description |
---|---|---|
uint | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
IsTwoPow(in ulong)
Determines if the value is a power of 2.
Declaration
[CLSCompliant(false)]
public static bool IsTwoPow(in ulong value)
Parameters
Type | Name | Description |
---|---|---|
ulong | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
IsValid(in double)
Determines if a double is a valid operable real number.
Declaration
public static bool IsValid(this in double value)
Parameters
Type | Name | Description |
---|---|---|
double | value | double to check. |
Returns
Type | Description |
---|---|
bool | true if |
IsValid(in float)
Determines if a float is a valid operable real number.
Declaration
public static bool IsValid(this in float value)
Parameters
Type | Name | Description |
---|---|---|
float | value | float to check. |
Returns
Type | Description |
---|---|
bool | true if |
IsWhole(in double)
Determines if a double is a whole number.
Declaration
public static bool IsWhole(this in double value)
Parameters
Type | Name | Description |
---|---|---|
double | value | Value to check. |
Returns
Type | Description |
---|---|
bool |
Nearest2Pow(in int)
Calculates the nearest power of two greater than or equal to the value.
Declaration
public static long Nearest2Pow(in int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | Input value. A power of two greater than or equal to this value will be searched for. |
Returns
Type | Description |
---|---|
long | A long value that is the result of the operation. |
NearestPowerUp(in double, in double)
Returns the first power of powerBase
that is greater than value
.
Declaration
public static double NearestPowerUp(in double value, in double powerBase)
Parameters
Type | Name | Description |
---|---|---|
double | value | Target number. |
double | powerBase | Power base. |
Returns
Type | Description |
---|---|
double | A double that is the first power of |