-
-
Save parzibyte/bb96d0c5089858b3de2110ec208f55a5 to your computer and use it in GitHub Desktop.
This file contains 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
def producto_matrices(a, b): | |
filas_a = len(a) | |
filas_b = len(b) | |
columnas_a = len(a[0]) | |
columnas_b = len(b[0]) | |
if columnas_a != filas_b: | |
return None | |
# Asignar espacio al producto. Es decir, rellenar con "espacios vacíos" | |
producto = [] | |
for i in range(filas_b): | |
producto.append([]) | |
for j in range(columnas_b): | |
producto[i].append(None) | |
# Rellenar el producto | |
for c in range(columnas_b): | |
for i in range(filas_a): | |
suma = 0 | |
for j in range(columnas_a): | |
suma += a[i][j]*b[j][c] | |
producto[i][c] = suma | |
return producto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment