import numpy as np
A = np.array([[4,1,7],[2,1,8],[3 ,7,1]])
B = np.array([[6,1,1],[2,1,5],[2,3,1]])
C=A.dot(B)
print(“Values of First 2D Matrixn”,A)
print(“Values of Second 2D Matrixn”,B)
print(“———————————————“)
print(“Multiplication of Matricesn”,C)
print(“n”)
Ainv=np.linalg.inv(A)
Binv=np.linalg.inv(B)
print(“Inverse of First Matrixn”,Ainv)
print(“Inverse of Second Matrixn”,Binv)
print(“n”)
AI=Ainv.dot(A)
BI=Binv.dot(B)
print(“Multiplication of First Matrix and their Inversen”,AI)
print(“Multiplication of Second Matrix and their Inversen”,BI)
AD=np.linalg.det(A)
BD=np.linalg.det(B)
print(“n”)
print(“Determinant of First Matricx:”,AD)
print(“Determinant of Second Matricx:”,BD)
print(“n”)
ADi=np.diag(A)
BDi=np.diag(B)
print(“Diagonal Elements of First Matrix:”,ADi)
print(“Diagonal Elements of Second Matrix:”,BDi)
SADi=np.trace(A)
SBDi=np.trace(B)
print(“n”)
print(“Sum of Diagonal Elements of First Matrix:”,SADi)
print(“Sum of Diagonal Elements of Second Matrix:”,SBDi)
print(“n”)
CA=np.cov(A)
CB=np.cov(B)
print(“Covariance matrix of First Matrixn”,CA)
print(“Covariance matrix of Second Matrixn”,CB)
print(“n”)
ECA=np.linalg.eigh(CA)
ECB=np.linalg.eigh(CB)
print(“First array represents eigenvalues and second array represents eigenvectors”)
print(“n”)
print(“covariance matrix eigenvalues eigenvectors of First Matrixn”,ECA)
print(“n”)
print(“covariance matrix eigenvalues eigenvectors of Second Matrixn”,ECB)

Source link

Operations on Matrices

Leave a Reply

Your email address will not be published. Required fields are marked *