Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
gj2
matrix = [[3, 2, 3, 4, 2, 1, 1, 2, 2, 3], # epafksimenos (augmented) pinakas 20x10 [2, 3, 4, 2, 1, 5, 3, 2, 2, 1], [3, 1, 2, 5, 2, 3, 1, 3, 1, 3], [1, 3, 1, 4, 1, 1, 3, 2, 2, 1], [3, 2, 2, 3, 1, 2, 2, 1, 1, 2], [2, 1, 3, 1, 2, 4, 2, 3, 2, 3], [3, 1, 1, 3, 3, 3, 1, 3, 1, 3], [3, 3, 3, 2, 1, 1, 2, 2, 2, 1], [3, 3, 1, 1, 1, 1, 1, 1, 3, 1], [1, 2, 1, 1, 3, 2, 1, 1, 2, 3], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0 ,1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]] def matrix_elimination(matrix): # pollaplasiazoume ta stoixeia tis 1hs grammis me ton antistrofo tou protou stoixeiou # afairoume tin 1h grammi apo tis ipoloipes (elimination) # epanalamvanoume tin parapano diadikasia i, k, m, n = 0, 0, 0, 20 while i < n / 2: j = 0 var = matrix[i][i] print ("var =", var, "", "i =", i) for e in matrix[i]: if var != 0: e = e * (1 / var) matrix[i][j] = e j = j + 1 # print ("matrix = ", matrix) m = k + 1 print ("m =", m, "", "i =", i, "", "k =", k) while m < n / 2: var1 = matrix[m][i] print ("var1 =", var1) k = i while k < n / 2: matrix[m][k] = matrix[m][k] - (matrix[i][k] * var1 ) k = k + 1 m = m + 1 k = i k = k + 1 i = i + 1 print (*matrix, sep = "\n") return matrix inverse_matrix = matrix_elimination(matrix) print ("inverse_matrix =",inverse_matrix) i = 0 while i < 20 / 2: j = 0 while j < 10: inverse_matrix[i][j] = round(inverse_matrix[i][j], 1) j = j + 1 i = i + 1 print (*inverse_matrix, sep = "\n") inverse_matrix = [[1.0, 0.66, 1.0, 1.33, 0.66, 0.33, 0.33, 0.66, 0.66, 1.0], [0.0, 1.0, 1.2, -0.39, -0.19, 2.59, 1.4, 0.4, 0.4, -0.6], [0.0, 0.0, 1.0, 3.0, -1.0, 23.0, 7.0, 7.0, -3.0, -3.0], [0.0, 0.0, 0.0, 1.0, 0.16, 4.91, 1.58, 1.66, -0.66, -0.58], [-0.0, -0.0, -0.0, -0.0, 1.0, -8.5, -2.9, 1.6, 1.59, 1.70], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.44, 0.36, -0.06, -0.02], [-0.0, -0.0, -0.0, -0.0, -0.0, -0.0, 1.0, 0.53, 0.53, 0.86], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.15, -0.32], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.83], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]] def upper_matrix_elimination(inverse_matrix): n = 10 i, j, k = n-1, n - 1, 0 # pollaplasiazoume tin teleftea grammi me to telefteo stoixeio tis protelefteas kai afairoume "pro-teleftea - teleftea"... while j > 0: print ("j =", j) i = n - 1 - k while i > 0: var = inverse_matrix[i - 1][j] print ("var =", var, "", "i =", i) for e in inverse_matrix[j]: e = e * var if e != 0: break inverse_matrix[i - 1][j] = inverse_matrix[i - 1][j] - e print (*inverse_matrix, sep = "\n") i = i - 1 k = k + 1 j = j - 1 return inverse_matrix print (upper_matrix_elimination(inverse_matrix))
run
|
edit
|
history
|
help
0
Lesson 3 Homework:
Calculate Volume of Sphere
Bmi calculator dictionary
instance variable class var
Payth
linked_lists
Ej2_python_204676887
Repeated match within another regular expression
python lesson 1 function
How to make a foolto my friend ?