Open In App

Ruby | Vector covector() function

The covector() is an inbuilt method in Ruby returns a single-row matrix created using vector

Syntax: vec1.covector()



Parameters: The function accepts no parameter

Return Value: It returns a single-row matrix created using vector



Example 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()

Output:

Matrix[[1, 2]]

Example 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()

Output:

Matrix[[1, 2, 3]]
Article Tags :