Skip to content
Related Articles

Related Articles

Improve Article

Ruby | Vector independent? function

  • Last Updated : 07 Jan, 2020

The independent? is an inbuilt method in Ruby returns true if given vectors are linearly independent otherwise false

Syntax: Vector.independent?(vectors)

Parameters: The function accepts vectors as parameter

Return Value: It returns true if given vectors are linearly independent otherwise false.

Example 1:






#Ruby program for independent ? () method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vector
    vec1
    = Vector[1, 2] vec2 = Vector[2, 1]
  
#Check if vectors are linearly independent or not
                          Vector.independent
    ? (vec1, vec2)

Output:

true

Example 2:




#Ruby program for independent ? () method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vector
    vec1
    = Vector[1, 2] vec2 = Vector[2, 4]
  
#Check if vectors are linearly independent or not
                          Vector.independent
    ? (vec1, vec2)

Output:

false
My Personal Notes arrow_drop_up
Recommended Articles
Page :