On 11/13/2011 8:23 PM, Gib Bogle wrote:
I haven't seen such a program, but that might be because I haven't
been looking for one.
If you decide to write such a program yourself, some suggestions
for these lines:
1. Replace the ":=" with "=".
2. Add a semicolon at the end of the last line.
3. For each of the groups after the "=" with no spaces included,
add parentheses around that group. For example, "4*bx^2*cy^2*dz^2"
becomes "(4*bx^2*cy^2*dz^2)".
4. For each of the powers, create a new variable for that power of
that variable. For example,
x2 = x * x;
y2 = y * y;
z2 = z * z;
Or, if you prefer, the equivalent using pow().
Depending on your C compiler's level of optimization, this may
speed up the code by avoiding calculating those powers over and
over.
5. Wherever two variables are adjacent, insert a "*" between
them. For example, "bx^2" becomes " b*x^2".
6. Using some text editing program, replace such powers with the
corresponding new variable; or just have your program do that.
For example, replace "x^2" with "x2", "y^2" with "y2", and "z^2"
with "z2".
7. Note that I haven't mentioned writing the first few lines,
including declarations of all the variables, or the last few.
Those should be short enough to do them by hand.
If that's not adequate, show us more about what fails.
Is there any particular reason for not converting it into
Fortran instead?
Robert Miles