红宝石 |向量 covector()函数
covector()是 Ruby 中的内置方法,返回使用向量创建的单行矩阵
Syntax: vec1.covector()
Parameters: The function accepts no parameter
Return Value: It returns a single-row matrix created using vector
示例 1 :
#Ruby program for covector() method in Vector
#Include matrix
require "matrix"
#Initialize the vector
vec1
= Vector[1, 2]
#Prints single - row matrix
puts vec1.covector()
输出:
Matrix[[1, 2]]
示例 2 :
#Ruby program for covector() method in Vector
#Include matrix
require "matrix"
#Initialize the vector
vec1
= Vector[1, 2, 3]
#Prints single - row matrix
puts vec1.covector()
输出:
Matrix[[1, 2, 3]]