Ruby | Vector zero() function
The zero() is an inbuilt method in Ruby returns the vector of size N with elemets equals to 0.
Syntax: Vector.zero(N)
Parameters: The function accepts a parameter which represents the size of the array.
Return Value: It returns the vector of size N with elemets equals to 0.
Example 1:
#Ruby program for zero method in Vector #Include matrix require "matrix" #Initialize the vector vec1 = Vector.zero(4) #prints the new vector puts vec1 |
chevron_right
filter_none
Output:
Vector[0, 0, 0, 0]
Example 2:
#Ruby program for zero method in Vector #Include matrix require "matrix" #Initialize the vector vec1 = Vector.zero(3) #prints the new vector puts vec1 |
chevron_right
filter_none
Output:
Vector[0, 0, 0]
Recommended Posts:
- Ruby | Vector eql?() function
- Ruby | Vector zero?() function
- Ruby | Vector r() function
- Ruby | Vector to_a() function
- Ruby | Vector hash() function
- Ruby | Vector independent? function
- Ruby | Vector covector() function
- Ruby | Vector cross_product() function
- Ruby | Vector norm() function
- Ruby | Vector round() function
- Ruby | Vector size() function
- Ruby | Vector to_matrix() function
- Ruby | Vector inner_product() function
- Ruby | Vector angle_with() function
- Ruby | Vector elements() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

