Clean up Java implementation of Thomas Algorithm #496
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When merged, this PR fixes a few issues with the Java implementation of the Thomas algorithm and also changes it so that it works similarly to the new Julia implementation (#495).
The class and file name were
thomas
, but classes in Java should be PascalCase, so I renamed them toThomas
.The
thomasAlgorithm
method had aint size
parameter, which is not needed in Java. I assume that the code was directly ported from the C implementation and that was not taken out.I had a short talk with @leios on stream today. I mentioned how almost none of the implementations return the result. Instead, they all modify the input vector, which they get passed by reference. The new version of this does not modify any of the input vectors and returns the output vector.
The output was quite messy, also as a result of the fact that the code was directly ported over from C.
All the array declarations were formatted as
double x[]
instead ofdouble[] x
. The latter is, as far as I know, the preferred way in Java. This is probably also an artifact of the port from C.Lastly, I made the output dynamic. The output is hard-coded in almost all implementations and I think we should change that. It's not that difficult.
Note: I don't know why GitHub reports thomas.py as deleted and Thomas.py as new. I used
git mv
to rename the file.