Created
May 1, 2020 23:00
-
-
Save rendrap/a493c095286703f92fcea93b88368000 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Definindo numpy | |
import numpy as np | |
# Criando uma matriz | |
a = np.random.random_integers(0, 4, (3, 3)) | |
print ("Matriz A\n", a) | |
b = np.random.random_integers(0, 4, (3, 3)) | |
print ("Matriz B\n" ,b) | |
# Tomando as dimensões de uma matriz | |
print ("A matriz A tem a forma", a.shape) | |
print ("A matriz A tem a forma", b.shape) | |
# Fazendo cálculos simples (soma, subtração, multiplicação e divisão) | |
# Soma de matrizes | |
print("Matriz A+B\n", np.add(a,b)) | |
# Subtração de matrizes | |
print("Matriz A-B\n", np.subtract(a,b)) | |
# Multiplicação de matrizes | |
print("Matriz A*B elementwise\n", np.dot(a,b)) | |
# Multiplicação elementwise | |
print("Matriz A*B\n", np.multiply(a,b)) | |
# Criando uma matriz identidade | |
print("Matriz Identidade\n", np.identity(3)) | |
# Criando uma matriz de um's | |
print("Matriz com 1's\n", np.ones((3,3))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment