Ruby | Vector inner_product() function Last Updated : 21 Jan, 2021 Improve Improve Like Article Like Save Share Report 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 Return Value: It returns dot product of given vectors Example 1: Ruby #Ruby program for inner_product() method in Vector #Include matrix require "matrix" #Initialize the vector vec1 = Vector[1, 2] vec2 = Vector[2, 1] #Prints the dot product of vectors puts vec1.inner_product(vec2) Output: 4 Example 2: Ruby #Ruby program for inner_product() method in Vector #Include matrix require "matrix" #Initialize the vector vec1 = Vector[1, 2, 3] vec2 = Vector[2, 1, 4] #Prints the dot product of vectors puts vec1.inner_product(vec2) Output: 16 Like Article Suggest improvement Previous Ruby | Vector norm() function Next Ruby | Matrix rectangular() function Share your thoughts in the comments Add Your Comment Please Login to comment...