简体   繁体   中英

C++ Objective AlgLib

I have an c++ code. that i have to use in objective c.

double[,] x = new double[,]{{-1},{-0.8},{-0.6},{-0.4},{-0.2},{0},{0.2},{0.4},{0.6},{0.8},{1.0}};
double[] y = new double[]{0.223130,0.382893,0.582748,0.786628,0.941765,1.000000,0.941765,0.786628,0.582748,0.382893,0.223130};
double[] c = new double[]{0.3};

double epsf = 0;
double epsx = 0.000001;

int maxits = 0;
int info;

alglib::lsfitstate state;
alglib::lsfitreport rep;

double diffstep = 0.0001;    

//
// Fitting with weights
// (you can change weights and see how it changes result)
//

double[] w = new double[]{1,1,1,1,1,1,1,1,1,1,1};

alglib::lsfitcreatewf(x, y, w, c, diffstep, out state);
alglib::lsfitsetcond(state, epsf, epsx, maxits);
alglib::lsfitfit(state, function_cx_1_func, null, null);
alglib::lsfitresults(state, out info, out c, out rep);

i already called my objective file at the end with .mm

But i get difference Errors. (first lines - expected expression when i init my vars).

I can't . But i only need this one function.

I hope that this is a solution for this question. https://gis.stackexchange.com/questions/74567/math-algorithm-for-n-amount-points-in-objective-c

That is mostly Java code at the beginning for the array declarations, not C, C++ or ObjC.

This would be C/C++ code:

double x[][1] = {{-1},{-0.8},{-0.6},{-0.4},{-0.2},{0},{0.2},{0.4},{0.6},{0.8},{1.0}};
double y[] = {0.223130,0.382893,0.582748,0.786628,0.941765,1.000000,0.941765,0.786628,0.582748,0.382893,0.223130};
double c[] = {0.3};

However, according to the lsfitcreatewf function reference here , you need it to be of the type alglib::real_2d_array . There are some examples here how to generate such data.

Here and following are some general examples about how to use the lsfit subpackage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM