ejercicio
en este programa veremos como hacer operaciones aritmeticas con matrices :
import numpy as np
from numpy import matrix
print ("a)")
print ("matriz A")
A=matrix([[2,4,1],[1,-2,3],[5,0,-1]])
print (A)
print("tamaño de la matriz")
print (A.shape)
print ("dimension de la matriz")
print (A.ndim)
print (A.dtype)
print ()
print ("matriz B")
B=matrix ([[3,-1,-2],[0,5,6],[0,0,9]])
print (B)
print("tamaño de la matriz")
print (B.shape)
print ("dimension de la matriz")
print (B.ndim)
print (B.dtype)
print ()
print("matriz C")
C=matrix([[2,0,-1],[0,-1,2],[1,-2,5]])
print (C)
print("tamaño de la matriz")
print (C.shape)
print ("dimension de la matriz")
print (C.ndim)
print (B.dtype)
print ()
print ("b)")
print ("1) -A-B+C")
print (-A-B+C)
print()
print ("2) A+B-C")
print (A+B-C)
print()
print ("3) 3A+C/2")
print ((3*A)+(C/2))
print ()
D=matrix([[3,2,1],[0,2,-5],[-2,1,4]])
print (D)
print (D.dtype)
print (D.shape)
print (np.linalg.det(D))
import numpy as np
from numpy import matrix
print ("a)")
print ("matriz A")
A=matrix([[2,4,1],[1,-2,3],[5,0,-1]])
print (A)
print("tamaño de la matriz")
print (A.shape)
print ("dimension de la matriz")
print (A.ndim)
print (A.dtype)
print ()
print ("matriz B")
B=matrix ([[3,-1,-2],[0,5,6],[0,0,9]])
print (B)
print("tamaño de la matriz")
print (B.shape)
print ("dimension de la matriz")
print (B.ndim)
print (B.dtype)
print ()
print("matriz C")
C=matrix([[2,0,-1],[0,-1,2],[1,-2,5]])
print (C)
print("tamaño de la matriz")
print (C.shape)
print ("dimension de la matriz")
print (C.ndim)
print (B.dtype)
print ()
print ("b)")
print ("1) -A-B+C")
print (-A-B+C)
print()
print ("2) A+B-C")
print (A+B-C)
print()
print ("3) 3A+C/2")
print ((3*A)+(C/2))
print ()
D=matrix([[3,2,1],[0,2,-5],[-2,1,4]])
print (D)
print (D.dtype)
print (D.shape)
print (np.linalg.det(D))
Comentarios
Publicar un comentario