It is an optimization example of newton-raphson method. I get the error message when compiling :
a function-definition is not allowed here before '{' token
It points to the first line of the first function.
Any help? thank you in advance
#include <iostream>
#include <cmath>
#include <fstream>
#include <vector>
#include <numeric>
#include <iterator>
#include <map>
#include <string>
//C++ clang
using namespace std;
int main()
{
//Optimization Example
void getF( double* X, double *F)
{
F[0]=X[0]*X[0]+X[1]*X[1]-4;
F[1]=-X[0]*X[0]/3+X[1];
return;
}
void Jacobian(double* X, double** H)
{
H[0][0]=2*X[0];
H[0][1]=2*X[1];
H[1][0]=-2/3*X[0];
H[1][1]=1;
return;
}
unsigned int maxSteps=1000;
double epsilon=0.00001;
double* X=new double[2];
double* F=new double[2];
double** H= new double*[2];
for (unsigned int i=0 ; i<2 ; i++)
{
H[i]=new double[2];
}
cout << "Solution : " << endl;
cout << "x = " << X[0] << endl;
cout << "y = " << X[1] << endl;
delete[] X;
delete[] F;
for (unsigned int i=0 ; i<2 ; i++)
{
delete[] H[i];
}
delete[] H;
}