Skip to content

Tag Archives: Ruby Vector-class

The norm() is an inbuilt method in Ruby returns the pythagorean distance of the vector. Syntax: vec1.norm() Parameters: The function accepts no parameter Return Value:… Read More
The zero?() is an inbuilt method in Ruby returns boolean value true if all elements of vector are equals to zero otherwise false Syntax: vec1.zero?()… Read More
The to_matrix() is an inbuilt method in Ruby returns the matrix of single column with elements of vector. Syntax: vec1.to_matrix() Parameters: The function accepts no… Read More
The to_a() is an inbuilt method in Ruby returns the array with elements of vector Syntax: vec1.to_a() Parameters: The function accepts no parameter Return Value:… Read More
The size() is an inbuilt method in Ruby returns the number of elements in the vector Syntax: vec1.size() Parameters: The function accepts no parameter Return… Read More
The round() is an inbuilt method in Ruby returns a new vector with entries rounded to the given precision Syntax: vec1.round() Parameters: The function accepts… Read More
The normalize() is an inbuilt method in Ruby returns a new vector with the same direction but with norm equals to 1. Syntax: vec1.normalize() Parameters:… Read More
The r() is an inbuilt method in Ruby returns the Pythagorean distance of the vector. Syntax: vec1.r() Parameters: The function accepts no parameter Return Value:… Read More
The * is an inbuilt method in Ruby returns a vector by multiplying vector by x Syntax: vec1 * x Parameters: The function does not… Read More
The angle_with() is an inbuilt method in Ruby returns the angle between two vectors. The angle is always between 0 and π Syntax: vec1.angle_with(vec2) Parameters:… Read More
The inner_product() is an inbuilt method in Ruby returns dot product of given vectors. Syntax: vec1.inner_product(vec2) Parameters: The function accepts a single vector as parameters… Read More
The + is an inbuilt method in Ruby returns the addition of two vectors Syntax: vec1 + vec2 Parameters: The function does not accepts any… Read More
The – is an inbuilt method in Ruby returns the substraction of two vectors Syntax: vec1 – vec2 Parameters: The function does not accepts any… Read More
The / is an inbuilt method in Ruby returns a vector by dividing vector by x Syntax: vec1 / x Parameters: The function does not… Read More
The [] is an inbuilt method in Ruby returns the element at position x, indexing starts from 0. Syntax: vec1[x] Parameters: The function does not… Read More