Skip to content
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

Ensuring ability for reentry #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Schnierle
Copy link

@Schnierle Schnierle commented Jul 30, 2018

Problem description

Your implementation of gaussian elimination fails for integration in e.g. Newton algorithm, because it's not able to reentry.
Try following:

$A = [[1, 1, 1], [2, 1, 2], [1, 2, 3]]; $x = [6, 10, 14]; $result = gauss($A, $x); console.log($result); $result = gauss($A, $x); console.log($result); $result = gauss($A, $x);

You get 3 different solutions because A and x are changed every time we call gauss. The problem is that you give the variables over Call by Reference to the algorithm.

My pull request

Let us copy A and x (I called it b) at the beginning of the algorithm.

Creates copys of A and b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant