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

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

红宝石 |矩阵 column_vectors()函数

column_vectors()是 Ruby 中的内置方法,返回包含列的向量数组。

示例 1

# Ruby program for column_vectors() method in Matrix
   
# Include matrix 
require "matrix"
   
# Initialize a matrix 
mat1 =  Matrix[[1, 21], [31, 18]]       
   
# prints the columns
puts  mat1.column_vectors

输出

Vector[1, 31]
Vector[21, 18]

示例 2

# Ruby program for column_vectors() method in Matrix
   
# Include matrix 
require "matrix"
   
# Initialize a matrix 
mat1 =  Matrix[[13, 1, 5], [12, 1, 5], [11, 2, 5]]   
   
# prints the columns
puts  mat1.column_vectors

输出

Vector[13, 12, 11]
Vector[1, 1, 2]
Vector[5, 5, 5]