ADVERTISEMENT
ADVERTISEMENT

Python | Range of a Matrix

Python | Range of a Matrix: Here, we are going to learn about the range of a matrix and how to find it?
Submitted by Anuj Singh, on July 11, 2020

The range of a matrix can be defined as the difference between the maximum and minimum among the elements of the matrix. In NumPy, we have provided with an inbuilt function for this operation i.e. numpy.ptp(). It returns the range of the matrix by calculating maximum-minimum.

Python | Range of a Matrix Output

Python code to find range of a matrix

# Linear Algebra Learning Sequence
# Range of a Matrix

import numpy as np

a = np.array([[14,5,3], [7,8,9], [4,2,-6]])

print('Matrix A : ', a)

# Range
print('Range of the matrix A : ', np.ptp(a))

Output:

Matrix A :  [[14  5  3]
 [ 7  8  9]
 [ 4  2 -6]]
Range of the matrix A :  20
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.