Friday, August 20, 2010

Polynomial Solver - C++

Over the past week or so, I've been posting different versions of my polynomial solver program on the PC Scripts Forums. Now, I have finished it and I probably won't make any changes to it anymore. The program is object oriented and has three files. For convenience, I have packaged the source into a downloadable tarball. It can be downloaded here. The current version of this program is 1.5.


Compiling in an IDE

To compile this program in your favorite IDE, follow these instructions:

  1. Create a new C++ project
  2. Add a new C++ source file and call it polynomialsolver.cpp
  3. Copy and paste the contents of polynomialsolver.cpp into the project source file
  4. Add a new C++ source file and call it Polynomial.cpp
  5. Copy and paste the contents of Polynomial.cpp into the corresponding source file in the project
  6. Add a new C++ header file and call it Polynomial.h
  7. Copy and paste the contents of Polynomial.h into the Polynomial header file in the project
  8. Compile and run the program how you would any other program in your IDE


Compiling From the Terminal

I have not been able to compile this program from the Linux terminal using GCC. If anyone knows how to compile multi-file object oriented programs using GCC, please leave a comment.


Bugs

There are a few bugs in my program.

  • I can't get the private function PrintPoly() to correctly output the polynomial. This does not affect the answer it gives but it cannot correctly display polynomials like x4-500x2+1000. If anyone knows how to fix this bug, please leave a comment.
  • Outputs errors when the sensitivity of GetValues(). Again, if anyone knows how to fix this, please leave a comment.

No comments:

Post a Comment