Ruby | Matrix rectangular() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The rectangular() is an inbuilt method in Ruby returns two matrix. The first matrix returned has all the real values of the matrix, and the second matrix has all the imaginary values in the matrix. Syntax: mat1.rectangular() Parameters: The function needs the matrix whose real and imaginary values are to be returned. Return Value: It returns two matrices which has real and imaginary values. Example 1: CPP #Ruby program for rectangular() method in Matrix #Include matrix require "matrix" #Initialize a matrix mat1 = Matrix[[ 1, 21 ], [ 31, 18 ]] #Prints two matrix with real #and imaginary values puts mat1.rectangular() Output: Matrix[[1, 21], [31, 18]] Matrix[[0, 0], [0, 0]] Example 2: CPP #Ruby program for rectangular() method in Matrix #Include matrix require "matrix" #Initialize a matrix mat1 = Matrix[[ 1, 21 ], [ 31, 18 ], [ Complex(1, 9), 1 ]] #Prints two matrix with real #and imaginary values puts mat1.rectangular() Output: Matrix[[1, 21], [31, 18], [1, 1]] Matrix[[0, 0], [0, 0], [9, 0]] Comment More infoAdvertise with us Next Article Ruby | Matrix rect() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix regular?() function The regular?() is an inbuilt method in Ruby returns a boolean value. It returns true if it is a regular matrix, else it returns false. Syntax: mat1.regular?() Parameters: The function needs the matrix to be checked for regular matrix or not. Return Value: It returns true if it is a regular matrix, e 1 min read Ruby | Numeric rectangular() function The rectangular() is an inbuilt method in Ruby returns an array which consists of a real and an imaginary number. Syntax: num.rectangular() Parameters: The function needs the number whose real and imaginary part is returned. Return Value: It returns an array which consists of a real and an imaginary 1 min read Ruby | Matrix rect() function The rect() is an inbuilt method in Ruby returns two matrix. The first matrix returned has all the real values of the matrix, and the second matrix has all the imaginary values in the matrix. Syntax: mat1.rect() Parameters: The function needs the matrix whose real and imaginary values are to be retur 1 min read Ruby | Matrix real?() function The real?() is an inbuilt method in Ruby returns a boolean value. It returns true if all values in the matrix are real, else it returns false. Syntax: mat1.real?() Parameters: The function needs the matrix which is to be checked for real values Return Value: It returns true if it all values are real 1 min read Ruby | Matrix real() function The real() is an inbuilt method in Ruby returns a matrix with only real part in it. The other index are assigned to zero. Syntax: mat1.real() Parameters: The function does not takes any parameter. Return Value: It returns a matrix with only real part. Example 1: CPP #Ruby program for real() method i 1 min read Ruby | Matrix rank() function The rank() is an inbuilt method in Ruby returns the rank of the given matrix. The float values can yield enormous results due to float precision Syntax: mat1.rank() Parameters: The function does not accepts any parameter. Return Value: It returns the rank of the current matrix. Example 1: CPP #Ruby 1 min read Like