Comparing Maximum from Matrices | Linear Algebra using Python

Linear Algebra using Python | Comparing Maximum from Matrices: Here, we are going to learn about the comparing maximum from matrices and its implementation in Python.
Submitted by Anuj Singh, on June 08, 2020

Prerequisites:

Learn: how to find the maximum value from comparison of each element in two matrices using an inbuilt function in the numpy library?

Syntax:

numpy.maximum(Matrix_M1, Matrix_M2)

Return:

A matrix of same dimension with given matrix containing maximum value at each entry among both matrices.

Python code for comparing maximum from matrices

# Linear Algebra Learning Sequence
# Maximum Value Comparing

import numpy as np

M = np.array([[2,3,4], [4,4,8], [4,8455,7], [4,8,99] ])
MM = np.array([[2,3,46], [4,44,8], [4,8,7], [4,8,9] ])
print("\n\n---Matrix A---\n", M)
print("\n\n---Matrix B---\n", MM)
print('\n\n---maximum value comparasion : ', np.maximum(M,MM))

Output:


---Matrix A---
 [[   2    3    4]
 [   4    4    8]
 [   4 8455    7]
 [   4    8   99]]


---Matrix B---
 [[ 2  3 46]
 [ 4 44  8]
 [ 4  8  7]
 [ 4  8  9]]


---maximum value comparasion :  [[   2    3   46]
 [   4   44    8]
 [   4 8455    7]
 [   4    8   99]]





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





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.