天天看點

使用OpenCASCADE的Math功能解線性方程組

OpenCASCADE由七個子產品組成,分别如下:

Module FoundationClasses; 基礎類;

Module ModelingData; 造型資料;

Module ModelingAlgorihtms; 造型算法;

Module Visualization; 可視化;

Module ApplicationFramework; 程式架構;

Module DataExchange; 資料交換;

Module Draw;

其中基礎類子產品有三個工具箱:

Toolkit TKAdvTools; 進階工具箱;

Toolkit TKMath; 數學工具箱;

Toolkit TKernel; 核心工具箱;

根據OpenCASCADE的Reference文檔,查到math_Gauss類,描述如下:

This class implements the Gauss LU decomposition (Crout algorithm) with partial pivoting (rows interchange) of a square matrix and the different possible derived calculation :

Solution of a set of linear equations.

Inverse of a matrix.

Determinant of a matrix.

主要根據矩陣的三角分解中的LU分解方法,可作如下計算:

線性方程組的求解;

矩陣的逆;

矩陣的行列式;

為簡單起見,先做個簡單的測試,求以下方程組的解:

使用OpenCASCADE的Math功能解線性方程組

OpenCASCADE的C++代碼如下:(建立一個控制台程式,需要包含TKernel.lib;TKMath.lib兩個庫;)

輸出結果如下所示:

通過對基礎類子產品中數學工具箱的使用,對OpenCASCADE慢慢進行了解。

繼續閱讀