翻譯|使用教程|編輯:況魚杰|2019-12-09 11:29:58.300|閱讀 548 次
概述:為方便起見,NMath在類NMathFunctions上提供了靜態(tài)方法,用于求解線性系統(tǒng)以及計算行列式,逆數(shù)和條件數(shù)。所有方法都接受矩陣。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
NMath是一個適用于所有.NET語言,如C#、Visual Basic、F#和.NET的數(shù)學庫,它包含了.NET平臺上的面向?qū)ο髷?shù)字計算的基礎類。我們將以連載的形式向大家介紹NMath的實用教程。
為方便起見,NMath在類NMathFunctions上提供了靜態(tài)方法,用于求解線性系統(tǒng)以及計算行列式,逆數(shù)和條件數(shù)。所有方法都接受矩陣。
提供以下靜態(tài)方法:
NMathFunctions.Solve()解決單個或多個右側(cè)的線性系統(tǒng)。
NMathFunctions.Inverse()計算給定矩陣的逆數(shù)。
NMathFunctions.Determinant()計算給定矩陣的行列式。
NMathFunctions.EstimateConditionNumber()估計指定范數(shù)類型中給定矩陣的條件編號。
NMathFunctions.ConditionNumber()直接計算指定范數(shù)類型中給定矩陣的條件編號。
例如:
代碼示例– C#LU分解
var A = new DoubleMatrix( "3x3 [2 1 1 4 1 0 -2 2 1]" ); var b = new DoubleVector( "[8 11 3]" );DoubleVector x = NMathFunctions.Solve( A, b ); var B = new DoubleMatrix( "3x2[8 3 11 11 3 8]" );DoubleMatrix X = NMathFunctions.Solve( A, B );DoubleMatrix AInv = NMathFunctions.Inverse( A ); double ADet = NMathFunctions.Determinant( A ); double ACond = NMathFunctions.ConditionNumber( A, NormType.InfinityNorm );
代碼示例– VB LU分解
Dim A As New DoubleMatrix("3x3 [2 1 1 4 1 0 -2 2 1]") Dim B As New DoubleVector("[8 11 3]") Dim X As DoubleVector = NMathFunctions.Solve(A, B) Dim B As New DoubleMatrix("3x2[8 3 11 11 3 8]") Dim X As DoubleMatrix = NMathFunctions.Solve(A, B) Dim AInv As DoubleMatrix = NMathFunctions.Inverse(A) Dim ADet As Double = NMathFunctions.Determinant(A) Dim ACond As Double = NMathFunctions.ConditionNumber(A, NormType.InfinityNorm)
請注意,每次調(diào)用NMathFunctions.Solve()都會創(chuàng)建一個LU分解實例。如果您反復(例如在循環(huán)內(nèi))調(diào)用Solve(),并且兩次調(diào)用之間的系數(shù)矩陣沒有變化,則效率更高:
代碼示例– C#LU分解
var fact = new DoubleLUFact( A, false ); ... fact.Solve( B );
代碼示例– VB LU分解
Dim Fact As New DoubleLUFact(A, False) ... Fact.Solve(B)
上一章:使用LU分解
下一章:最小二乘
==========================================
如果想要購買正版授權(quán)NMath的朋友,可以聯(lián)系
關注慧聚IT微信公眾號 ???,了解產(chǎn)品的最新動態(tài)及最新資訊。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務必注明出處、不得修改原文相關鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: