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

updating gaussian elimination to be more general #219

Merged

Conversation

leios
Copy link
Member

@leios leios commented Jul 5, 2018

Hey guys, following the discussion in #193 and #201 , we looked at making the Gaussian Elimination code more general. This change does not change the computational complexity of the gaussian_elimination function, but it does for the back-substitution.

In the previous julia version, we were literally plugging the values in for the upper diagonal matrix. In this version, we are actually doing the full Gauss-Jordan elimination and creating a reduced row eschelon matrix. The definition of "back-substitution" can mean either case.

As we mentioned before, the previous code we had submitted was not "wrong"; however, this is technically more general. I am curious to see what you guys think about the back-substitution step. In the worst-case, we can add a condition to switch between the methods if the matrix is not singular (which means that it admits a regular set of solutions). As a note: the solution vector of this method is the last column of the output matrix.

Please let me know what you think about this implementation. We can always change it.

@Gathros Gathros added Chapter Edit This changes the archive's chapters. (md files are edited.) Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.) and removed Chapter Edit This changes the archive's chapters. (md files are edited.) labels Jul 5, 2018
@jiegillet
Copy link
Member

I want to apologize for not fully grasping your original implementation. I had not realized that the complexity was so different.
I support the idea of keeping both functions. Checking if a matrix is singular after it goes through gaussian_elimination is as simple as checking A[rows, cols-1] == 0 (or by stopping the computation as you were doing before). After that, one could decide to use your old back_substitution or, say, to_reduced_echelon.

@leios
Copy link
Member Author

leios commented Jul 5, 2018

I'm alright with having multiple implementations that switch off depending on the matrix. It should be easy enough to implement and we can highlight the difference in the text.

@jiegillet
Copy link
Member

I don't even think you need to implement it, you just need to make both functions available and let people decide which method they want. Someone who only wants to solve a system wouldn't be interested in looking at the reduced echelon form anyway.

@leios
Copy link
Member Author

leios commented Jul 5, 2018

Yeah, I just meant that we re-write the code like you suggested and mention the differences in the text.

@jiegillet
Copy link
Member

God I really wish I had not put text and code in the same PR. Do you want me to do it or you want to PR my branch?

@leios
Copy link
Member Author

leios commented Jul 5, 2018

I will PR your branch (tomorrow, though)

leios added 2 commits July 8, 2018 19:35
…ination and back-substitution. Rough edit because I am sure there will be discussion.
@leios
Copy link
Member Author

leios commented Jul 8, 2018

Alright, sorry this took so long. I was busy this weekend with other commitments. Here is an attempt to solve the issues and PR's for Gaussian Elimination.

I split the chapter to have both Gauss-Jordan elimination and back-substitution, which seemed to be the fairest thing to do. This allows the programmer to choose which method best suits their use-case. I am sure there will be discussion, so this is a "rough" edit.

@jiegillet
Copy link
Member

This is a good change. I'll get rid of the chapter edits in my PR.
A small nitpick is the inconsistent capitalization of Echelon Form/echelon form.

@jiegillet jiegillet closed this Jul 8, 2018
@jiegillet
Copy link
Member

Sorry, closed it by mistake

@jiegillet jiegillet reopened this Jul 8, 2018
@leios
Copy link
Member Author

leios commented Jul 8, 2018

No prob bob. I'll review for typos and update this PR soon.

@jiegillet jiegillet added the Chapter Edit This changes the archive's chapters. (md files are edited.) label Jul 8, 2018
@leios leios requested a review from jiegillet July 15, 2018 11:19
Copy link
Member

@jiegillet jiegillet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those were the only nitpicks I found

@@ -1,43 +1,47 @@
using DataStructures
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed anymore.


1. All non-zero rows are above rows of all zeros
2. The leading coefficient or _pivot_ (the first non-zero element in every row when reading from left to right) is right of the pivot of the row above it.

Now, Row Eschelon Form is nice, but wouldn't it be even better if our system of equations looked simply like this
All the following examples are in the Row Echelon Form:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The capitalization of [R|r]ow [E|e]echelon is all over the place. After some thoughts, I suggest dropping the capital letter everywhere (since row echelon is not a name, it's like saying diagonal), except maybe when it's first introduced. Same deal for RRE.

@leios
Copy link
Member Author

leios commented Jul 17, 2018

Cool, I'll make the changes as soon as I get home tonight!

EDIT: Made them now.

@jiegillet jiegillet merged commit 918cb57 into algorithm-archivists:master Jul 17, 2018
@leios leios deleted the gaussian_elimination_update branch September 21, 2018 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chapter Edit This changes the archive's chapters. (md files are edited.) Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants