Horje
Ruby | Matrix column_size() function

The column_size() is an inbuilt method in Ruby returns the number of columns in a matrix.

Syntax: mat1.column_size()

Parameters: The function does not accepts any parameter.

Return Value: It returns the number of columns in a matrix.

Example 1:




# Ruby program for column_size() method in Matrix
  
# Include matrix 
require "matrix"
  
# Initialize a matrix 
mat1 =  Matrix[[1, 21], [31, 18]]    
  
# prints the number of columns 
puts  mat1.column_size

Output:

2

Example 2:




# Ruby program for column_size() method in Matrix
  
# Include matrix 
require "matrix"
  
# Initialize a matrix 
mat1 =  Matrix[[13, 1, 5], [12, 1, 5], [11, 2, 5]]   
  
# prints the number of columns 
puts  mat1.column_size

Output:

3



Reffered: https://www.geeksforgeeks.org


Ruby

Related
Ruby | Matrix column() function Ruby | Matrix column() function
Ruby | Matrix column_count() function Ruby | Matrix column_count() function
Ruby | Matrix collect() function Ruby | Matrix collect() function
Ruby | Matrix cofactor_expansion() function Ruby | Matrix cofactor_expansion() function
Ruby | Matrix cofactor() function Ruby | Matrix cofactor() function

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
10