跳转到内容

模組:Complex Number/Matrix/doc

本页使用了标题或全文手工转换
维基百科,自由的百科全书

这是本页的一个历史版本,由A2569875留言 | 贡献2022年6月1日 (三) 10:20 使用方法编辑。这可能和当前版本存在着巨大的差异。

这是Module:Complex Number/Matrix的文档页面

本模組為基於Module:Complex Number矩陣運算庫

使用方法

LUA

函數庫初始化
  • local 自訂函數庫名稱 = require("Module:Complex Number/Matrix").mmath.init()
    例如:local mmath = require("Module:Complex Number/Matrix").mmath.init()
宣告矩陣
  • local 變數名稱 = 自訂函數庫名稱.matrix(自訂函數庫名稱.row(數字, 數字, 數字...),自訂函數庫名稱.row(數字, 數字, 數字...)...)
  • local 變數名稱 = 自訂函數庫名稱.toMatrix("{{數字, 數字, 數字...},{數字, 數字, 數字...},{數字, 數字, 數字...}...}")
    例如:
    local matrix1 = mmath.matrix(
    	mmath.row(1,2,3),
    	mmath.row(4,5,6),
    	mmath.row(7,8,9)
    )
    local matrix2 = mmath.toMatrix("{{1,2,3},{4,5,6},{7,8,9}}")
    
執行運算
例如:
local A = mmath.matrix(
	mmath.row(1,2,3),
	mmath.row(4,5,6),
	mmath.row(7,8,9)
)
print(A * A)
輸出:{{30,36,42},{66,81,96},{102,126,150}}
或者使用函數庫內容:
local mmath = require("Module:Complex Number/Matrix").mmath.init()
local A = mmath.matrix(
	mmath.row(1,2),
	mmath.row(3,4)
)
print(mmath.inverse(A))
輸出:{{-2,1},{1.5,-0.5}}

模板

使用{{複變運算}}

語法:{{複變運算|運算式|number class=Module:Complex Number/Matrix.mmath}}
宣告矩陣
語法:{{複變運算|matrix(row(數字, 數字, ...),row(數字, 數字, ...),...)|number class=Module:Complex Number/Matrix.mmath}}
例如:{{複變運算|matrix(row(1,2,3),row(4,5,6),row(7,8,9))|number class=Module:Complex Number/Matrix.mmath}}
→「{{1,2,3},{4,5,6},{7,8,9}}」
顯示矩陣(於{{計算結果}})
語法:{{計算結果|mathform(矩陣運算式)|number class=Module:Complex Number/Matrix.mmath}}
例如:{{計算結果|mathform(matrix(row(1,2,3),row(4,5,6),row(7,8,9)))|number class=Module:Complex Number/Matrix.mmath}}
→「
矩陣運算
例如:{{計算結果|mathform(matrix(row(1,2),row(4,5))*matrix(row(4,3),row(2,1)))|number class=Module:Complex Number/Matrix.mmath}}
→「
例如:{{計算結果|det(matrix(row(1,2,5),row(4,3,6),row(7,9,8)))|number class=Module:Complex Number/Matrix.mmath}}
→「
例如:{{計算結果|mathform(inverse(matrix(row(1,2),row(3,4))))|number class=Module:Complex Number/Matrix.mmath}}
→「
矩陣數列:{{數列|<nowiki>{{#tag:math|$\ }}</nowiki>,|1|5|mathform(identity(x))| delnowiki=yes|preprocess=yes|raw_value=yes|class=Module:Complex Number/Matrix.mmath}}
→「, , , , , 」

函數列表

函數 名稱 別名 說明
determinant 行列式 det 計算矩陣的行列式
adjoint 伴隨矩陣 adj 計算矩陣的伴隨矩陣
cofactor 餘子式 cof 計算矩陣的餘子式
mathform <math></math>輸出 令矩陣在tostring時是以<math></math>的格式輸出
rows rows數 計算矩陣的rows數
cols cols數 計算矩陣的cols數
MatrixFunction 矩陣函數 對矩陣套用矩陣函數
GaussElimination 高斯消去法 對矩陣做高斯消去法
rank 計算矩陣的秩
transpose 转置矩阵 計算矩陣的轉置
clone 複製一份矩陣物件
identity 單位矩陣 取得的單位矩陣
diag 對角矩陣 產生對角矩陣
eigenvalue 特徵值 計算矩陣的特徵值,僅支援或以下的矩陣
eigenvector 特徵向量 計算矩陣的特徵向量,僅支援或以下的矩陣
row 初始化矩陣的row
matrix 以若干row物件初始化矩陣
isMatrix 檢查一個物件是否為矩陣
vector 初始化向量
rowvector 初始化row向量
toMatrix 嘗試從字串讀成矩陣