At the link below is posted a C++ translation of the FORTRAN routine RPOLY.FOR, which is posted off the NETLIB site as TOMS/493. The direct URL is as follows:
RPOLY is based on the Jenkins-Traub algorithm.
TOMS/493 would be used to find the roots of polynomials of degree 100 or less, and whose coefficients are real.
To distinguish the routines posted at the link below from others, an _ak1 suffix has been appended to them.
Following is a list of the major changes made in the course of translating the TOMS/493 routines to the C++ versions posted at the link below:
1) All global variables have been eliminated.
2) The "FAIL" parameter passed into RPOLY.FOR has been eliminated in rpoly_ak1.
3) RPOLY.FOR solves polynomials of degree up to 100, but does not explicitly state this limit.
rpoly_ak1 explicitly states this limit; uses the macro name, MAXDEGREE, to specify this limit;
and does a check to ensure that the user input variable Degree is not greater than MAXDEGREE
(if it is, an error message is output and rpoly_ak1 terminates).
If a user wishes to compute roots of polynomials of degree greater than MAXDEGREE,
using a macro name like MAXDEGREE provides the simplest way of providing the capability to change.
4) All "GO TO" statements have been eliminated.
Note that the program does not incorporate several features available in C++, for example, dynamic arrays and vectors.
These features are not included in order to keep the C++ version as similar to the FORTRAN version as possible, and also to minimize the changes a user might have to make when using the code.
A small main program is included also, to provide an example of how to use rpoly_ak1. In this example, data is input from a file to eliminate the need for a user to type data in via the console.
The page has been styled so that the source code can be copied by clicking and dragging on the code itself; however, selecting everything (i.e. - Control-A) will select the line numbers along the left side too.
RPOLY C++ Translation - Rpoly_ak1
Return to Math Functions Page