Skip to content

Reduce the complexity of linear_algebra/src/polynom_for_points.py #8605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix review issues
  • Loading branch information
MaximSmolskiy committed Aug 5, 2023
commit 37a7aa52d5adc86b027f01c10e4c6fb7c2abc436
16 changes: 6 additions & 10 deletions linear_algebra/src/polynom_for_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,15 @@ def points_to_polynomial(coordinates: list[list[int]]) -> str:
vector: list[float] = [coordinates[count_of_line][1] for count_of_line in range(x)]

for count in range(x):
zahlen = 0
while zahlen < x:
if count == zahlen:
zahlen += 1
if zahlen == x:
break
bruch = matrix[zahlen][count] / matrix[count][count]
for number in range(x):
if count == number:
continue
fraction = matrix[number][count] / matrix[count][count]
for counting_columns, item in enumerate(matrix[count]):
# manipulating all the values in the matrix
matrix[zahlen][counting_columns] -= item * bruch
matrix[number][counting_columns] -= item * fraction
# manipulating the values in the vector
vector[zahlen] -= vector[count] * bruch
zahlen += 1
vector[number] -= vector[count] * fraction

# make solutions
solution: list[str] = [
Expand Down