tions and me

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 29SA
icon
Related questions
Question
100%

create a flowchart discuss the functions and methods 

[30] def mat_operations (mat1, mat2):
mat1 = np.array (mat1)
mat2 = np.array (mat2)
print('Matrix 1:', mat1)
print('Matrix 2:', mat2)
if (mat1.shape != mat2.shape):
print('The shape of both matrices are not same. Could not perform operations.')
return
print('Sum of the given matrices:')
msum = mat1 + mat2
print (msum)
print('Difference of the given matrices:')
mdiff = mat1
mat2
print (mdiff)
print('Element-wise multiplication of the given matrices:')
mmul = np.multiply(mat1, mat2)
print (mmul)
print ('Element-wise division of the given matrices:')
mmul = np.divide(mat1, mat2)
print (mmul)
Transcribed Image Text:[30] def mat_operations (mat1, mat2): mat1 = np.array (mat1) mat2 = np.array (mat2) print('Matrix 1:', mat1) print('Matrix 2:', mat2) if (mat1.shape != mat2.shape): print('The shape of both matrices are not same. Could not perform operations.') return print('Sum of the given matrices:') msum = mat1 + mat2 print (msum) print('Difference of the given matrices:') mdiff = mat1 mat2 print (mdiff) print('Element-wise multiplication of the given matrices:') mmul = np.multiply(mat1, mat2) print (mmul) print ('Element-wise division of the given matrices:') mmul = np.divide(mat1, mat2) print (mmul)
[28] def mat_desc (mat):
sq = False
mat = np.array(mat)
print (mat)
print('Shape: ', mat.shape)
print('Size:', mat.size)
print ('Rank:', np.linalg.matrix_rank(mat))
if (mat.shape[0]
sq = True
print('The matrix is square')
mat.shape[1]):
=3D
else:
print('The matrix is non-square')
if (mat.shape[0] == 0 and mat.shape[1]
print('The matrix is empty')
0):
==
else:
print('The matrix is not empty')
iden = np.identity(mat.shape[0])
if(sq and (iden == mat).all()):
print('The matrix is an identity matrix')
else:
print('The matrix is not an identity matrix')
one = np.ones ((mat.shape[0], mat.shape[1]))
if((one == mat).all()):
print('The matrix is an ones matrix')
else:
print('The matrix is not an ones matrix')
np.zeros ( (mat.shape[0], mat.shape[1]))
zero =
if((zero == mat).all()):
print('The matrix is an zeros matrix')
else:
print('The matrix is not a zeros matrix')
Transcribed Image Text:[28] def mat_desc (mat): sq = False mat = np.array(mat) print (mat) print('Shape: ', mat.shape) print('Size:', mat.size) print ('Rank:', np.linalg.matrix_rank(mat)) if (mat.shape[0] sq = True print('The matrix is square') mat.shape[1]): =3D else: print('The matrix is non-square') if (mat.shape[0] == 0 and mat.shape[1] print('The matrix is empty') 0): == else: print('The matrix is not empty') iden = np.identity(mat.shape[0]) if(sq and (iden == mat).all()): print('The matrix is an identity matrix') else: print('The matrix is not an identity matrix') one = np.ones ((mat.shape[0], mat.shape[1])) if((one == mat).all()): print('The matrix is an ones matrix') else: print('The matrix is not an ones matrix') np.zeros ( (mat.shape[0], mat.shape[1])) zero = if((zero == mat).all()): print('The matrix is an zeros matrix') else: print('The matrix is not a zeros matrix')
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Boolean Algebra and Digital Logics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning