2005-04-07

matrix solver update

  • matrix solver
    Update 7/5/2005 solves for parametric matrices. Update 4/5/2005 - proper detection of the nature of solutions, code clean up, as well as fixing the infinite loop that occurs for certain matrices. A simple program I wrote after learning about matrixes. It performs Guassian elimination on a given matrix, then uses what I considered a very elegant loop to perform back subtitution to solve the system of equations where a solution exists.

    Features
    • Command line based
    • Detects unique, parametric solutions, as well as no solutions
    • Prints unique and parametric solutions
    • Works! :)
    • Will print out working
    • Small

    Download
Example:
solaris:~/code/matrixSolver steve$ ./matrixSolver 3 1 0 -2 1 3 1 -6 1 0 0 0 0
Solving below matrix
0 [ 1.000 0.000 -2.000 1.000 ]
1 [ 3.000 1.000 -6.000 1.000 ]
2 [ 0.000 0.000 0.000 0.000 ]

0 [ 1.000 0.000 -2.000 1.000 ]
1 [ 0.000 1.000 0.000 -2.000 ]
2 [ 0.000 0.000 0.000 0.000 ]

matrix has parametric solution:
unknown0: 1 + 2 * s0
unknown1: -2
unknown2: s0
Cheers,
Steve