def suma_vect(v1,v2): if len(v1) == len(v2): resul = [] for i in range(0,len(v1)): resul.append(com.suma(v1[i],v2[i])) return resul else: return "El tamaño de los vectores no coincide"
def suma_matrices(ma1,ma2): if (len(ma1) == len(ma2)) and (len(ma1[0])== len(ma2[0])): matriz = [] for i in range(0,len(ma1)): fila = [] for j in range (0,len(ma1[0])): re = com.suma(m1[i][j],m2[i][j]) fila.append(re) matriz.append(fila) return matriz else: return "El tamaño de las matrices no coincide"
def multiplicacion_mat(ma1,ma2): fi1,co1 = len(ma1),len(ma1[0]) fi2,co2 = len(ma2),len(ma2[0]) if co1 == fi2: matres = [[[0,0] for i in range(co2)]for j in range (fi1)] for i in range (0,fi1): for j in range(0,co2): for k in range (0,co1): matres[i][j] = com.suma(matres[i][j],com.multiplicacion(ma1[i][k],ma2[k][j])) return matres else: return "No es posible multiplicar las matrices"
def accion_ma_ve(ma,ve): fi1,co1 = len(ma),len(ma[0]) fi2,co2 = len(ve),len(ve[0]) if co1 == fi2: matres = [[[0,0] for i in range(fi1)]for j in range (co2)] for i in range (0,fi1): for j in range(0,co2): for k in range (0,co1): matres[i][j] = com.suma(matres[i][j],com.multiplicacion(ma[i][k],ve[k][j])) return matres else: return "No es posible multiplicar las matrices" return res