So this quarter at UCSC I’m taking a couple math classes but, unfortunately, I’m not taking any computer classes. That’s a bit of a bummer because I’ve recently realized I’m in LOVE with programming. I love the fact I’m creating something from scratch that is working, interactive, and returns workable output. For me that’s a big deal, I love creative tangible things like art, crafts, and cooking (especially baking bagels!) I’d call myself new to programming still, but I’m getting the hang of it quickly and loving where it’s taking me.
My TA in one of my math classes encouraged computer people to implement the process of bringing a rectangular matrix to reduced row echelon form. If you’re familiar with this procedure, you know it’s a pain in the butt manually. So I took on the challenge since I’m not doing any other programming at the moment. I used the shell code of a previous project that solves sudoku puzzles. If you can imagine, a sudoku is just a matrix with strict 9x9 dimensions. So my new matrix.java program accepts a matrix of any size and outputs the reduced row echelon form.
Just as an example, there is a matrix in a file test2:
$ java matrix test2 Initial Matrix is 5 x 8 0 0 0 0 0 1 2 3 0 2 0 3 0 4 0 6 0 1 2 3 4 5 6 -9 1 3 -9 -2 -3 -4 1 2 1 2 4 5 1 10 22 33 Reduced row echelon form: 1 0 0 0 53/5 0 94/5 -47 0 1 0 0 -132/5 0 -86/5 144 0 0 1 0 -56/5 0 -33/5 63 0 0 0 1 88/5 0 44/5 -98 0 0 0 0 0 1 2 3
Matrix.java uses a custom fraction class to handle fractions instead of using decimals. Also I found a nifty port of getopt for java that I used to handle command line arguments. Check out the code and use it / modify it for yourself over at my GitHub page. Also look around my profile for the sudoku solver and other code. In future versions I hope to add some functionality such as checking the consistency of the input matrix as well as solving for the variables. Check the git repo for future changes if you’d like!
word.
Reading your code reminds me why I use Fortran.…
Java could beat up fortran anyday.