Repository navigation
Module_Numerics
Location: Home / Numerics module
This module provides multiple types related to numerical computation, including integers, floating-point numbers, complex numbers, rational numbers, fractions, and more. These types offer high-precision numerical computation and can be converted to and from other numeric types.
All types below are located in namespace: Vorcyc.Mathematics.Numerics
📒Contents
- 🔖 Vorcyc.Mathematics.Numerics.BigFloat struct
- 🔖 Vorcyc.Mathematics.Numerics.Complex<T> struct
- 🔖 Vorcyc.Mathematics.Numerics.ComplexFp32 struct
- 🔖 Vorcyc.Mathematics.Numerics.Int24 struct
- 🔖 Vorcyc.Mathematics.Numerics.IntRange struct
- 🔖 Vorcyc.Mathematics.Numerics.Number class
- 🔖 Vorcyc.Mathematics.Numerics.Point<T> struct
- 🔖 Vorcyc.Mathematics.Numerics.PointFp32 struct
- 🔖 Vorcyc.Mathematics.Numerics.Range<T> class
- 🔖 Vorcyc.Mathematics.Numerics.Rational<T> struct
- 🔖 Vorcyc.Mathematics.Numerics.RectangleFP32 struct
- 🔖 Vorcyc.Mathematics.Numerics.Size<T> struct
- 🔖 Vorcyc.Mathematics.Numerics.SizeFp32 struct
- 🔖 Vorcyc.Mathematics.Numerics.UInt24 struct
A struct representing a high-precision floating-point number.
- Represents high-precision floating-point numbers
- Supports addition, subtraction, multiplication, division, and related operations
- Supports conversion to and from other numeric types
- Supports advanced math operations such as square root and exponentiation
-
Fields:
DataBits,Scale,Size,Exponent,IsZero,OutOfPrecision,IsPositive,IsNegative,Sign,Int -
Properties:
GetPrecision(read-only),GetAccuracy(read-only) -
Methods:
Floor(instance),Ceiling(instance),Sqrt(static),Pow(static),Parse(static),TryParse(static) -
Operator overloads:
+,-,*,/ -
Interface implementations:
IComparable,IComparable<BigFloat>,IEquatable<BigFloat>
BigFloat a = new BigFloat(123.456);
BigFloat b = new BigFloat("789.012");
BigFloat resultAdd = a + b;
BigFloat resultSub = a - b;
BigFloat resultMul = a * b;
BigFloat resultDiv = a / b;
BigFloat resultSqrt = BigFloat.Sqrt(a);
BigFloat resultPow = BigFloat.Pow(a, 2);
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");
Console.WriteLine($"Sqrt: {resultSqrt}");
Console.WriteLine($"Pow: {resultPow}");A struct representing a complex number with a generic numeric type.
- Represents complex numbers
- Supports addition, subtraction, multiplication, division, and related operations
- Supports polar coordinate conversion
- Supports magnitude, conjugate, and related operations
-
Fields:
Real,Imaginary -
Properties:
Magnitude,Phase -
Methods:
Add,Subtract,Multiply,Divide,Negate,Conjugate,Reciprocal,Abs,Sqrt,Pow,Log,Exp,Sin,Cos,Tan,Asin,Acos,Atan,Sinh,Cosh,Tanh -
Operator overloads:
+,-,*,/,==,!= -
Interface implementations:
IEquatable<Complex<T>>,IFormattable,INumberBase<Complex<T>>,ISignedNumber<Complex<T>>
Complex<double> c1 = new Complex<double>(1.0, 2.0);
Complex<double> c2 = new Complex<double>(3.0, 4.0);
Complex<double> resultAdd = c1 + c2;
Complex<double> resultSub = c1 - c2;
Complex<double> resultMul = c1 * c2;
Complex<double> resultDiv = c1 / c2;
double magnitude = Complex<double>.Abs(c1);
Complex<double> conjugate = Complex<double>.Conjugate(c1);
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");
Console.WriteLine($"Magnitude: {magnitude}");
Console.WriteLine($"Conjugate: {conjugate}");A struct representing a complex number with single-precision floating-point components.
- Represents complex numbers
- Supports addition, subtraction, multiplication, division, and related operations
- Supports polar coordinate conversion
- Supports magnitude, conjugate, and related operations
-
Fields:
Real,Imaginary -
Properties:
Magnitude,Phase -
Methods:
Add,Subtract,Multiply,Divide,Negate,Conjugate,Reciprocal,Abs,Sqrt,Pow,Log,Exp,Sin,Cos,Tan,Asin,Acos,Atan,Sinh,Cosh,Tanh -
Operator overloads:
+,-,*,/,==,!= -
Interface implementations:
IEquatable<ComplexFp32>,IFormattable,INumberBase<ComplexFp32>,ISignedNumber<ComplexFp32>
ComplexFp32 c1 = new ComplexFp32(1.0f, 2.0f);
ComplexFp32 c2 = new ComplexFp32(3.0f, 4.0f);
ComplexFp32 resultAdd = c1 + c2;
ComplexFp32 resultSub = c1 - c2;
ComplexFp32 resultMul = c1 * c2;
ComplexFp32 resultDiv = c1 / c2;
float magnitude = ComplexFp32.Abs(c1);
ComplexFp32 conjugate = ComplexFp32.Conjugate(c1);
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");
Console.WriteLine($"Magnitude: {magnitude}");
Console.WriteLine($"Conjugate: {conjugate}");A struct representing a 24-bit signed integer.
- Represents 24-bit signed integers
- Supports addition, subtraction, multiplication, division, and related operations
- Supports conversion to and from other numeric types
-
Operator overloads:
+,-,*,/ -
Interface implementations:
IMinMaxValue<Int24>,IAdditionOperators<Int24, Int24, Int24>,ISubtractionOperators<Int24, Int24, Int24>,IMultiplyOperators<Int24, Int24, Int24>,IDivisionOperators<Int24, Int24, Int24>,IAdditiveIdentity<Int24, Int24>,IComparable,IComparable<Int24>,IFormattable
Int24 a = new Int24(123456);
Int24 b = new Int24(654321);
Int24 resultAdd = a + b;
Int24 resultSub = a - b;
Int24 resultMul = a * b;
Int24 resultDiv = a / b;
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");A struct representing an integer range.
- Represents an integer range
- Checks whether a value is within the range
- Computes the intersection of ranges
-
Properties:
Min,Max,Length -
Methods:
IsInside,Intersection,IsOverlapping,ToString -
Operator overloads:
==,!= -
Interface implementations:
IEquatable<IntRange>,IEnumerable<int>
IntRange range = new IntRange(1, 10);
bool isInside = range.IsInside(5);
IntRange intersection = range.Intersection(new IntRange(5, 15));
Console.WriteLine($"IsInside: {isInside}");
Console.WriteLine($"Intersection: [{intersection.Min}, {intersection.Max}]");A class representing a number as a digit list with arbitrary precision.
- Represents arbitrary-precision numbers
- Supports addition, subtraction, multiplication, division, and related operations
- Supports conversion to and from other numeric types
-
Properties:
DigitsCount,IntegerDigitsCount,FloatingDigitsCount,FirstDigit,LastDigit -
Methods:
Abs,Round,Floor,Ceiling,GetFloatingPart,AppendFirstDigit,RemoveFirstDigit,AppendLastDigit,RemoveLastDigit -
Operator overloads:
+,-,*,/ -
Interface implementations:
IComparable<Number>
Number n1 = new Number("12345678901234567890");
Number n2 = new Number("98765432109876543210");
Number resultAdd = n1 + n2;
Number resultSub = n1 - n2;
Number resultMul = n1 * n2;
Number resultDiv = n1 / n2;
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");A struct representing a point on a 2D plane with a generic numeric type.
- Represents a point on a 2D plane
- Supports addition and subtraction
- Supports distance calculation
-
Properties:
X,Y,IsEmpty -
Methods:
Add,Subtract,ToString -
Operator overloads:
+,-(withSize<T>,(T width, T height)tuple, or scalarT; noPoint<T>±Point<T>) -
Interface implementations:
IAdditionOperators<Point<T>, Size<T>, Point<T>>,ISubtractionOperators<Point<T>, Size<T>, Point<T>>,IEquatable<Point<T>>
Point<int> p = new Point<int>(1, 2);
Size<int> s = new Size<int>(3, 4);
Point<int> resultAdd = p + s;
Point<int> resultSub = p - s;
Point<float> pf1 = new Point<float>(1.0f, 2.0f);
Point<float> pf2 = new Point<float>(3.0f, 4.0f);
float distance = Point<float>.Distance(pf1, pf2);
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Distance: {distance}");A struct representing a point on a 2D plane with single-precision floating-point coordinates.
- Represents a point on a 2D plane
- Supports addition and subtraction
-
Properties:
X,Y,IsEmpty -
Methods:
Add,Subtract,ToString -
Operator overloads:
+,-,==,!=
PointFp32 p = new PointFp32(1.0f, 2.0f);
SizeFp32 s = new SizeFp32(3.0f, 4.0f);
PointFp32 resultAdd = p + s;
PointFp32 resultSub = p - s;
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");A class representing a value range with a generic numeric type.
- Represents a value range
- Checks whether a value is within the range
- Computes intersection and union of ranges
-
Properties:
Value,Minimum,Maximum -
Methods:
IsInside,Intersection(returnsnullwhen the ranges do not overlap),Union,IsOverlapping,ToString -
Interface implementations:
IEquatable<Range<T>>
Range<int> range = new Range<int>(1, 10);
bool isInside = range.IsInside(5);
Range<int> intersection = range.Intersection(new Range<int>(5, 15));
Range<int> union = range.Union(new Range<int>(5, 15));
Console.WriteLine($"IsInside: {isInside}");
Console.WriteLine($"Intersection: [{intersection.Minimum}, {intersection.Maximum}]");
Console.WriteLine($"Union: [{union.Minimum}, {union.Maximum}]");A struct representing a rational number with a generic integer type.
- Represents rational numbers
- Supports addition, subtraction, multiplication, division, and related operations
- Supports conversion to and from other numeric types
-
Fields:
Numerator,Denominator -
Operators:
+,-,*,/ -
Methods:
Negate,Reciprocal,Abs,ToDouble,ToFloatingPointNumber<TFloatingNumber>() -
Interface implementations:
IComparable<Rational<T>>,IEquatable<Rational<T>>
Rational<int> r1 = new Rational<int>(1, 2);
Rational<int> r2 = new Rational<int>(3, 4);
Rational<int> resultAdd = r1 + r2;
Rational<int> resultSub = r1 - r2;
Rational<int> resultMul = r1 * r2;
Rational<int> resultDiv = r1 / r2;
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");A struct representing a rectangle with floating-point coordinates and dimensions.
- Represents a rectangle
- Checks whether a point is inside the rectangle
- Computes intersection and union of rectangles
-
Properties:
X,Y,Width,Height,Location,Size,IsEmpty,Left,Right,Top,Bottom -
Methods:
Contains,Inflate,Intersect,IntersectsWith,Offset,ToString -
Operator overloads:
==,!=
RectangleFP32 rect = new RectangleFP32(0.0f, 0.0f, 10.0f, 20.0f);
bool contains = rect.Contains(5.0f, 5.0f);
RectangleFP32 intersection = RectangleFP32.Intersect(rect, new RectangleFP32(5.0f, 5.0f, 10.0f, 20.0f));
RectangleFP32 union = RectangleFP32.Union(rect, new RectangleFP32(5.0f, 5.0f, 10.0f, 20.0f));
Console.WriteLine($"Contains: {contains}");
Console.WriteLine($"Intersection: {intersection}");
Console.WriteLine($"Union: {union}");A struct representing a 2D size with a generic numeric type.
- Represents a 2D size
- Supports addition, subtraction, multiplication, division, and related operations
-
Properties:
Width,Height -
Methods:
ToString -
Operator overloads:
+,-,*,/(each with a scalarT; noSize<T>±Size<T>)
Usage example:
Size<int> size = new Size<int>(10, 20);
Size<int> resultAdd = size + 2;
Size<int> resultSub = size - 2;
Size<int> resultMul = size * 2;
Size<int> resultDiv = size / 2;
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");A struct representing a 2D size with single-precision floating-point dimensions.
- Represents a 2D size
- Supports addition, subtraction, multiplication, division, and related operations
-
Properties:
Width,Height,IsEmpty -
Methods:
Add,Subtract,ToString -
Operator overloads:
+,-,==,!=
Usage example:
SizeFp32 size1 = new SizeFp32(10.0f, 20.0f);
SizeFp32 size2 = new SizeFp32(5.0f, 5.0f);
SizeFp32 resultAdd = size1 + size2;
SizeFp32 resultSub = size1 - size2;
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");A struct representing a 24-bit unsigned integer.
- Represents 24-bit unsigned integers
- Supports addition, subtraction, multiplication, division, and related operations
- Supports conversion to and from other numeric types
-
Operator overloads:
+,-,*,/ -
Interface implementations:
IMinMaxValue<UInt24>,IAdditionOperators<UInt24, UInt24, UInt24>,ISubtractionOperators<UInt24, UInt24, UInt24>,IMultiplyOperators<UInt24, UInt24, UInt24>,IDivisionOperators<UInt24, UInt24, UInt24>,IAdditiveIdentity<UInt24, UInt24>
Usage example:
UInt24 a = new UInt24(123456);
UInt24 b = new UInt24(654321);
UInt24 resultAdd = a + b;
UInt24 resultSub = a - b;
UInt24 resultMul = a * b;
UInt24 resultDiv = a / b;
Console.WriteLine($"Add: {resultAdd}");
Console.WriteLine($"Subtract: {resultSub}");
Console.WriteLine($"Multiply: {resultMul}");
Console.WriteLine($"Divide: {resultDiv}");-
- 🔖 ArrayExtension class
- 🔖 BaseConverter class
- 🔖 BitMathExtension class
- 🔖 Combinatorics class
- 🔖 ConstantsFp32 class
- 🔖 NumberMapper class
- 🔖 PinnableArray<T> class
- 🔖 SimpleRNG_Fp32 and SimpleRNG_Fp64 classes
- 🔖 TrigonometryHelper class
- 🔖 VMath class
- 🔖 Pinned buffers (Buffers)
- 🔖 IPinnedBuffer<T> interface
- 🔖 POHBuffer<T> class
- 🔖 NativeBuffer<T> class
-
- 🔖 0.9 classifier walkthrough
- 🔖 KNN<T> class
- 🔖 MultipleLinearRegression<T> class
- 🔖 SimpleLinearRegression<T> class
- 🔖 SupportVectorMachine<TSelf> class
- 🔖 DBSCAN<T> class
- 🔖 ExpectationMaximization<T> class
- 🔖 GMM<T> class
- 🔖 HierarchicalClustering<T> class
- 🔖 KMeansClusterer<T> class
- 🔖 VectorQuantization<T> class
- 🔖 FactorAnalysis<T> class
- 🔖 PCA<TSelf> class
- 🔖 TSNE<T> class
- 🔖 Distance metric classes
-
📒 Examples
-
📒 GPU 策略说明
- 🔖 为何放弃主包 GPU
- 🔖 当前性能路径
- 🔖 若仍需要更强算力
-
📒 计算上下文模块
-
📒 核心模块
-
📒 深度学习模块
-
📒 线性代数模块
-
📒 机器学习模块
- 🔖 0.9 分类器完整示例
- 🔖 KNN<T> 类
- 🔖 MultipleLinearRegression<T> 类
- 🔖 SimpleLinearRegression<T> 类
- 🔖 SupportVectorMachine<TSelf> 类
- 🔖 DBSCAN<T> 类
- 🔖 ExpectationMaximization<T> 类
- 🔖 GMM<T> 类
- 🔖 HierarchicalClustering<T> 类
- 🔖 KMeansClusterer<T> 类
- 🔖 VectorQuantization<T> 类
- 🔖 FactorAnalysis<T> 类
- 🔖 PCA<TSelf> 类
- 🔖 TSNE<T> 类
- 🔖 距离度量类
-
📒 信号处理模块
-
📒 数值模块
-
📒 统计模块
- 🔖 基础统计函数
- 🔖 高级统计函数
- 🔖 稳健统计 / RunningMoments
- 🔖 其它统计函数
- 🔖 分布相关函数
- 🔖 时间序列分析
- 🔖 IComparable 扩展
- 🔖 ExtremeValueFinder
- 🔖 INumber 扩展
-
📒 FFTW 扩展
-
📒 示例