driebel
02-24-2009, 07:10 AM
I am attempting to find the roots to three equation in three unknowns, using the globally convergent Newton method. My problem is simply with the syntax. roots_multidim.h is looking for a &vecfunc object, and I have no idea how to create one. The only line from the text that seems relevant is "Its declaration as a function is
VecDoub vecfunc(VecDoub_I x); "
I have tried _many_ variations on the above line, and pre-main declaration, I won't reproduce them all here. Most produce ~50 lines of error messages and won't compile. My latest attempt, which does not work, is:
VecDoub vecfunc(VecDoub_I x) {
vecfunc[0] = x[0] * x[1] * x[2] - 6;
vecfunc[1] = x[0] * x[0] * x[1] + x[1] * x[1] * x[2]+x[2] * x[2] * x[0]-23;
vecfunc[2] = exp(x[0]+x[1]+x[2])-403;
}
using namespace std;
int main() {
const int N=3;
bool check;
int i;
VecDoub x(N);
VecDoub vecfunc(VecDoub x);
x[0] = 0;
x[1] = 5;
x[2] = 7;
newt(x,check,vecfunc);
As you can tell, I have minimal experience with C++. Any help on the basic syntax of how to create the necessary vector of functions would be much appreciated. Thanks,
Dave
VecDoub vecfunc(VecDoub_I x); "
I have tried _many_ variations on the above line, and pre-main declaration, I won't reproduce them all here. Most produce ~50 lines of error messages and won't compile. My latest attempt, which does not work, is:
VecDoub vecfunc(VecDoub_I x) {
vecfunc[0] = x[0] * x[1] * x[2] - 6;
vecfunc[1] = x[0] * x[0] * x[1] + x[1] * x[1] * x[2]+x[2] * x[2] * x[0]-23;
vecfunc[2] = exp(x[0]+x[1]+x[2])-403;
}
using namespace std;
int main() {
const int N=3;
bool check;
int i;
VecDoub x(N);
VecDoub vecfunc(VecDoub x);
x[0] = 0;
x[1] = 5;
x[2] = 7;
newt(x,check,vecfunc);
As you can tell, I have minimal experience with C++. Any help on the basic syntax of how to create the necessary vector of functions would be much appreciated. Thanks,
Dave