Repository navigation
Module_Statistics_INumberExtension
Location: Home / Statistics module / INumberExtension
Vorcyc.Mathematics.Statistics.INumberExtension provides extension methods for numeric operations, with SIMD optimization, including finding maximum and minimum values in spans.
All methods below are located in class: Vorcyc.Mathematics.Statistics.INumberExtension
📒Contents
Gets the maximum value in a sequence.
-
public static T Max<T>(this Span<T> span) where T : struct, INumber<T>- Parameters:
-
span: TheSpanof values.
-
- Returns: The maximum value in the
Span.
- Parameters:
-
public static T Max<T>(this T[] values) where T : struct, INumber<T>- Parameters:
-
values: The array of values.
-
- Returns: The maximum value in the array.
- Parameters:
-
public static T Max<T>(this T[] values, int start, int length) where T : struct, INumber<T>- Parameters:
-
values: The array of values. -
start: The starting index of the range. -
length: The length of the range.
-
- Returns: The maximum value in the specified range of the array.
- Parameters:
Gets the maximum value and its index in a sequence.
-
public static (int index, T value) LocateMax<T>(this Span<T> span) where T : INumber<T>- Parameters:
-
span: TheSpanof values.
-
- Returns: A tuple containing the maximum value and its index.
- Parameters:
-
public static (int index, T value) LocateMax<T>(this T[] values) where T : INumber<T>- Parameters:
-
values: The array of values.
-
- Returns: A tuple containing the maximum value and its index.
- Parameters:
-
public static (int index, T value) LocateMax<T>(this T[] values, int start, int length) where T : INumber<T>- Parameters:
-
values: The array of values. -
start: The starting index of the range. -
length: The length of the range.
-
- Returns: A tuple containing the maximum value and its index.
- Parameters:
Gets the minimum value in a sequence.
-
public static T Min<T>(this Span<T> span) where T : struct, INumber<T>- Parameters:
-
span: TheSpanof values.
-
- Returns: The minimum value in the
Span.
- Parameters:
-
public static T Min<T>(this T[] values) where T : struct, INumber<T>- Parameters:
-
values: The array of values.
-
- Returns: The minimum value in the array.
- Parameters:
-
public static T Min<T>(this T[] values, int start, int length) where T : struct, INumber<T>- Parameters:
-
values: The array of values. -
start: The starting index of the range. -
length: The length of the range.
-
- Returns: The minimum value in the specified range of the array.
- Parameters:
Gets the minimum value and its index in a sequence.
-
public static (int index, T value) LocateMin<T>(this Span<T> span) where T : INumber<T>- Parameters:
-
span: TheSpanof values.
-
- Returns: A tuple containing the minimum value and its index.
- Parameters:
-
public static (int index, T value) LocateMin<T>(this T[] values) where T : INumber<T>- Parameters:
-
values: The array of values.
-
- Returns: A tuple containing the minimum value and its index.
- Parameters:
-
public static (int index, T value) LocateMin<T>(this T[] values, int start, int length) where T : INumber<T>- Parameters:
-
values: The array of values. -
start: The starting index of the range. -
length: The length of the range.
-
- Returns: A tuple containing the minimum value and its index.
- Parameters:
The following example uses several methods from the INumberExtension class, with comments in the sample:
using System;
using Vorcyc.Mathematics.Statistics;
public class INumberExtensionExample
{
public static void Main()
{
// Define a float array
float[] floatArray = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
// Get maximum and minimum in the array
float maxFloat = floatArray.Max();
float minFloat = floatArray.Min();
Console.WriteLine($"Max value in float array: {maxFloat}");
Console.WriteLine($"Min value in float array: {minFloat}");
// Get index and value of maximum and minimum in the array
var (maxFloatIndex, maxFloatValue) = floatArray.LocateMax();
var (minFloatIndex, minFloatValue) = floatArray.LocateMin();
Console.WriteLine($"Max value in float array: {maxFloatValue} at index {maxFloatIndex}");
Console.WriteLine($"Min value in float array: {minFloatValue} at index {minFloatIndex}");
// Get maximum and minimum in a specified range of the array
float maxFloatRange = floatArray.Max(1, 3);
float minFloatRange = floatArray.Min(1, 3);
Console.WriteLine($"Max value in float array range: {maxFloatRange}");
Console.WriteLine($"Min value in float array range: {minFloatRange}");
// Get index and value of maximum and minimum in a specified range of the array
var (maxFloatRangeIndex, maxFloatRangeValue) = floatArray.LocateMax(1, 3);
var (minFloatRangeIndex, minFloatRangeValue) = floatArray.LocateMin(1, 3);
Console.WriteLine($"Max value in float array range: {maxFloatRangeValue} at index {maxFloatRangeIndex}");
Console.WriteLine($"Min value in float array range: {minFloatRangeValue} at index {minFloatRangeIndex}");
// Define an integer array
int[] intArray = { 1, 2, 3, 4, 5 };
// Get maximum and minimum in the array
int maxInt = intArray.Max();
int minInt = intArray.Min();
Console.WriteLine($"Max value in int array: {maxInt}");
Console.WriteLine($"Min value in int array: {minInt}");
// Get index and value of maximum and minimum in the array
var (maxIntIndex, maxIntValue) = intArray.LocateMax();
var (minIntIndex, minIntValue) = intArray.LocateMin();
Console.WriteLine($"Max value in int array: {maxIntValue} at index {maxIntIndex}");
Console.WriteLine($"Min value in int array: {minIntValue} at index {minIntIndex}");
// Get maximum and minimum in a specified range of the array
int maxIntRange = intArray.Max(1, 3);
int minIntRange = intArray.Min(1, 3);
Console.WriteLine($"Max value in int array range: {maxIntRange}");
Console.WriteLine($"Min value in int array range: {minIntRange}");
// Get index and value of maximum and minimum in a specified range of the array
var (maxIntRangeIndex, maxIntRangeValue) = intArray.LocateMax(1, 3);
var (minIntRangeIndex, minIntRangeValue) = intArray.LocateMin(1, 3);
Console.WriteLine($"Max value in int array range: {maxIntRangeValue} at index {maxIntRangeIndex}");
Console.WriteLine($"Min value in int array range: {minIntRangeValue} at index {minIntRangeIndex}");
}
}-
- 🔖 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 扩展
-
📒 示例