Skip to content
Related Articles

Related Articles

Ruby | Matrix first_minor() function
  • Last Updated : 07 Jan, 2020
GeeksforGeeks - Summer Carnival Banner

The first_minor() is an inbuilt method in Ruby returns the submatrix after removing the specified row and column.

Syntax: mat1.first_minor(row_num, col_num)

Parameters: The function needs the row number and column number which are to be removed

Return Value: It returns the submatrix after removal.

Example 1:






# Ruby program for first_minor method in Matrix
   
# Include matrix 
require "matrix"
  
# Initilizes the matrix
mat1 = Matrix[[12, 21], [31, 12]] 
   
# Prints the submatrix after removing 
puts  mat1.first_minor(1, 1)

Output:

Matrix[[12]]

Example 2:




# Ruby program for first_minor method in Matrix
   
# Include matrix 
require "matrix"
  
# Initilizes the matrix
mat1 = Matrix[[6, 7], [9, 10], [12, 4]] 
   
# Prints the submatrix after removing 
puts  mat1.first_minor(0, 1)

Output:

Matrix[[9], [12]]

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :