A .NET library with a collection of useful data structures and extension methods, designed to simplify common mathematical and programming tasks.
CyberMath provides a rich set of tools to accelerate development, including:
- Matrices: A comprehensive set of matrix types.
Matrix<T>: A standard, fixed-size matrix.DynamicMatrix<T>: A matrix that allows adding or removing rows and columns.JuggedMatrix<T>: A matrix with rows that can have different lengths.DynamicJuggedMatrix<T>: A jagged matrix with dynamic row and column manipulation.
 - Binary Trees: A collection of binary tree implementations.
BinaryTree<T>: A simple binary search tree.AVLBinaryTree<T>: A self-balancing AVL tree.RedBlackBinaryTree<T>: A self-balancing Red-Black tree.
 
QuadraticEquation: A class to solve quadratic equations of the formax^2 + bx + c = 0.
- Collections: A variety of extension methods for collections, including 
Swap,Shuffle,RandomItem, andPermutations. - Strings: A set of useful string extensions, such as 
IsPalindrome,IsAnagramOf,WordsFrequency, andToAlternatingCase. - Random: Extensions for the 
Randomclass to generate numbers within a specified range (NextDouble,NextLong). - Int32 and Int64: A wide range of extensions for 32-bit and 64-bit integers, including:
- Number Theory: 
IsPrime,IsOdd,IsEven,GCD,LCM. - Number Manipulation: 
IsPalindrome,GetLength,GetDigits. - Conversions: 
ToBinary,ToHex. 
 - Number Theory: 
 
FixExpressionConverter: A utility class to convert expressions between infix, postfix, and prefix notations.GenericTypesExtensions: Provides aSerializableDeepCopymethod for creating a deep copy of any serializable object.
You can install CyberMath via NuGet Package Manager:
PM> Install-Package CyberMathusing CyberMath.Structures.Matrices.Matrix;
var matrix = new Matrix<int>(3, 3);
matrix.FillRandomly(0, 10); // Fill with random numbers between 0 and 10
Console.WriteLine("Original Matrix:");
Console.WriteLine(matrix);
var transposed = matrix.Transpose();
Console.WriteLine("Transposed Matrix:");
Console.WriteLine(transposed);using CyberMath.Structures.BinaryTrees.BinaryTree;
var tree = new BinaryTree<int> { 5, 3, 8, 1, 4, 7, 9 };
Console.WriteLine($"Max value: {tree.Max()}");
Console.WriteLine($"Min value: {tree.Min()}");
Console.WriteLine("In-order traversal:");
foreach (var item in tree)
{
    Console.Write(item + " ");
}
// Output: 1 3 4 5 7 8 9using CyberMath.Extensions;
int number = 12321;
Console.WriteLine($"{number} is a palindrome: {number.IsPalindrome()}"); // True
int a = 48, b = 18;
Console.WriteLine($"GCD of {a} and {b} is: {a.GCD(b)}"); // 6
Console.WriteLine($"LCM of {a} and {b} is: {a.LCM(b)}"); // 144To build the project from source, you will need the .NET SDK.
- Clone the repository:
git clone https://github.com/Jeffeek/CyberMath.git
 - Navigate to the project directory:
cd CyberMath - Build the solution:
dotnet build -c Release
 
To run the tests, navigate to the root of the project and run the following command:
dotnet test