NMath是NMath套包中基礎的.NET函數庫,它包含了復數類,通用向量與矩陣類,結構化稀疏矩陣類與因式分解,通用稀疏矩陣類與因式分解,通用矩陣分解,最小二乘解,隨機數生成器,快速傅里葉變換(FFT算法) ,數值積分與微分方法,函數最小化,曲線擬合,求根法,線性與非線性編程等內容。
The NMath .NET math library contains foundational classes for object-oriented numerics on the .NET platform.
產品特點如下:
單精度和雙精度復數類
為以下四種數據類型提供全功能的向量和矩陣類:單精度浮點數,雙精度浮點數,單精度復數和雙精度復數。
利用切片和排列靈活的標定指數。
重載那些傳統意義的運算符,使其支持.NET語言,相當于那些沒有的命名的方法(Add(), Subtract()等)。
結構稀疏的矩陣類的全部特征包括,三角形矩陣,對稱矩陣,埃米特共軛矩陣,,三對角矩陣,帶狀對稱矩陣和帶狀埃米特共軛矩陣。
一般矩陣之間和結構稀疏矩陣類型之間的轉換函數。
結構稀疏矩陣置換,計算內積和計算矩陣范數的函數。
結構稀疏矩陣的分解類包括,帶狀矩陣和三對角線矩陣的LU分解,對稱矩陣和埃米特共軛矩陣的Bunch-Kaufman分解和對稱矩陣和埃米特共軛正定矩陣的Cholesky分解。這些矩陣分解一旦建成,就可以用來求解線性系統和計算行列式,求逆,和條件數。
一般稀疏向量和矩陣類和矩陣分解類.
一般矩陣的正交分解類,包括QR分解類和單值分解(SVD)類。
一般矩陣的高等最小平方分解類,包括Cholesky, QR, and SVD.
一般矩陣的LU分解,以及求解線性系統,計算行列式,求逆和條件數的函數。
解決對稱,埃爾米特和非對稱特征值問題的類
標準數值函數的擴展,如與向量,矩陣和復數類協同使用的Cos(), Sqrt(), and Exp()函數。
各種概率分布的隨機數生成。
快速傅立葉變換和線性旋積和相關
支持數值積分(Romberg and Gauss-Kronrod methods),微分(Ridders' method)和代數運算函數的單變量封裝函數的類
多項式封裝,插值和精確的積分和微分。
用黃金分割搜索和Brent方法最小化單變量函數的類
用單形法,鮑威爾的方向設置法,共軛梯度法和變尺度(或類似牛頓法)法最小化多變量函數的類。
模擬退火法
單形法線性規劃
最小平方的多項式擬合
非線性的最小平方最小化,曲線擬合和曲面擬合
用正割法,Ridders法和 Newton-Raphson 法查找單變量函數的根的類
二元函數的二重積分的數值方法
用Trust-Region方法和Levenberg-Marquardt方法的變體最小化非線性最小平方
非線性最小平方的曲線擬合和曲面擬合
用標準的,NET機制的完全持久化數據類
與ADO.NET的整合
線性規劃
在NMath中有2個類被用于線性規劃(LP)的問題,第一個類用來封裝標準的LP問題,第二個類用來封裝包含整數或二進制約束的的LP問題。
類使用初始單純形法(primal simplex method)解決線性規劃的問題,而類則是使用了對偶單純形法(dual simplex method)。單純形法通過在一個單純形的頂點上構建初始解來處理線性規劃的問題,然后沿著單純形的邊沿到達頂點,通過依次篩選目標函數中更高的數值直到最優化。
線性規劃文檔:線性規劃代碼示例:
LinearProgrammingExample [
C#] [
VB]
解決普通線性規劃問題的代碼示例。
PrimalDualSimplexExample [
C#] [
VB]
使用初始單純形和對偶單純型法解決Klee-Minty多面體線性規劃問題的代碼示例。
MixedIntLinearProgrammingExample [
C#] [
VB]
解決在限制變量為整數的情況下線性規劃問題的代碼示例。
BinaryLinearProgrammingExample [
C#] [
VB]
解決在所有變量都為二進制數的情況下線性規劃問題的代碼示例。
隨機數生成器
NMath可提供隨機生成器功能,用于生成各種概率分布的隨機偏離,包括、、、、、、、、、、以及。這個功能可以用于包括VB.NET和F#在內的任意.NET語言。
NMath庫是 CenterSpace軟件公司的數學庫的一部分,它提供了用于 .NET平臺上數學、金融、工程和科學應用程序的構建模塊。其特性包括了矩陣向量類、線性代數、隨機數生成器、數值積分法、插值法、統計、生物統計學、多元線性回歸、方差分析(ANOVA)、優化和通往公共域計算程序包(含線性代數基本子程序及線性代數包)的面向對象接口,所有NMath的日常活動都可從包括C#、 Visual Basic.NET和 F#在內的任何 .NET語言上調用。
隨機生成器文檔:
NMath參考指南中包含了下列表格里可用的生成器類API文檔:
Class |
Distribution |
---|
|
Beta distribution() |
|
Binomial distribution() |
|
Exponential distribution() |
|
Gamma distribution() |
|
Geometric distribution() |
|
Log-Normal distribution() |
|
Normal distribution() |
|
Pareto distribution() |
|
Triangular distribution() |
|
Uniform distribution() |
|
Weibull distribution() |
所有的NMath內核生成器都通過抽象基類RandomNumberGenerator的公共接口進行繼承。
隨機生成器代碼示例:
RandomNumberExample [
C#] [
VB]
如何使用類生成正態分布的隨機數,并將其用于直方圖的示例。
AdvancedRNGExample [
C#] [
VB]
如何使用指定的均勻偏離法創建用于特定概率分布的隨機數字生成器的示例。
MonteCarloRNGExample [
C#] [
VB]
如何使用蒙特卡羅法和均勻隨機數生成器類RandGenUniform計算π的近似值
快速傅里葉變換
NMath作為一個.NET類庫可提供一般向量與矩陣類、復數類、數值微分與積分、最小化與求根類以及用于信號處理的相關性、卷積和快速傅里葉變換(FFT)類。
NMath的包含了單雙精度的一維和二維傅里葉變換,并且 NMath還包含了傅里葉變換的正向、逆向、實數、復數等類型的類,支持任意長度的輸入數據。所有的FFT實現使用的是在單一和多核機器上性能最優秀的類算法。易用性和內存效率可通過使用正向實數快速傅里葉變換的標準對稱信號壓縮來實現,其提供的閱讀器類能夠像遍歷數組那樣輕松讀取壓縮結果。NMath的 FFT算法性能屬于世界一流,最適宜運行在英特爾處理器上。該功能可用于包括VB.NET 和F#在內的任意 .NET語言。
快速傅里葉變換文檔:
Class | Distribution |
---|
| 計算一維和二維的雙精度、正向、實數FFT。 |
| 計算一維和二維的雙精度、正逆向、復數FFT。 |
| 計算由正向實數一維FFT生成的逆向實數FFT的對稱信號。 |
| 用于管理數據集的抵消和跨過的先進靈活的一維FFT類 |
| 用于配置一般FFT類的FFT配置類 |
| 助手類,生成并返回實數正向FFT類自身,幫助讀取復-共軛對稱信號 |
快速傅里葉轉換代碼示例:
Examples using the 1D FFT classes [
C#] [
VB]
Examples using the 2D FFT classes [
C#] [
VB]
Product features include:
- Single- and double-precision complex number classes.
- Full-featured vector and matrix classes for four datatypes: single- and double-precision floating point numbers, and single- and double-precision complex numbers.
- Flexible indexing using slices and ranges.
- Overloaded arithmetic operators with their conventional meanings for those .NET languages that support them, and equivalent named methods (
Add()
, Subtract()
, and so on) for those that do not.
- Full-featured structured sparse matrix classes, including triangular, symmetric, Hermitian, banded, tridiagonal, symmetric banded, and Hermitian banded.
- Functions for converting between general matrices and structured sparse matrix types.
- Functions for transposing structured sparse matrices, computing inner products, and calculating matrix norms.
- Classes for factoring structured sparse matrices, including LU factorization for banded and tridiagonal matrices, Bunch-Kaufman factorization for symmetric and Hermitian matrices, and Cholesky decomposition for symmetric and Hermitian positive definite matrices. Once constructed, matrix factorizations can be used to solve linear systems and compute determinants, inverses, and condition numbers.
- General sparse vector and matrix classes, and matrix factorizations.
- Orthogonal decomposition classes for general matrices, including QR decomposition and singular value decomposition (SVD).
- Advanced least squares factorization classes for general matrices, including Cholesky, QR, and SVD.
- LU factorization for general matrices, as well as functions for solving linear systems, computing determinants, inverses, and condition numbers.
- Classes for solving symmetric, Hermitian, and nonsymmetric eigenvalue problems.
- Extension of standard mathematical functions, such as
Cos()
, Sqrt()
, and Exp()
, to work with vectors, matrices, and complex number classes.
- Random number generation from various probability distributions.
- Fast Fourier Transforms (FFTs), and linear convolution and correlation.
- Classes for encapsulating functions of one variable, with support for numerical integration (Romberg and Gauss-Kronrod methods), differentiation (Ridders' method), and algebraic manipulation of functions.
- Polynomial encapsulation, interpolation, and exact differentiation and integration.
- Classes for minimizing univariate functions using golden section search and Brent's method.
- Classes for minimizing multivariate functions using the downhill simplex method, Powell's direction set method, the conjugate gradient method, and the variable metric (or quasi-Newton) method.
- Simulated annealing.
- Linear programming using the simplex method.
- Least squares polynomial fitting.
- Nonlinear least squares minimization, curve fitting, and surface fitting.
- Classes for finding roots of univariate functions using the secant method, Ridders' method, and the Newton-Raphson method.
- Numerical methods for double integration of functions of two variables.
- Nonlinear least squares minimization using the Trust-Region method, a variant of the Levenberg-Marquardt method.
- Curve and surface fitting by nonlinear least squares.
- Fully persistable data classes using standard .NET mechanisms.
- Integration with ADO.NET.