transpose()是Ruby中的內置方法,用於返回矩陣的轉置。
用法: mat1.transpose()
參數:該函數需要轉置矩陣。
返回值:返回轉置矩陣。
例子1:
# Ruby program for transpose() method in Matrix
# Include matrix
require "matrix"
# Initialize a matrix
mat1 = Matrix[[3, 12], [2, 8]]
# Prints the transpose matrix
puts mat1.transpose()
輸出:
Matrix[[3, 2], [12, 8]]
例子2:
# Ruby program for transpose() method in Matrix
# Include matrix
require "matrix"
# Initialize a matrix
mat1 = Matrix[[1, 0], [6, 1], [1, 2]]
# Prints the transpose matrix
puts mat1.transpose()
輸出:
Matrix[[1, 6, 1], [0, 1, 2]]
相關用法
- Ruby Array transpose()用法及代碼示例
- Ruby Matrix inv()用法及代碼示例
- Ruby Matrix zero?()用法及代碼示例
- Ruby Matrix t()用法及代碼示例
- Ruby Matrix row()用法及代碼示例
- Ruby Matrix lup()用法及代碼示例
- Ruby Matrix eql?用法及代碼示例
- Ruby Matrix I()用法及代碼示例
- Ruby Matrix zero()用法及代碼示例
- Ruby Matrix tr()用法及代碼示例
- Ruby Matrix det()用法及代碼示例
- Ruby Matrix unitary?()用法及代碼示例
- Ruby Matrix regular?()用法及代碼示例
- Ruby Matrix upper_triangular?()用法及代碼示例
- Ruby Matrix diagonal()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 Ruby | Matrix transpose() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。