Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import numpy as np
  2. with open('a.txt', 'r') as file1:
  3.     with open('a.txt','r') as file11:
  4.         with open('b.txt', 'r') as file2:
  5.             n = len(file1.readline().split()) #количество столбцов в первой матрице
  6.             file1 = file11.readlines()
  7.             file2 = file2.readlines()
  8.             for i in range(len(file1)):
  9.                 file1[i] = list(file1[i].strip().split())
  10.             for j in range(len(file2)):
  11.                 file2[j] = list(file2[j].strip().split())
  12.             m = len(file2) #количество строк во второй матрице
  13.             if n == m:
  14.                 x1 = np.array(file1, 'f')
  15.                 x2 = np.array(file2, 'f')
  16.                 c = np.dot(x1,x2)
  17.                 file3 = open('c.txt', 'w')
  18.                 print(c,file = file3)
  19.                 file3.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement