Ruby | Vector norm() function Last Updated : 06 Jan, 2020 Comments Improve Suggest changes Like Article Like Report 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: It pythagorean distance of the vector Example 1: Ruby # Ruby program for norm() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[1, 2, 3] # Prints pythogras of the vector puts vec1.norm() Output: 3.7416573867739413 Example 2: Ruby # Ruby program for norm() method in Vector # Include matrix require "matrix" # Initialize the vector vec1 = Vector[1, 1, 1] # Prints pythogras of the vector puts vec1.norm() Output: 1.7320508075688772 Comment More infoAdvertise with us Next Article Ruby | Vector norm() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Vector-class Similar Reads Ruby | Vector r() function 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: It Pythagorean distance of the vector Example 1: Ruby # Ruby program for r() method in Vector # Include matrix require "matrix" 1 min read Ruby | Vector normalize() function 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: The function accepts no parameter Return Value: It returns a new vector with the same direction but with norm equals to 1. Example 1: Ruby # Ruby 1 min read Ruby | Vector round() function 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 a single parameter Return Value: It returns a new vector with entries rounded to the given precision Example 1: Ruby # Ruby program for roun 1 min read Ruby | Vector hash() function The hash() is an inbuilt method in Ruby returns hash code of the vector Syntax: vec1.hash() Parameters: The function accepts no parameter. Return Value: It returns hash code of the vector. Example 1: Ruby # Ruby program for hash() method in Vector # Include matrix require "matrix" # Initia 1 min read Ruby | Vector eql?() function The eql?() is an inbuilt method in Ruby returns boolean value true if two vectors are same otherwise false Syntax: vec1.eql?(vec2) Parameters: The function accepts a single vector as parameters Return Value: It returns boolean value true if two vectors are same otherwise false Example 1: Ruby # Ruby 1 min read Like