📜  红宝石 |矩阵 first_minor()函数

📅  最后修改于: 2022-05-13 01:55:34.097000             🧑  作者: Mango

红宝石 |矩阵 first_minor()函数

first_minor()是 Ruby 中的内置方法,在删除指定的行和列后返回子矩阵。

示例 1

Ruby
# Ruby program for first_minor method in Matrix
  
# Include matrix
require "matrix"
 
# Initializes the matrix
mat1 = Matrix[[12, 21], [31, 12]]
  
# Prints the submatrix after removing
puts  mat1.first_minor(1, 1)


Ruby
# Ruby program for first_minor method in Matrix
  
# Include matrix
require "matrix"
 
# Initializes the matrix
mat1 = Matrix[[6, 7], [9, 10], [12, 4]]
  
# Prints the submatrix after removing
puts  mat1.first_minor(0, 1)


输出

Matrix[[12]]

示例 2

红宝石

# Ruby program for first_minor method in Matrix
  
# Include matrix
require "matrix"
 
# Initializes the matrix
mat1 = Matrix[[6, 7], [9, 10], [12, 4]]
  
# Prints the submatrix after removing
puts  mat1.first_minor(0, 1)

输出

Matrix[[9], [12]]