lup_decomposition()是Ruby中的內置方法,它返回給定矩陣的LUP分解。
用法: mat1.lup_decomposition()
參數:函數需要返回其LUP分解的矩陣。
返回值:返回矩陣的LUP分解。
例子1:
#Ruby program for lup_decomposition() method in Matrix
#Include matrix
require "matrix"
#Initialize a matrix
mat1
= Matrix[[ 1, 21 ], [ 31, 18 ]]
#Prints the decomposition
puts mat1.lup_decomposition()
輸出:
Matrix[[1, 0], [1/31, 1]] Matrix[[31, 18], [0, 633/31]] Matrix[[0, 1], [1, 0]]
例子2:
#Ruby program for lup_decomposition() method in Matrix
#Include matrix
require "matrix"
#Initialize a matrix
mat1
= Matrix[[ 1, 0, 0 ], [ 2, 3, 0 ], [ 31, 18, 19 ]]
#Prints the decomposition
puts mat1.lup_decomposition()
輸出:
Matrix[[1, 0, 0], [2/31, 1, 0], [1/31, -6/19, 1]] Matrix[[31, 18, 19], [0, 57/31, -38/31], [0, 0, -1/1]] Matrix[[0, 0, 1], [0, 1, 0], [1, 0, 0]]
相關用法
- Ruby Matrix inv()用法及代碼示例
- Ruby Matrix det()用法及代碼示例
- Ruby Matrix tr()用法及代碼示例
- Ruby Matrix lup()用法及代碼示例
- Ruby Matrix t()用法及代碼示例
- Ruby Matrix row()用法及代碼示例
- Ruby Matrix eql?用法及代碼示例
- Ruby Matrix I()用法及代碼示例
- Ruby Matrix zero?()用法及代碼示例
- Ruby Matrix zero()用法及代碼示例
- Ruby Matrix to_a()用法及代碼示例
- Ruby Matrix scalar()用法及代碼示例
- Ruby Matrix column_size()用法及代碼示例
- Ruby Matrix round()用法及代碼示例
- Ruby Matrix unit()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 Ruby | Matrix lup_decomposition() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。