Advertisement
Oppaceted

CreateW

May 27th, 2024
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. def CreateW(A: list, B: list, column: list, headers: list) -> list:
  2.     W = [0]*(len(A[0])+1)      
  3.     for i in range(len(A)):
  4.         if column[i][0] == 'y':
  5.             for j in range(len(A[0])):
  6.                 W[j] += A[i][j]
  7.             W[len(A[0])] += B[i]
  8.     for j in range( len( A[0] ) ):
  9.         if headers[j][0] == 'y':
  10.             W[j] += 1
  11.     return W
  12.  
  13. def ChangeFunctional(column: list, Functional_koeff: list) -> list:
  14.     new_Functional = list(Functional_koeff)
  15.     for i in range(len(column)):
  16.         new_Functional[i] = Functional_koeff[int(column[i][2])-1]
  17.     return new_Functional
  18.  
  19. def CreateF(A: list, B: list, Functional_koeff: list) -> list:
  20.     F = [0]*(len(A[0])+1)
  21.     for i in range(len(A)):
  22.         for j in range(len(A[0])):
  23.             F[j] += Functional_koeff[i]*A[i][j]
  24.     for i in range(len(A)):
  25.         F[len(F)-1] += B[i]*Functional_koeff[i]
  26.     return F
  27.  
  28. def ChangeF(A: list, B: list, F: list, stroka_number: int, stolbec_number: int):
  29.     F[len(F)-1] += B[stroka_number]*F[stolbec_number]
  30.     for j in range(len(A[0])):
  31.         for i in range(len(A)):    
  32.             pass
  33.         if j == stolbec_number:
  34.             #print(f'A: {A[stroka_number][stolbec_number]}')#отладка
  35.             #print(f'F[j]: {F[j]}')#отладка
  36.             F[j] *= A[stroka_number][stolbec_number]
  37.         else:
  38.             F[j] += F[stolbec_number]*A[stroka_number][j]
  39.     return F
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement