interpolation.h

Go to the documentation of this file.
1 /*************************************************************************
2 ALGLIB 3.11.0 (source code generated 2017-05-11)
3 Copyright (c) Sergey Bochkanov (ALGLIB project).
4 
5 >>> SOURCE LICENSE >>>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation (www.fsf.org); either version 2 of the
9 License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 A copy of the GNU General Public License is available at
17 http://www.fsf.org/licensing/licenses
18 >>> END OF LICENSE >>>
19 *************************************************************************/
20 #ifndef _interpolation_pkg_h
21 #define _interpolation_pkg_h
22 #include "ap.h"
23 #include "alglibinternal.h"
24 #include "alglibmisc.h"
25 #include "linalg.h"
26 #include "solvers.h"
27 #include "specialfunctions.h"
28 #include "integration.h"
29 #include "optimization.h"
30 
32 //
33 // THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (DATATYPES)
34 //
36 namespace alglib_impl
37 {
38 typedef struct
39 {
40  ae_int_t n;
41  ae_int_t nx;
42  ae_int_t d;
43  double r;
44  ae_int_t nw;
45  kdtree tree;
46  ae_int_t modeltype;
47  ae_matrix q;
48  ae_vector xbuf;
49  ae_vector tbuf;
50  ae_vector rbuf;
51  ae_matrix xybuf;
52  ae_int_t debugsolverfailures;
53  double debugworstrcond;
54  double debugbestrcond;
55 } idwinterpolant;
56 typedef struct
57 {
58  ae_int_t n;
59  double sy;
60  ae_vector x;
61  ae_vector y;
62  ae_vector w;
64 typedef struct
65 {
66  ae_bool periodic;
67  ae_int_t n;
68  ae_int_t k;
69  ae_int_t continuity;
70  ae_vector x;
71  ae_vector c;
72 } spline1dinterpolant;
73 typedef struct
74 {
75  ae_int_t n;
76  ae_bool periodic;
81 typedef struct
82 {
84  ae_bool periodic;
90 typedef struct
91 {
92  ae_int_t k;
93  ae_int_t stype;
98  ae_vector x;
100  ae_vector z;
103 typedef struct
104 {
105  double taskrcond;
106  double rmserror;
107  double avgerror;
108  double avgrelerror;
109  double maxerror;
111 typedef struct
112 {
113  double taskrcond;
114  ae_int_t dbest;
115  double rmserror;
116  double avgerror;
117  double avgrelerror;
118  double maxerror;
120 typedef struct
121 {
122  double taskrcond;
123  double rmserror;
124  double avgerror;
125  double avgrelerror;
126  double maxerror;
128 typedef struct
129 {
130  double taskrcond;
131  ae_int_t iterationscount;
132  ae_int_t varidx;
133  double rmserror;
134  double avgerror;
135  double avgrelerror;
136  double maxerror;
137  double wrmserror;
138  ae_matrix covpar;
139  ae_vector errpar;
140  ae_vector errcurve;
141  ae_vector noise;
142  double r2;
144 typedef struct
145 {
146  ae_int_t optalgo;
147  ae_int_t m;
149  double epsx;
150  ae_int_t maxits;
151  double stpmax;
152  ae_bool xrep;
154  ae_vector bndl;
155  ae_vector bndu;
156  ae_matrix taskx;
157  ae_vector tasky;
158  ae_int_t npoints;
159  ae_vector taskw;
160  ae_int_t nweights;
161  ae_int_t wkind;
162  ae_int_t wits;
163  double diffstep;
164  double teststep;
165  ae_matrix cleic;
166  ae_int_t nec;
167  ae_int_t nic;
168  ae_bool xupdated;
169  ae_bool needf;
170  ae_bool needfg;
171  ae_bool needfgh;
172  ae_int_t pointindex;
175  double f;
178  ae_vector wcur;
179  ae_vector tmpct;
181  ae_vector tmpf;
182  ae_matrix tmpjac;
183  ae_matrix tmpjacw;
184  double tmpnoise;
185  matinvreport invrep;
186  ae_int_t repiterationscount;
187  ae_int_t repterminationtype;
188  ae_int_t repvaridx;
189  double reprmserror;
190  double repavgerror;
191  double repavgrelerror;
192  double repmaxerror;
193  double repwrmserror;
195  minlmstate optstate;
196  minlmreport optrep;
197  ae_int_t prevnpt;
198  ae_int_t prevalgo;
199  rcommstate rstate;
201 typedef struct
202 {
204  ae_vector curboxmin;
205  ae_vector curboxmax;
206  double curdist2;
207  ae_vector x123;
208  ae_vector y123;
210 typedef struct
211 {
218  ae_vector kdroots;
219  ae_vector kdnodes;
220  ae_vector kdsplits;
221  ae_vector kdboxmin;
222  ae_vector kdboxmax;
225  double lambdareg;
226  ae_int_t maxits;
227  double supportr;
228  ae_int_t basisfunction;
229  rbfv2calcbuffer calcbuf;
231 typedef struct
232 {
241 typedef struct
242 {
243  ae_int_t terminationtype;
244  double maxerror;
245  double rmserror;
247 typedef struct
248 {
249  ae_int_t nfev;
250  ae_int_t iterationscount;
252 typedef struct
253 {
255  ae_int_t stype;
258  ae_int_t d;
260  ae_vector y;
263 typedef struct
264 {
265  ae_vector calcbufxcx;
266  ae_matrix calcbufx;
267  ae_vector calcbuftags;
268  kdtreerequestbuffer requestbuffer;
270 typedef struct
271 {
276  kdtree tree;
279  double rmax;
280  ae_matrix v;
281  ae_vector calcbufxcx;
282  ae_matrix calcbufx;
283  ae_vector calcbuftags;
285 typedef struct
286 {
287  ae_vector tx;
289  ae_vector ty;
290  ae_vector flag0;
291  ae_vector flag1;
292  ae_vector flag2;
293  ae_vector flag12;
294  ae_vector expbuf0;
295  ae_vector expbuf1;
296  ae_vector expbuf2;
298  ae_matrix calcbufx;
299  ae_vector calcbuftags;
301 typedef struct
302 {
303  ae_int_t arows;
304  ae_int_t acols;
305  ae_int_t annz;
306  ae_int_t iterationscount;
307  ae_int_t nmv;
308  ae_int_t terminationtype;
310 typedef struct
311 {
312  ae_int_t modelversion;
316 typedef struct
317 {
318  ae_int_t nx;
320  ae_int_t modelversion;
321  rbfv1model model1;
322  rbfv2model model2;
323  double lambdav;
324  double radvalue;
325  double radzvalue;
326  ae_int_t nlayers;
327  ae_int_t aterm;
328  ae_int_t algorithmtype;
329  double epsort;
330  double epserr;
331  ae_int_t maxits;
332  ae_int_t nnmaxits;
333  ae_int_t n;
335  ae_matrix y;
336  ae_bool hasscale;
339 typedef struct
340 {
341  double rmserror;
342  double maxerror;
343  ae_int_t arows;
344  ae_int_t acols;
345  ae_int_t annz;
346  ae_int_t iterationscount;
347  ae_int_t nmv;
348  ae_int_t terminationtype;
350 
351 }
352 
354 //
355 // THIS SECTION CONTAINS C++ INTERFACE
356 //
358 namespace alglib
359 {
360 
361 /*************************************************************************
362 IDW interpolant.
363 *************************************************************************/
364 class _idwinterpolant_owner
365 {
366 public:
373 protected:
375 };
377 {
378 public:
382  virtual ~idwinterpolant();
383 
384 };
385 
386 /*************************************************************************
387 Barycentric interpolant.
388 *************************************************************************/
390 {
391 public:
398 protected:
400 };
402 {
403 public:
408 
409 };
410 
411 /*************************************************************************
412 1-dimensional spline interpolant
413 *************************************************************************/
415 {
416 public:
423 protected:
425 };
427 {
428 public:
433 
434 };
435 
436 /*************************************************************************
437 Parametric spline inteprolant: 2-dimensional curve.
438 
439 You should not try to access its members directly - use PSpline2XXXXXXXX()
440 functions instead.
441 *************************************************************************/
443 {
444 public:
448  virtual ~_pspline2interpolant_owner();
451 protected:
453 };
455 {
456 public:
461 
462 };
463 
464 
465 /*************************************************************************
466 Parametric spline inteprolant: 3-dimensional curve.
467 
468 You should not try to access its members directly - use PSpline3XXXXXXXX()
469 functions instead.
470 *************************************************************************/
472 {
473 public:
477  virtual ~_pspline3interpolant_owner();
480 protected:
482 };
484 {
485 public:
490 
491 };
492 
493 /*************************************************************************
494 3-dimensional spline inteprolant
495 *************************************************************************/
497 {
498 public:
505 protected:
507 };
509 {
510 public:
515 
516 };
517 
518 
519 
520 /*************************************************************************
521 Polynomial fitting report:
522  TaskRCond reciprocal of task's condition number
523  RMSError RMS error
524  AvgError average error
525  AvgRelError average relative error (for non-zero Y[I])
526  MaxError maximum error
527 *************************************************************************/
529 {
530 public:
534  virtual ~_polynomialfitreport_owner();
537 protected:
539 };
541 {
542 public:
547  double &taskrcond;
548  double &rmserror;
549  double &avgerror;
550  double &avgrelerror;
551  double &maxerror;
552 
553 };
554 
555 
556 /*************************************************************************
557 Barycentric fitting report:
558  RMSError RMS error
559  AvgError average error
560  AvgRelError average relative error (for non-zero Y[I])
561  MaxError maximum error
562  TaskRCond reciprocal of task's condition number
563 *************************************************************************/
565 {
566 public:
573 protected:
575 };
577 {
578 public:
583  double &taskrcond;
585  double &rmserror;
586  double &avgerror;
587  double &avgrelerror;
588  double &maxerror;
589 
590 };
591 
592 
593 /*************************************************************************
594 Spline fitting report:
595  RMSError RMS error
596  AvgError average error
597  AvgRelError average relative error (for non-zero Y[I])
598  MaxError maximum error
599 
600 Fields below are filled by obsolete functions (Spline1DFitCubic,
601 Spline1DFitHermite). Modern fitting functions do NOT fill these fields:
602  TaskRCond reciprocal of task's condition number
603 *************************************************************************/
605 {
606 public:
610  virtual ~_spline1dfitreport_owner();
613 protected:
615 };
617 {
618 public:
623  double &taskrcond;
624  double &rmserror;
625  double &avgerror;
626  double &avgrelerror;
627  double &maxerror;
628 
629 };
630 
631 
632 /*************************************************************************
633 Least squares fitting report. This structure contains informational fields
634 which are set by fitting functions provided by this unit.
635 
636 Different functions initialize different sets of fields, so you should
637 read documentation on specific function you used in order to know which
638 fields are initialized.
639 
640  TaskRCond reciprocal of task's condition number
641  IterationsCount number of internal iterations
642 
643  VarIdx if user-supplied gradient contains errors which were
644  detected by nonlinear fitter, this field is set to
645  index of the first component of gradient which is
646  suspected to be spoiled by bugs.
647 
648  RMSError RMS error
649  AvgError average error
650  AvgRelError average relative error (for non-zero Y[I])
651  MaxError maximum error
652 
653  WRMSError weighted RMS error
654 
655  CovPar covariance matrix for parameters, filled by some solvers
656  ErrPar vector of errors in parameters, filled by some solvers
657  ErrCurve vector of fit errors - variability of the best-fit
658  curve, filled by some solvers.
659  Noise vector of per-point noise estimates, filled by
660  some solvers.
661  R2 coefficient of determination (non-weighted, non-adjusted),
662  filled by some solvers.
663 *************************************************************************/
665 {
666 public:
670  virtual ~_lsfitreport_owner();
673 protected:
675 };
677 {
678 public:
682  virtual ~lsfitreport();
683  double &taskrcond;
686  double &rmserror;
687  double &avgerror;
688  double &avgrelerror;
689  double &maxerror;
690  double &wrmserror;
695  double &r2;
696 
697 };
698 
699 
700 /*************************************************************************
701 Nonlinear fitter.
702 
703 You should use ALGLIB functions to work with fitter.
704 Never try to access its fields directly!
705 *************************************************************************/
707 {
708 public:
712  virtual ~_lsfitstate_owner();
715 protected:
717 };
719 {
720 public:
722  lsfitstate(const lsfitstate &rhs);
724  virtual ~lsfitstate();
730  double &f;
734 
735 };
736 
737 
738 
739 
740 
741 /*************************************************************************
742 2-dimensional spline inteprolant
743 *************************************************************************/
745 {
746 public:
753 protected:
755 };
757 {
758 public:
763 
764 };
765 
766 
767 
768 /*************************************************************************
769 Buffer object which is used to perform nearest neighbor requests in the
770 multithreaded mode (multiple threads working with same KD-tree object).
771 
772 This object should be created with KDTreeCreateBuffer().
773 *************************************************************************/
775 {
776 public:
780  virtual ~_rbfcalcbuffer_owner();
783 protected:
785 };
787 {
788 public:
792  virtual ~rbfcalcbuffer();
793 
794 };
795 
796 
797 /*************************************************************************
798 RBF model.
799 
800 Never try to directly work with fields of this object - always use ALGLIB
801 functions to use this object.
802 *************************************************************************/
804 {
805 public:
806  _rbfmodel_owner();
807  _rbfmodel_owner(const _rbfmodel_owner &rhs);
809  virtual ~_rbfmodel_owner();
812 protected:
814 };
815 class rbfmodel : public _rbfmodel_owner
816 {
817 public:
819  rbfmodel(const rbfmodel &rhs);
821  virtual ~rbfmodel();
822 
823 };
824 
825 
826 /*************************************************************************
827 RBF solution report:
828 * TerminationType - termination type, positive values - success,
829  non-positive - failure.
830 
831 Fields which are set by modern RBF solvers (hierarchical):
832 * RMSError - root-mean-square error; NAN for old solvers (ML, QNN)
833 * MaxError - maximum error; NAN for old solvers (ML, QNN)
834 *************************************************************************/
836 {
837 public:
841  virtual ~_rbfreport_owner();
843  alglib_impl::rbfreport* c_ptr() const;
844 protected:
846 };
848 {
849 public:
851  rbfreport(const rbfreport &rhs);
853  virtual ~rbfreport();
854  double &rmserror;
855  double &maxerror;
862 
863 };
864 
865 /*************************************************************************
866 IDW interpolation
867 
868 INPUT PARAMETERS:
869  Z - IDW interpolant built with one of model building
870  subroutines.
871  X - array[0..NX-1], interpolation point
872 
873 Result:
874  IDW interpolant Z(X)
875 
876  -- ALGLIB --
877  Copyright 02.03.2010 by Bochkanov Sergey
878 *************************************************************************/
879 double idwcalc(const idwinterpolant &z, const real_1d_array &x);
880 
881 
882 /*************************************************************************
883 IDW interpolant using modified Shepard method for uniform point
884 distributions.
885 
886 INPUT PARAMETERS:
887  XY - X and Y values, array[0..N-1,0..NX].
888  First NX columns contain X-values, last column contain
889  Y-values.
890  N - number of nodes, N>0.
891  NX - space dimension, NX>=1.
892  D - nodal function type, either:
893  * 0 constant model. Just for demonstration only, worst
894  model ever.
895  * 1 linear model, least squares fitting. Simpe model for
896  datasets too small for quadratic models
897  * 2 quadratic model, least squares fitting. Best model
898  available (if your dataset is large enough).
899  * -1 "fast" linear model, use with caution!!! It is
900  significantly faster than linear/quadratic and better
901  than constant model. But it is less robust (especially
902  in the presence of noise).
903  NQ - number of points used to calculate nodal functions (ignored
904  for constant models). NQ should be LARGER than:
905  * max(1.5*(1+NX),2^NX+1) for linear model,
906  * max(3/4*(NX+2)*(NX+1),2^NX+1) for quadratic model.
907  Values less than this threshold will be silently increased.
908  NW - number of points used to calculate weights and to interpolate.
909  Required: >=2^NX+1, values less than this threshold will be
910  silently increased.
911  Recommended value: about 2*NQ
912 
913 OUTPUT PARAMETERS:
914  Z - IDW interpolant.
915 
916 NOTES:
917  * best results are obtained with quadratic models, worst - with constant
918  models
919  * when N is large, NQ and NW must be significantly smaller than N both
920  to obtain optimal performance and to obtain optimal accuracy. In 2 or
921  3-dimensional tasks NQ=15 and NW=25 are good values to start with.
922  * NQ and NW may be greater than N. In such cases they will be
923  automatically decreased.
924  * this subroutine is always succeeds (as long as correct parameters are
925  passed).
926  * see 'Multivariate Interpolation of Large Sets of Scattered Data' by
927  Robert J. Renka for more information on this algorithm.
928  * this subroutine assumes that point distribution is uniform at the small
929  scales. If it isn't - for example, points are concentrated along
930  "lines", but "lines" distribution is uniform at the larger scale - then
931  you should use IDWBuildModifiedShepardR()
932 
933 
934  -- ALGLIB PROJECT --
935  Copyright 02.03.2010 by Bochkanov Sergey
936 *************************************************************************/
937 void idwbuildmodifiedshepard(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const ae_int_t d, const ae_int_t nq, const ae_int_t nw, idwinterpolant &z);
938 
939 
940 /*************************************************************************
941 IDW interpolant using modified Shepard method for non-uniform datasets.
942 
943 This type of model uses constant nodal functions and interpolates using
944 all nodes which are closer than user-specified radius R. It may be used
945 when points distribution is non-uniform at the small scale, but it is at
946 the distances as large as R.
947 
948 INPUT PARAMETERS:
949  XY - X and Y values, array[0..N-1,0..NX].
950  First NX columns contain X-values, last column contain
951  Y-values.
952  N - number of nodes, N>0.
953  NX - space dimension, NX>=1.
954  R - radius, R>0
955 
956 OUTPUT PARAMETERS:
957  Z - IDW interpolant.
958 
959 NOTES:
960 * if there is less than IDWKMin points within R-ball, algorithm selects
961  IDWKMin closest ones, so that continuity properties of interpolant are
962  preserved even far from points.
963 
964  -- ALGLIB PROJECT --
965  Copyright 11.04.2010 by Bochkanov Sergey
966 *************************************************************************/
967 void idwbuildmodifiedshepardr(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const double r, idwinterpolant &z);
968 
969 
970 /*************************************************************************
971 IDW model for noisy data.
972 
973 This subroutine may be used to handle noisy data, i.e. data with noise in
974 OUTPUT values. It differs from IDWBuildModifiedShepard() in the following
975 aspects:
976 * nodal functions are not constrained to pass through nodes: Qi(xi)<>yi,
977  i.e. we have fitting instead of interpolation.
978 * weights which are used during least squares fitting stage are all equal
979  to 1.0 (independently of distance)
980 * "fast"-linear or constant nodal functions are not supported (either not
981  robust enough or too rigid)
982 
983 This problem require far more complex tuning than interpolation problems.
984 Below you can find some recommendations regarding this problem:
985 * focus on tuning NQ; it controls noise reduction. As for NW, you can just
986  make it equal to 2*NQ.
987 * you can use cross-validation to determine optimal NQ.
988 * optimal NQ is a result of complex tradeoff between noise level (more
989  noise = larger NQ required) and underlying function complexity (given
990  fixed N, larger NQ means smoothing of compex features in the data). For
991  example, NQ=N will reduce noise to the minimum level possible, but you
992  will end up with just constant/linear/quadratic (depending on D) least
993  squares model for the whole dataset.
994 
995 INPUT PARAMETERS:
996  XY - X and Y values, array[0..N-1,0..NX].
997  First NX columns contain X-values, last column contain
998  Y-values.
999  N - number of nodes, N>0.
1000  NX - space dimension, NX>=1.
1001  D - nodal function degree, either:
1002  * 1 linear model, least squares fitting. Simpe model for
1003  datasets too small for quadratic models (or for very
1004  noisy problems).
1005  * 2 quadratic model, least squares fitting. Best model
1006  available (if your dataset is large enough).
1007  NQ - number of points used to calculate nodal functions. NQ should
1008  be significantly larger than 1.5 times the number of
1009  coefficients in a nodal function to overcome effects of noise:
1010  * larger than 1.5*(1+NX) for linear model,
1011  * larger than 3/4*(NX+2)*(NX+1) for quadratic model.
1012  Values less than this threshold will be silently increased.
1013  NW - number of points used to calculate weights and to interpolate.
1014  Required: >=2^NX+1, values less than this threshold will be
1015  silently increased.
1016  Recommended value: about 2*NQ or larger
1017 
1018 OUTPUT PARAMETERS:
1019  Z - IDW interpolant.
1020 
1021 NOTES:
1022  * best results are obtained with quadratic models, linear models are not
1023  recommended to use unless you are pretty sure that it is what you want
1024  * this subroutine is always succeeds (as long as correct parameters are
1025  passed).
1026  * see 'Multivariate Interpolation of Large Sets of Scattered Data' by
1027  Robert J. Renka for more information on this algorithm.
1028 
1029 
1030  -- ALGLIB PROJECT --
1031  Copyright 02.03.2010 by Bochkanov Sergey
1032 *************************************************************************/
1033 void idwbuildnoisy(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const ae_int_t d, const ae_int_t nq, const ae_int_t nw, idwinterpolant &z);
1034 
1035 /*************************************************************************
1036 Rational interpolation using barycentric formula
1037 
1038 F(t) = SUM(i=0,n-1,w[i]*f[i]/(t-x[i])) / SUM(i=0,n-1,w[i]/(t-x[i]))
1039 
1040 Input parameters:
1041  B - barycentric interpolant built with one of model building
1042  subroutines.
1043  T - interpolation point
1044 
1045 Result:
1046  barycentric interpolant F(t)
1047 
1048  -- ALGLIB --
1049  Copyright 17.08.2009 by Bochkanov Sergey
1050 *************************************************************************/
1051 double barycentriccalc(const barycentricinterpolant &b, const double t);
1052 
1053 
1054 /*************************************************************************
1055 Differentiation of barycentric interpolant: first derivative.
1056 
1057 Algorithm used in this subroutine is very robust and should not fail until
1058 provided with values too close to MaxRealNumber (usually MaxRealNumber/N
1059 or greater will overflow).
1060 
1061 INPUT PARAMETERS:
1062  B - barycentric interpolant built with one of model building
1063  subroutines.
1064  T - interpolation point
1065 
1066 OUTPUT PARAMETERS:
1067  F - barycentric interpolant at T
1068  DF - first derivative
1069 
1070 NOTE
1071 
1072 
1073  -- ALGLIB --
1074  Copyright 17.08.2009 by Bochkanov Sergey
1075 *************************************************************************/
1076 void barycentricdiff1(const barycentricinterpolant &b, const double t, double &f, double &df);
1077 
1078 
1079 /*************************************************************************
1080 Differentiation of barycentric interpolant: first/second derivatives.
1081 
1082 INPUT PARAMETERS:
1083  B - barycentric interpolant built with one of model building
1084  subroutines.
1085  T - interpolation point
1086 
1087 OUTPUT PARAMETERS:
1088  F - barycentric interpolant at T
1089  DF - first derivative
1090  D2F - second derivative
1091 
1092 NOTE: this algorithm may fail due to overflow/underflor if used on data
1093 whose values are close to MaxRealNumber or MinRealNumber. Use more robust
1094 BarycentricDiff1() subroutine in such cases.
1095 
1096 
1097  -- ALGLIB --
1098  Copyright 17.08.2009 by Bochkanov Sergey
1099 *************************************************************************/
1100 void barycentricdiff2(const barycentricinterpolant &b, const double t, double &f, double &df, double &d2f);
1101 
1102 
1103 /*************************************************************************
1104 This subroutine performs linear transformation of the argument.
1105 
1106 INPUT PARAMETERS:
1107  B - rational interpolant in barycentric form
1108  CA, CB - transformation coefficients: x = CA*t + CB
1109 
1110 OUTPUT PARAMETERS:
1111  B - transformed interpolant with X replaced by T
1112 
1113  -- ALGLIB PROJECT --
1114  Copyright 19.08.2009 by Bochkanov Sergey
1115 *************************************************************************/
1116 void barycentriclintransx(const barycentricinterpolant &b, const double ca, const double cb);
1117 
1118 
1119 /*************************************************************************
1120 This subroutine performs linear transformation of the barycentric
1121 interpolant.
1122 
1123 INPUT PARAMETERS:
1124  B - rational interpolant in barycentric form
1125  CA, CB - transformation coefficients: B2(x) = CA*B(x) + CB
1126 
1127 OUTPUT PARAMETERS:
1128  B - transformed interpolant
1129 
1130  -- ALGLIB PROJECT --
1131  Copyright 19.08.2009 by Bochkanov Sergey
1132 *************************************************************************/
1133 void barycentriclintransy(const barycentricinterpolant &b, const double ca, const double cb);
1134 
1135 
1136 /*************************************************************************
1137 Extracts X/Y/W arrays from rational interpolant
1138 
1139 INPUT PARAMETERS:
1140  B - barycentric interpolant
1141 
1142 OUTPUT PARAMETERS:
1143  N - nodes count, N>0
1144  X - interpolation nodes, array[0..N-1]
1145  F - function values, array[0..N-1]
1146  W - barycentric weights, array[0..N-1]
1147 
1148  -- ALGLIB --
1149  Copyright 17.08.2009 by Bochkanov Sergey
1150 *************************************************************************/
1152 
1153 
1154 /*************************************************************************
1155 Rational interpolant from X/Y/W arrays
1156 
1157 F(t) = SUM(i=0,n-1,w[i]*f[i]/(t-x[i])) / SUM(i=0,n-1,w[i]/(t-x[i]))
1158 
1159 INPUT PARAMETERS:
1160  X - interpolation nodes, array[0..N-1]
1161  F - function values, array[0..N-1]
1162  W - barycentric weights, array[0..N-1]
1163  N - nodes count, N>0
1164 
1165 OUTPUT PARAMETERS:
1166  B - barycentric interpolant built from (X, Y, W)
1167 
1168  -- ALGLIB --
1169  Copyright 17.08.2009 by Bochkanov Sergey
1170 *************************************************************************/
1172 
1173 
1174 /*************************************************************************
1175 Rational interpolant without poles
1176 
1177 The subroutine constructs the rational interpolating function without real
1178 poles (see 'Barycentric rational interpolation with no poles and high
1179 rates of approximation', Michael S. Floater. and Kai Hormann, for more
1180 information on this subject).
1181 
1182 Input parameters:
1183  X - interpolation nodes, array[0..N-1].
1184  Y - function values, array[0..N-1].
1185  N - number of nodes, N>0.
1186  D - order of the interpolation scheme, 0 <= D <= N-1.
1187  D<0 will cause an error.
1188  D>=N it will be replaced with D=N-1.
1189  if you don't know what D to choose, use small value about 3-5.
1190 
1191 Output parameters:
1192  B - barycentric interpolant.
1193 
1194 Note:
1195  this algorithm always succeeds and calculates the weights with close
1196  to machine precision.
1197 
1198  -- ALGLIB PROJECT --
1199  Copyright 17.06.2007 by Bochkanov Sergey
1200 *************************************************************************/
1202 
1203 /*************************************************************************
1204 This subroutine builds linear spline interpolant
1205 
1206 INPUT PARAMETERS:
1207  X - spline nodes, array[0..N-1]
1208  Y - function values, array[0..N-1]
1209  N - points count (optional):
1210  * N>=2
1211  * if given, only first N points are used to build spline
1212  * if not given, automatically detected from X/Y sizes
1213  (len(X) must be equal to len(Y))
1214 
1215 OUTPUT PARAMETERS:
1216  C - spline interpolant
1217 
1218 
1219 ORDER OF POINTS
1220 
1221 Subroutine automatically sorts points, so caller may pass unsorted array.
1222 
1223  -- ALGLIB PROJECT --
1224  Copyright 24.06.2007 by Bochkanov Sergey
1225 *************************************************************************/
1228 
1229 
1230 /*************************************************************************
1231 This subroutine builds cubic spline interpolant.
1232 
1233 INPUT PARAMETERS:
1234  X - spline nodes, array[0..N-1].
1235  Y - function values, array[0..N-1].
1236 
1237 OPTIONAL PARAMETERS:
1238  N - points count:
1239  * N>=2
1240  * if given, only first N points are used to build spline
1241  * if not given, automatically detected from X/Y sizes
1242  (len(X) must be equal to len(Y))
1243  BoundLType - boundary condition type for the left boundary
1244  BoundL - left boundary condition (first or second derivative,
1245  depending on the BoundLType)
1246  BoundRType - boundary condition type for the right boundary
1247  BoundR - right boundary condition (first or second derivative,
1248  depending on the BoundRType)
1249 
1250 OUTPUT PARAMETERS:
1251  C - spline interpolant
1252 
1253 ORDER OF POINTS
1254 
1255 Subroutine automatically sorts points, so caller may pass unsorted array.
1256 
1257 SETTING BOUNDARY VALUES:
1258 
1259 The BoundLType/BoundRType parameters can have the following values:
1260  * -1, which corresonds to the periodic (cyclic) boundary conditions.
1261  In this case:
1262  * both BoundLType and BoundRType must be equal to -1.
1263  * BoundL/BoundR are ignored
1264  * Y[last] is ignored (it is assumed to be equal to Y[first]).
1265  * 0, which corresponds to the parabolically terminated spline
1266  (BoundL and/or BoundR are ignored).
1267  * 1, which corresponds to the first derivative boundary condition
1268  * 2, which corresponds to the second derivative boundary condition
1269  * by default, BoundType=0 is used
1270 
1271 PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
1272 
1273 Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
1274 However, this subroutine doesn't require you to specify equal values for
1275 the first and last points - it automatically forces them to be equal by
1276 copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
1277 Y[last_point]. However it is recommended to pass consistent values of Y[],
1278 i.e. to make Y[first_point]=Y[last_point].
1279 
1280  -- ALGLIB PROJECT --
1281  Copyright 23.06.2007 by Bochkanov Sergey
1282 *************************************************************************/
1283 void spline1dbuildcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, spline1dinterpolant &c);
1285 
1286 
1287 /*************************************************************************
1288 This function solves following problem: given table y[] of function values
1289 at nodes x[], it calculates and returns table of function derivatives d[]
1290 (calculated at the same nodes x[]).
1291 
1292 This function yields same result as Spline1DBuildCubic() call followed by
1293 sequence of Spline1DDiff() calls, but it can be several times faster when
1294 called for ordered X[] and X2[].
1295 
1296 INPUT PARAMETERS:
1297  X - spline nodes
1298  Y - function values
1299 
1300 OPTIONAL PARAMETERS:
1301  N - points count:
1302  * N>=2
1303  * if given, only first N points are used
1304  * if not given, automatically detected from X/Y sizes
1305  (len(X) must be equal to len(Y))
1306  BoundLType - boundary condition type for the left boundary
1307  BoundL - left boundary condition (first or second derivative,
1308  depending on the BoundLType)
1309  BoundRType - boundary condition type for the right boundary
1310  BoundR - right boundary condition (first or second derivative,
1311  depending on the BoundRType)
1312 
1313 OUTPUT PARAMETERS:
1314  D - derivative values at X[]
1315 
1316 ORDER OF POINTS
1317 
1318 Subroutine automatically sorts points, so caller may pass unsorted array.
1319 Derivative values are correctly reordered on return, so D[I] is always
1320 equal to S'(X[I]) independently of points order.
1321 
1322 SETTING BOUNDARY VALUES:
1323 
1324 The BoundLType/BoundRType parameters can have the following values:
1325  * -1, which corresonds to the periodic (cyclic) boundary conditions.
1326  In this case:
1327  * both BoundLType and BoundRType must be equal to -1.
1328  * BoundL/BoundR are ignored
1329  * Y[last] is ignored (it is assumed to be equal to Y[first]).
1330  * 0, which corresponds to the parabolically terminated spline
1331  (BoundL and/or BoundR are ignored).
1332  * 1, which corresponds to the first derivative boundary condition
1333  * 2, which corresponds to the second derivative boundary condition
1334  * by default, BoundType=0 is used
1335 
1336 PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
1337 
1338 Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
1339 However, this subroutine doesn't require you to specify equal values for
1340 the first and last points - it automatically forces them to be equal by
1341 copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
1342 Y[last_point]. However it is recommended to pass consistent values of Y[],
1343 i.e. to make Y[first_point]=Y[last_point].
1344 
1345  -- ALGLIB PROJECT --
1346  Copyright 03.09.2010 by Bochkanov Sergey
1347 *************************************************************************/
1348 void spline1dgriddiffcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, real_1d_array &d);
1350 
1351 
1352 /*************************************************************************
1353 This function solves following problem: given table y[] of function values
1354 at nodes x[], it calculates and returns tables of first and second
1355 function derivatives d1[] and d2[] (calculated at the same nodes x[]).
1356 
1357 This function yields same result as Spline1DBuildCubic() call followed by
1358 sequence of Spline1DDiff() calls, but it can be several times faster when
1359 called for ordered X[] and X2[].
1360 
1361 INPUT PARAMETERS:
1362  X - spline nodes
1363  Y - function values
1364 
1365 OPTIONAL PARAMETERS:
1366  N - points count:
1367  * N>=2
1368  * if given, only first N points are used
1369  * if not given, automatically detected from X/Y sizes
1370  (len(X) must be equal to len(Y))
1371  BoundLType - boundary condition type for the left boundary
1372  BoundL - left boundary condition (first or second derivative,
1373  depending on the BoundLType)
1374  BoundRType - boundary condition type for the right boundary
1375  BoundR - right boundary condition (first or second derivative,
1376  depending on the BoundRType)
1377 
1378 OUTPUT PARAMETERS:
1379  D1 - S' values at X[]
1380  D2 - S'' values at X[]
1381 
1382 ORDER OF POINTS
1383 
1384 Subroutine automatically sorts points, so caller may pass unsorted array.
1385 Derivative values are correctly reordered on return, so D[I] is always
1386 equal to S'(X[I]) independently of points order.
1387 
1388 SETTING BOUNDARY VALUES:
1389 
1390 The BoundLType/BoundRType parameters can have the following values:
1391  * -1, which corresonds to the periodic (cyclic) boundary conditions.
1392  In this case:
1393  * both BoundLType and BoundRType must be equal to -1.
1394  * BoundL/BoundR are ignored
1395  * Y[last] is ignored (it is assumed to be equal to Y[first]).
1396  * 0, which corresponds to the parabolically terminated spline
1397  (BoundL and/or BoundR are ignored).
1398  * 1, which corresponds to the first derivative boundary condition
1399  * 2, which corresponds to the second derivative boundary condition
1400  * by default, BoundType=0 is used
1401 
1402 PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
1403 
1404 Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
1405 However, this subroutine doesn't require you to specify equal values for
1406 the first and last points - it automatically forces them to be equal by
1407 copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
1408 Y[last_point]. However it is recommended to pass consistent values of Y[],
1409 i.e. to make Y[first_point]=Y[last_point].
1410 
1411  -- ALGLIB PROJECT --
1412  Copyright 03.09.2010 by Bochkanov Sergey
1413 *************************************************************************/
1414 void spline1dgriddiff2cubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, real_1d_array &d1, real_1d_array &d2);
1416 
1417 
1418 /*************************************************************************
1419 This function solves following problem: given table y[] of function values
1420 at old nodes x[] and new nodes x2[], it calculates and returns table of
1421 function values y2[] (calculated at x2[]).
1422 
1423 This function yields same result as Spline1DBuildCubic() call followed by
1424 sequence of Spline1DDiff() calls, but it can be several times faster when
1425 called for ordered X[] and X2[].
1426 
1427 INPUT PARAMETERS:
1428  X - old spline nodes
1429  Y - function values
1430  X2 - new spline nodes
1431 
1432 OPTIONAL PARAMETERS:
1433  N - points count:
1434  * N>=2
1435  * if given, only first N points from X/Y are used
1436  * if not given, automatically detected from X/Y sizes
1437  (len(X) must be equal to len(Y))
1438  BoundLType - boundary condition type for the left boundary
1439  BoundL - left boundary condition (first or second derivative,
1440  depending on the BoundLType)
1441  BoundRType - boundary condition type for the right boundary
1442  BoundR - right boundary condition (first or second derivative,
1443  depending on the BoundRType)
1444  N2 - new points count:
1445  * N2>=2
1446  * if given, only first N2 points from X2 are used
1447  * if not given, automatically detected from X2 size
1448 
1449 OUTPUT PARAMETERS:
1450  F2 - function values at X2[]
1451 
1452 ORDER OF POINTS
1453 
1454 Subroutine automatically sorts points, so caller may pass unsorted array.
1455 Function values are correctly reordered on return, so F2[I] is always
1456 equal to S(X2[I]) independently of points order.
1457 
1458 SETTING BOUNDARY VALUES:
1459 
1460 The BoundLType/BoundRType parameters can have the following values:
1461  * -1, which corresonds to the periodic (cyclic) boundary conditions.
1462  In this case:
1463  * both BoundLType and BoundRType must be equal to -1.
1464  * BoundL/BoundR are ignored
1465  * Y[last] is ignored (it is assumed to be equal to Y[first]).
1466  * 0, which corresponds to the parabolically terminated spline
1467  (BoundL and/or BoundR are ignored).
1468  * 1, which corresponds to the first derivative boundary condition
1469  * 2, which corresponds to the second derivative boundary condition
1470  * by default, BoundType=0 is used
1471 
1472 PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
1473 
1474 Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
1475 However, this subroutine doesn't require you to specify equal values for
1476 the first and last points - it automatically forces them to be equal by
1477 copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
1478 Y[last_point]. However it is recommended to pass consistent values of Y[],
1479 i.e. to make Y[first_point]=Y[last_point].
1480 
1481  -- ALGLIB PROJECT --
1482  Copyright 03.09.2010 by Bochkanov Sergey
1483 *************************************************************************/
1484 void spline1dconvcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2);
1486 
1487 
1488 /*************************************************************************
1489 This function solves following problem: given table y[] of function values
1490 at old nodes x[] and new nodes x2[], it calculates and returns table of
1491 function values y2[] and derivatives d2[] (calculated at x2[]).
1492 
1493 This function yields same result as Spline1DBuildCubic() call followed by
1494 sequence of Spline1DDiff() calls, but it can be several times faster when
1495 called for ordered X[] and X2[].
1496 
1497 INPUT PARAMETERS:
1498  X - old spline nodes
1499  Y - function values
1500  X2 - new spline nodes
1501 
1502 OPTIONAL PARAMETERS:
1503  N - points count:
1504  * N>=2
1505  * if given, only first N points from X/Y are used
1506  * if not given, automatically detected from X/Y sizes
1507  (len(X) must be equal to len(Y))
1508  BoundLType - boundary condition type for the left boundary
1509  BoundL - left boundary condition (first or second derivative,
1510  depending on the BoundLType)
1511  BoundRType - boundary condition type for the right boundary
1512  BoundR - right boundary condition (first or second derivative,
1513  depending on the BoundRType)
1514  N2 - new points count:
1515  * N2>=2
1516  * if given, only first N2 points from X2 are used
1517  * if not given, automatically detected from X2 size
1518 
1519 OUTPUT PARAMETERS:
1520  F2 - function values at X2[]
1521  D2 - first derivatives at X2[]
1522 
1523 ORDER OF POINTS
1524 
1525 Subroutine automatically sorts points, so caller may pass unsorted array.
1526 Function values are correctly reordered on return, so F2[I] is always
1527 equal to S(X2[I]) independently of points order.
1528 
1529 SETTING BOUNDARY VALUES:
1530 
1531 The BoundLType/BoundRType parameters can have the following values:
1532  * -1, which corresonds to the periodic (cyclic) boundary conditions.
1533  In this case:
1534  * both BoundLType and BoundRType must be equal to -1.
1535  * BoundL/BoundR are ignored
1536  * Y[last] is ignored (it is assumed to be equal to Y[first]).
1537  * 0, which corresponds to the parabolically terminated spline
1538  (BoundL and/or BoundR are ignored).
1539  * 1, which corresponds to the first derivative boundary condition
1540  * 2, which corresponds to the second derivative boundary condition
1541  * by default, BoundType=0 is used
1542 
1543 PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
1544 
1545 Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
1546 However, this subroutine doesn't require you to specify equal values for
1547 the first and last points - it automatically forces them to be equal by
1548 copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
1549 Y[last_point]. However it is recommended to pass consistent values of Y[],
1550 i.e. to make Y[first_point]=Y[last_point].
1551 
1552  -- ALGLIB PROJECT --
1553  Copyright 03.09.2010 by Bochkanov Sergey
1554 *************************************************************************/
1555 void spline1dconvdiffcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2, real_1d_array &d2);
1557 
1558 
1559 /*************************************************************************
1560 This function solves following problem: given table y[] of function values
1561 at old nodes x[] and new nodes x2[], it calculates and returns table of
1562 function values y2[], first and second derivatives d2[] and dd2[]
1563 (calculated at x2[]).
1564 
1565 This function yields same result as Spline1DBuildCubic() call followed by
1566 sequence of Spline1DDiff() calls, but it can be several times faster when
1567 called for ordered X[] and X2[].
1568 
1569 INPUT PARAMETERS:
1570  X - old spline nodes
1571  Y - function values
1572  X2 - new spline nodes
1573 
1574 OPTIONAL PARAMETERS:
1575  N - points count:
1576  * N>=2
1577  * if given, only first N points from X/Y are used
1578  * if not given, automatically detected from X/Y sizes
1579  (len(X) must be equal to len(Y))
1580  BoundLType - boundary condition type for the left boundary
1581  BoundL - left boundary condition (first or second derivative,
1582  depending on the BoundLType)
1583  BoundRType - boundary condition type for the right boundary
1584  BoundR - right boundary condition (first or second derivative,
1585  depending on the BoundRType)
1586  N2 - new points count:
1587  * N2>=2
1588  * if given, only first N2 points from X2 are used
1589  * if not given, automatically detected from X2 size
1590 
1591 OUTPUT PARAMETERS:
1592  F2 - function values at X2[]
1593  D2 - first derivatives at X2[]
1594  DD2 - second derivatives at X2[]
1595 
1596 ORDER OF POINTS
1597 
1598 Subroutine automatically sorts points, so caller may pass unsorted array.
1599 Function values are correctly reordered on return, so F2[I] is always
1600 equal to S(X2[I]) independently of points order.
1601 
1602 SETTING BOUNDARY VALUES:
1603 
1604 The BoundLType/BoundRType parameters can have the following values:
1605  * -1, which corresonds to the periodic (cyclic) boundary conditions.
1606  In this case:
1607  * both BoundLType and BoundRType must be equal to -1.
1608  * BoundL/BoundR are ignored
1609  * Y[last] is ignored (it is assumed to be equal to Y[first]).
1610  * 0, which corresponds to the parabolically terminated spline
1611  (BoundL and/or BoundR are ignored).
1612  * 1, which corresponds to the first derivative boundary condition
1613  * 2, which corresponds to the second derivative boundary condition
1614  * by default, BoundType=0 is used
1615 
1616 PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
1617 
1618 Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
1619 However, this subroutine doesn't require you to specify equal values for
1620 the first and last points - it automatically forces them to be equal by
1621 copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
1622 Y[last_point]. However it is recommended to pass consistent values of Y[],
1623 i.e. to make Y[first_point]=Y[last_point].
1624 
1625  -- ALGLIB PROJECT --
1626  Copyright 03.09.2010 by Bochkanov Sergey
1627 *************************************************************************/
1628 void spline1dconvdiff2cubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2, real_1d_array &d2, real_1d_array &dd2);
1630 
1631 
1632 /*************************************************************************
1633 This subroutine builds Catmull-Rom spline interpolant.
1634 
1635 INPUT PARAMETERS:
1636  X - spline nodes, array[0..N-1].
1637  Y - function values, array[0..N-1].
1638 
1639 OPTIONAL PARAMETERS:
1640  N - points count:
1641  * N>=2
1642  * if given, only first N points are used to build spline
1643  * if not given, automatically detected from X/Y sizes
1644  (len(X) must be equal to len(Y))
1645  BoundType - boundary condition type:
1646  * -1 for periodic boundary condition
1647  * 0 for parabolically terminated spline (default)
1648  Tension - tension parameter:
1649  * tension=0 corresponds to classic Catmull-Rom spline (default)
1650  * 0<tension<1 corresponds to more general form - cardinal spline
1651 
1652 OUTPUT PARAMETERS:
1653  C - spline interpolant
1654 
1655 
1656 ORDER OF POINTS
1657 
1658 Subroutine automatically sorts points, so caller may pass unsorted array.
1659 
1660 PROBLEMS WITH PERIODIC BOUNDARY CONDITIONS:
1661 
1662 Problems with periodic boundary conditions have Y[first_point]=Y[last_point].
1663 However, this subroutine doesn't require you to specify equal values for
1664 the first and last points - it automatically forces them to be equal by
1665 copying Y[first_point] (corresponds to the leftmost, minimal X[]) to
1666 Y[last_point]. However it is recommended to pass consistent values of Y[],
1667 i.e. to make Y[first_point]=Y[last_point].
1668 
1669  -- ALGLIB PROJECT --
1670  Copyright 23.06.2007 by Bochkanov Sergey
1671 *************************************************************************/
1672 void spline1dbuildcatmullrom(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundtype, const double tension, spline1dinterpolant &c);
1674 
1675 
1676 /*************************************************************************
1677 This subroutine builds Hermite spline interpolant.
1678 
1679 INPUT PARAMETERS:
1680  X - spline nodes, array[0..N-1]
1681  Y - function values, array[0..N-1]
1682  D - derivatives, array[0..N-1]
1683  N - points count (optional):
1684  * N>=2
1685  * if given, only first N points are used to build spline
1686  * if not given, automatically detected from X/Y sizes
1687  (len(X) must be equal to len(Y))
1688 
1689 OUTPUT PARAMETERS:
1690  C - spline interpolant.
1691 
1692 
1693 ORDER OF POINTS
1694 
1695 Subroutine automatically sorts points, so caller may pass unsorted array.
1696 
1697  -- ALGLIB PROJECT --
1698  Copyright 23.06.2007 by Bochkanov Sergey
1699 *************************************************************************/
1702 
1703 
1704 /*************************************************************************
1705 This subroutine builds Akima spline interpolant
1706 
1707 INPUT PARAMETERS:
1708  X - spline nodes, array[0..N-1]
1709  Y - function values, array[0..N-1]
1710  N - points count (optional):
1711  * N>=2
1712  * if given, only first N points are used to build spline
1713  * if not given, automatically detected from X/Y sizes
1714  (len(X) must be equal to len(Y))
1715 
1716 OUTPUT PARAMETERS:
1717  C - spline interpolant
1718 
1719 
1720 ORDER OF POINTS
1721 
1722 Subroutine automatically sorts points, so caller may pass unsorted array.
1723 
1724  -- ALGLIB PROJECT --
1725  Copyright 24.06.2007 by Bochkanov Sergey
1726 *************************************************************************/
1729 
1730 
1731 /*************************************************************************
1732 This subroutine calculates the value of the spline at the given point X.
1733 
1734 INPUT PARAMETERS:
1735  C - spline interpolant
1736  X - point
1737 
1738 Result:
1739  S(x)
1740 
1741  -- ALGLIB PROJECT --
1742  Copyright 23.06.2007 by Bochkanov Sergey
1743 *************************************************************************/
1744 double spline1dcalc(const spline1dinterpolant &c, const double x);
1745 
1746 
1747 /*************************************************************************
1748 This subroutine differentiates the spline.
1749 
1750 INPUT PARAMETERS:
1751  C - spline interpolant.
1752  X - point
1753 
1754 Result:
1755  S - S(x)
1756  DS - S'(x)
1757  D2S - S''(x)
1758 
1759  -- ALGLIB PROJECT --
1760  Copyright 24.06.2007 by Bochkanov Sergey
1761 *************************************************************************/
1762 void spline1ddiff(const spline1dinterpolant &c, const double x, double &s, double &ds, double &d2s);
1763 
1764 
1765 /*************************************************************************
1766 This subroutine unpacks the spline into the coefficients table.
1767 
1768 INPUT PARAMETERS:
1769  C - spline interpolant.
1770  X - point
1771 
1772 OUTPUT PARAMETERS:
1773  Tbl - coefficients table, unpacked format, array[0..N-2, 0..5].
1774  For I = 0...N-2:
1775  Tbl[I,0] = X[i]
1776  Tbl[I,1] = X[i+1]
1777  Tbl[I,2] = C0
1778  Tbl[I,3] = C1
1779  Tbl[I,4] = C2
1780  Tbl[I,5] = C3
1781  On [x[i], x[i+1]] spline is equals to:
1782  S(x) = C0 + C1*t + C2*t^2 + C3*t^3
1783  t = x-x[i]
1784 
1785 NOTE:
1786  You can rebuild spline with Spline1DBuildHermite() function, which
1787  accepts as inputs function values and derivatives at nodes, which are
1788  easy to calculate when you have coefficients.
1789 
1790  -- ALGLIB PROJECT --
1791  Copyright 29.06.2007 by Bochkanov Sergey
1792 *************************************************************************/
1794 
1795 
1796 /*************************************************************************
1797 This subroutine performs linear transformation of the spline argument.
1798 
1799 INPUT PARAMETERS:
1800  C - spline interpolant.
1801  A, B- transformation coefficients: x = A*t + B
1802 Result:
1803  C - transformed spline
1804 
1805  -- ALGLIB PROJECT --
1806  Copyright 30.06.2007 by Bochkanov Sergey
1807 *************************************************************************/
1808 void spline1dlintransx(const spline1dinterpolant &c, const double a, const double b);
1809 
1810 
1811 /*************************************************************************
1812 This subroutine performs linear transformation of the spline.
1813 
1814 INPUT PARAMETERS:
1815  C - spline interpolant.
1816  A, B- transformation coefficients: S2(x) = A*S(x) + B
1817 Result:
1818  C - transformed spline
1819 
1820  -- ALGLIB PROJECT --
1821  Copyright 30.06.2007 by Bochkanov Sergey
1822 *************************************************************************/
1823 void spline1dlintransy(const spline1dinterpolant &c, const double a, const double b);
1824 
1825 
1826 /*************************************************************************
1827 This subroutine integrates the spline.
1828 
1829 INPUT PARAMETERS:
1830  C - spline interpolant.
1831  X - right bound of the integration interval [a, x],
1832  here 'a' denotes min(x[])
1833 Result:
1834  integral(S(t)dt,a,x)
1835 
1836  -- ALGLIB PROJECT --
1837  Copyright 23.06.2007 by Bochkanov Sergey
1838 *************************************************************************/
1839 double spline1dintegrate(const spline1dinterpolant &c, const double x);
1840 
1841 
1842 /*************************************************************************
1843 This function builds monotone cubic Hermite interpolant. This interpolant
1844 is monotonic in [x(0),x(n-1)] and is constant outside of this interval.
1845 
1846 In case y[] form non-monotonic sequence, interpolant is piecewise
1847 monotonic. Say, for x=(0,1,2,3,4) and y=(0,1,2,1,0) interpolant will
1848 monotonically grow at [0..2] and monotonically decrease at [2..4].
1849 
1850 INPUT PARAMETERS:
1851  X - spline nodes, array[0..N-1]. Subroutine automatically
1852  sorts points, so caller may pass unsorted array.
1853  Y - function values, array[0..N-1]
1854  N - the number of points(N>=2).
1855 
1856 OUTPUT PARAMETERS:
1857  C - spline interpolant.
1858 
1859  -- ALGLIB PROJECT --
1860  Copyright 21.06.2012 by Bochkanov Sergey
1861 *************************************************************************/
1864 
1865 /*************************************************************************
1866 This function builds non-periodic 2-dimensional parametric spline which
1867 starts at (X[0],Y[0]) and ends at (X[N-1],Y[N-1]).
1868 
1869 INPUT PARAMETERS:
1870  XY - points, array[0..N-1,0..1].
1871  XY[I,0:1] corresponds to the Ith point.
1872  Order of points is important!
1873  N - points count, N>=5 for Akima splines, N>=2 for other types of
1874  splines.
1875  ST - spline type:
1876  * 0 Akima spline
1877  * 1 parabolically terminated Catmull-Rom spline (Tension=0)
1878  * 2 parabolically terminated cubic spline
1879  PT - parameterization type:
1880  * 0 uniform
1881  * 1 chord length
1882  * 2 centripetal
1883 
1884 OUTPUT PARAMETERS:
1885  P - parametric spline interpolant
1886 
1887 
1888 NOTES:
1889 * this function assumes that there all consequent points are distinct.
1890  I.e. (x0,y0)<>(x1,y1), (x1,y1)<>(x2,y2), (x2,y2)<>(x3,y3) and so on.
1891  However, non-consequent points may coincide, i.e. we can have (x0,y0)=
1892  =(x2,y2).
1893 
1894  -- ALGLIB PROJECT --
1895  Copyright 28.05.2010 by Bochkanov Sergey
1896 *************************************************************************/
1897 void pspline2build(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline2interpolant &p);
1898 
1899 
1900 /*************************************************************************
1901 This function builds non-periodic 3-dimensional parametric spline which
1902 starts at (X[0],Y[0],Z[0]) and ends at (X[N-1],Y[N-1],Z[N-1]).
1903 
1904 Same as PSpline2Build() function, but for 3D, so we won't duplicate its
1905 description here.
1906 
1907  -- ALGLIB PROJECT --
1908  Copyright 28.05.2010 by Bochkanov Sergey
1909 *************************************************************************/
1910 void pspline3build(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline3interpolant &p);
1911 
1912 
1913 /*************************************************************************
1914 This function builds periodic 2-dimensional parametric spline which
1915 starts at (X[0],Y[0]), goes through all points to (X[N-1],Y[N-1]) and then
1916 back to (X[0],Y[0]).
1917 
1918 INPUT PARAMETERS:
1919  XY - points, array[0..N-1,0..1].
1920  XY[I,0:1] corresponds to the Ith point.
1921  XY[N-1,0:1] must be different from XY[0,0:1].
1922  Order of points is important!
1923  N - points count, N>=3 for other types of splines.
1924  ST - spline type:
1925  * 1 Catmull-Rom spline (Tension=0) with cyclic boundary conditions
1926  * 2 cubic spline with cyclic boundary conditions
1927  PT - parameterization type:
1928  * 0 uniform
1929  * 1 chord length
1930  * 2 centripetal
1931 
1932 OUTPUT PARAMETERS:
1933  P - parametric spline interpolant
1934 
1935 
1936 NOTES:
1937 * this function assumes that there all consequent points are distinct.
1938  I.e. (x0,y0)<>(x1,y1), (x1,y1)<>(x2,y2), (x2,y2)<>(x3,y3) and so on.
1939  However, non-consequent points may coincide, i.e. we can have (x0,y0)=
1940  =(x2,y2).
1941 * last point of sequence is NOT equal to the first point. You shouldn't
1942  make curve "explicitly periodic" by making them equal.
1943 
1944  -- ALGLIB PROJECT --
1945  Copyright 28.05.2010 by Bochkanov Sergey
1946 *************************************************************************/
1947 void pspline2buildperiodic(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline2interpolant &p);
1948 
1949 
1950 /*************************************************************************
1951 This function builds periodic 3-dimensional parametric spline which
1952 starts at (X[0],Y[0],Z[0]), goes through all points to (X[N-1],Y[N-1],Z[N-1])
1953 and then back to (X[0],Y[0],Z[0]).
1954 
1955 Same as PSpline2Build() function, but for 3D, so we won't duplicate its
1956 description here.
1957 
1958  -- ALGLIB PROJECT --
1959  Copyright 28.05.2010 by Bochkanov Sergey
1960 *************************************************************************/
1961 void pspline3buildperiodic(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline3interpolant &p);
1962 
1963 
1964 /*************************************************************************
1965 This function returns vector of parameter values correspoding to points.
1966 
1967 I.e. for P created from (X[0],Y[0])...(X[N-1],Y[N-1]) and U=TValues(P) we
1968 have
1969  (X[0],Y[0]) = PSpline2Calc(P,U[0]),
1970  (X[1],Y[1]) = PSpline2Calc(P,U[1]),
1971  (X[2],Y[2]) = PSpline2Calc(P,U[2]),
1972  ...
1973 
1974 INPUT PARAMETERS:
1975  P - parametric spline interpolant
1976 
1977 OUTPUT PARAMETERS:
1978  N - array size
1979  T - array[0..N-1]
1980 
1981 
1982 NOTES:
1983 * for non-periodic splines U[0]=0, U[0]<U[1]<...<U[N-1], U[N-1]=1
1984 * for periodic splines U[0]=0, U[0]<U[1]<...<U[N-1], U[N-1]<1
1985 
1986  -- ALGLIB PROJECT --
1987  Copyright 28.05.2010 by Bochkanov Sergey
1988 *************************************************************************/
1990 
1991 
1992 /*************************************************************************
1993 This function returns vector of parameter values correspoding to points.
1994 
1995 Same as PSpline2ParameterValues(), but for 3D.
1996 
1997  -- ALGLIB PROJECT --
1998  Copyright 28.05.2010 by Bochkanov Sergey
1999 *************************************************************************/
2001 
2002 
2003 /*************************************************************************
2004 This function calculates the value of the parametric spline for a given
2005 value of parameter T
2006 
2007 INPUT PARAMETERS:
2008  P - parametric spline interpolant
2009  T - point:
2010  * T in [0,1] corresponds to interval spanned by points
2011  * for non-periodic splines T<0 (or T>1) correspond to parts of
2012  the curve before the first (after the last) point
2013  * for periodic splines T<0 (or T>1) are projected into [0,1]
2014  by making T=T-floor(T).
2015 
2016 OUTPUT PARAMETERS:
2017  X - X-position
2018  Y - Y-position
2019 
2020 
2021  -- ALGLIB PROJECT --
2022  Copyright 28.05.2010 by Bochkanov Sergey
2023 *************************************************************************/
2024 void pspline2calc(const pspline2interpolant &p, const double t, double &x, double &y);
2025 
2026 
2027 /*************************************************************************
2028 This function calculates the value of the parametric spline for a given
2029 value of parameter T.
2030 
2031 INPUT PARAMETERS:
2032  P - parametric spline interpolant
2033  T - point:
2034  * T in [0,1] corresponds to interval spanned by points
2035  * for non-periodic splines T<0 (or T>1) correspond to parts of
2036  the curve before the first (after the last) point
2037  * for periodic splines T<0 (or T>1) are projected into [0,1]
2038  by making T=T-floor(T).
2039 
2040 OUTPUT PARAMETERS:
2041  X - X-position
2042  Y - Y-position
2043  Z - Z-position
2044 
2045 
2046  -- ALGLIB PROJECT --
2047  Copyright 28.05.2010 by Bochkanov Sergey
2048 *************************************************************************/
2049 void pspline3calc(const pspline3interpolant &p, const double t, double &x, double &y, double &z);
2050 
2051 
2052 /*************************************************************************
2053 This function calculates tangent vector for a given value of parameter T
2054 
2055 INPUT PARAMETERS:
2056  P - parametric spline interpolant
2057  T - point:
2058  * T in [0,1] corresponds to interval spanned by points
2059  * for non-periodic splines T<0 (or T>1) correspond to parts of
2060  the curve before the first (after the last) point
2061  * for periodic splines T<0 (or T>1) are projected into [0,1]
2062  by making T=T-floor(T).
2063 
2064 OUTPUT PARAMETERS:
2065  X - X-component of tangent vector (normalized)
2066  Y - Y-component of tangent vector (normalized)
2067 
2068 NOTE:
2069  X^2+Y^2 is either 1 (for non-zero tangent vector) or 0.
2070 
2071 
2072  -- ALGLIB PROJECT --
2073  Copyright 28.05.2010 by Bochkanov Sergey
2074 *************************************************************************/
2075 void pspline2tangent(const pspline2interpolant &p, const double t, double &x, double &y);
2076 
2077 
2078 /*************************************************************************
2079 This function calculates tangent vector for a given value of parameter T
2080 
2081 INPUT PARAMETERS:
2082  P - parametric spline interpolant
2083  T - point:
2084  * T in [0,1] corresponds to interval spanned by points
2085  * for non-periodic splines T<0 (or T>1) correspond to parts of
2086  the curve before the first (after the last) point
2087  * for periodic splines T<0 (or T>1) are projected into [0,1]
2088  by making T=T-floor(T).
2089 
2090 OUTPUT PARAMETERS:
2091  X - X-component of tangent vector (normalized)
2092  Y - Y-component of tangent vector (normalized)
2093  Z - Z-component of tangent vector (normalized)
2094 
2095 NOTE:
2096  X^2+Y^2+Z^2 is either 1 (for non-zero tangent vector) or 0.
2097 
2098 
2099  -- ALGLIB PROJECT --
2100  Copyright 28.05.2010 by Bochkanov Sergey
2101 *************************************************************************/
2102 void pspline3tangent(const pspline3interpolant &p, const double t, double &x, double &y, double &z);
2103 
2104 
2105 /*************************************************************************
2106 This function calculates derivative, i.e. it returns (dX/dT,dY/dT).
2107 
2108 INPUT PARAMETERS:
2109  P - parametric spline interpolant
2110  T - point:
2111  * T in [0,1] corresponds to interval spanned by points
2112  * for non-periodic splines T<0 (or T>1) correspond to parts of
2113  the curve before the first (after the last) point
2114  * for periodic splines T<0 (or T>1) are projected into [0,1]
2115  by making T=T-floor(T).
2116 
2117 OUTPUT PARAMETERS:
2118  X - X-value
2119  DX - X-derivative
2120  Y - Y-value
2121  DY - Y-derivative
2122 
2123 
2124  -- ALGLIB PROJECT --
2125  Copyright 28.05.2010 by Bochkanov Sergey
2126 *************************************************************************/
2127 void pspline2diff(const pspline2interpolant &p, const double t, double &x, double &dx, double &y, double &dy);
2128 
2129 
2130 /*************************************************************************
2131 This function calculates derivative, i.e. it returns (dX/dT,dY/dT,dZ/dT).
2132 
2133 INPUT PARAMETERS:
2134  P - parametric spline interpolant
2135  T - point:
2136  * T in [0,1] corresponds to interval spanned by points
2137  * for non-periodic splines T<0 (or T>1) correspond to parts of
2138  the curve before the first (after the last) point
2139  * for periodic splines T<0 (or T>1) are projected into [0,1]
2140  by making T=T-floor(T).
2141 
2142 OUTPUT PARAMETERS:
2143  X - X-value
2144  DX - X-derivative
2145  Y - Y-value
2146  DY - Y-derivative
2147  Z - Z-value
2148  DZ - Z-derivative
2149 
2150 
2151  -- ALGLIB PROJECT --
2152  Copyright 28.05.2010 by Bochkanov Sergey
2153 *************************************************************************/
2154 void pspline3diff(const pspline3interpolant &p, const double t, double &x, double &dx, double &y, double &dy, double &z, double &dz);
2155 
2156 
2157 /*************************************************************************
2158 This function calculates first and second derivative with respect to T.
2159 
2160 INPUT PARAMETERS:
2161  P - parametric spline interpolant
2162  T - point:
2163  * T in [0,1] corresponds to interval spanned by points
2164  * for non-periodic splines T<0 (or T>1) correspond to parts of
2165  the curve before the first (after the last) point
2166  * for periodic splines T<0 (or T>1) are projected into [0,1]
2167  by making T=T-floor(T).
2168 
2169 OUTPUT PARAMETERS:
2170  X - X-value
2171  DX - derivative
2172  D2X - second derivative
2173  Y - Y-value
2174  DY - derivative
2175  D2Y - second derivative
2176 
2177 
2178  -- ALGLIB PROJECT --
2179  Copyright 28.05.2010 by Bochkanov Sergey
2180 *************************************************************************/
2181 void pspline2diff2(const pspline2interpolant &p, const double t, double &x, double &dx, double &d2x, double &y, double &dy, double &d2y);
2182 
2183 
2184 /*************************************************************************
2185 This function calculates first and second derivative with respect to T.
2186 
2187 INPUT PARAMETERS:
2188  P - parametric spline interpolant
2189  T - point:
2190  * T in [0,1] corresponds to interval spanned by points
2191  * for non-periodic splines T<0 (or T>1) correspond to parts of
2192  the curve before the first (after the last) point
2193  * for periodic splines T<0 (or T>1) are projected into [0,1]
2194  by making T=T-floor(T).
2195 
2196 OUTPUT PARAMETERS:
2197  X - X-value
2198  DX - derivative
2199  D2X - second derivative
2200  Y - Y-value
2201  DY - derivative
2202  D2Y - second derivative
2203  Z - Z-value
2204  DZ - derivative
2205  D2Z - second derivative
2206 
2207 
2208  -- ALGLIB PROJECT --
2209  Copyright 28.05.2010 by Bochkanov Sergey
2210 *************************************************************************/
2211 void pspline3diff2(const pspline3interpolant &p, const double t, double &x, double &dx, double &d2x, double &y, double &dy, double &d2y, double &z, double &dz, double &d2z);
2212 
2213 
2214 /*************************************************************************
2215 This function calculates arc length, i.e. length of curve between t=a
2216 and t=b.
2217 
2218 INPUT PARAMETERS:
2219  P - parametric spline interpolant
2220  A,B - parameter values corresponding to arc ends:
2221  * B>A will result in positive length returned
2222  * B<A will result in negative length returned
2223 
2224 RESULT:
2225  length of arc starting at T=A and ending at T=B.
2226 
2227 
2228  -- ALGLIB PROJECT --
2229  Copyright 30.05.2010 by Bochkanov Sergey
2230 *************************************************************************/
2231 double pspline2arclength(const pspline2interpolant &p, const double a, const double b);
2232 
2233 
2234 /*************************************************************************
2235 This function calculates arc length, i.e. length of curve between t=a
2236 and t=b.
2237 
2238 INPUT PARAMETERS:
2239  P - parametric spline interpolant
2240  A,B - parameter values corresponding to arc ends:
2241  * B>A will result in positive length returned
2242  * B<A will result in negative length returned
2243 
2244 RESULT:
2245  length of arc starting at T=A and ending at T=B.
2246 
2247 
2248  -- ALGLIB PROJECT --
2249  Copyright 30.05.2010 by Bochkanov Sergey
2250 *************************************************************************/
2251 double pspline3arclength(const pspline3interpolant &p, const double a, const double b);
2252 
2253 
2254 /*************************************************************************
2255 This subroutine fits piecewise linear curve to points with Ramer-Douglas-
2256 Peucker algorithm. This function performs PARAMETRIC fit, i.e. it can be
2257 used to fit curves like circles.
2258 
2259 On input it accepts dataset which describes parametric multidimensional
2260 curve X(t), with X being vector, and t taking values in [0,N), where N is
2261 a number of points in dataset. As result, it returns reduced dataset X2,
2262 which can be used to build parametric curve X2(t), which approximates
2263 X(t) with desired precision (or has specified number of sections).
2264 
2265 
2266 INPUT PARAMETERS:
2267  X - array of multidimensional points:
2268  * at least N elements, leading N elements are used if more
2269  than N elements were specified
2270  * order of points is IMPORTANT because it is parametric
2271  fit
2272  * each row of array is one point which has D coordinates
2273  N - number of elements in X
2274  D - number of dimensions (elements per row of X)
2275  StopM - stopping condition - desired number of sections:
2276  * at most M sections are generated by this function
2277  * less than M sections can be generated if we have N<M
2278  (or some X are non-distinct).
2279  * zero StopM means that algorithm does not stop after
2280  achieving some pre-specified section count
2281  StopEps - stopping condition - desired precision:
2282  * algorithm stops after error in each section is at most Eps
2283  * zero Eps means that algorithm does not stop after
2284  achieving some pre-specified precision
2285 
2286 OUTPUT PARAMETERS:
2287  X2 - array of corner points for piecewise approximation,
2288  has length NSections+1 or zero (for NSections=0).
2289  Idx2 - array of indexes (parameter values):
2290  * has length NSections+1 or zero (for NSections=0).
2291  * each element of Idx2 corresponds to same-numbered
2292  element of X2
2293  * each element of Idx2 is index of corresponding element
2294  of X2 at original array X, i.e. I-th row of X2 is
2295  Idx2[I]-th row of X.
2296  * elements of Idx2 can be treated as parameter values
2297  which should be used when building new parametric curve
2298  * Idx2[0]=0, Idx2[NSections]=N-1
2299  NSections- number of sections found by algorithm, NSections<=M,
2300  NSections can be zero for degenerate datasets
2301  (N<=1 or all X[] are non-distinct).
2302 
2303 NOTE: algorithm stops after:
2304  a) dividing curve into StopM sections
2305  b) achieving required precision StopEps
2306  c) dividing curve into N-1 sections
2307  If both StopM and StopEps are non-zero, algorithm is stopped by the
2308  FIRST criterion which is satisfied. In case both StopM and StopEps
2309  are zero, algorithm stops because of (c).
2310 
2311  -- ALGLIB --
2312  Copyright 02.10.2014 by Bochkanov Sergey
2313 *************************************************************************/
2314 void parametricrdpfixed(const real_2d_array &x, const ae_int_t n, const ae_int_t d, const ae_int_t stopm, const double stopeps, real_2d_array &x2, integer_1d_array &idx2, ae_int_t &nsections);
2315 
2316 /*************************************************************************
2317 This subroutine calculates the value of the trilinear or tricubic spline at
2318 the given point (X,Y,Z).
2319 
2320 INPUT PARAMETERS:
2321  C - coefficients table.
2322  Built by BuildBilinearSpline or BuildBicubicSpline.
2323  X, Y,
2324  Z - point
2325 
2326 Result:
2327  S(x,y,z)
2328 
2329  -- ALGLIB PROJECT --
2330  Copyright 26.04.2012 by Bochkanov Sergey
2331 *************************************************************************/
2332 double spline3dcalc(const spline3dinterpolant &c, const double x, const double y, const double z);
2333 
2334 
2335 /*************************************************************************
2336 This subroutine performs linear transformation of the spline argument.
2337 
2338 INPUT PARAMETERS:
2339  C - spline interpolant
2340  AX, BX - transformation coefficients: x = A*u + B
2341  AY, BY - transformation coefficients: y = A*v + B
2342  AZ, BZ - transformation coefficients: z = A*w + B
2343 
2344 OUTPUT PARAMETERS:
2345  C - transformed spline
2346 
2347  -- ALGLIB PROJECT --
2348  Copyright 26.04.2012 by Bochkanov Sergey
2349 *************************************************************************/
2350 void spline3dlintransxyz(const spline3dinterpolant &c, const double ax, const double bx, const double ay, const double by, const double az, const double bz);
2351 
2352 
2353 /*************************************************************************
2354 This subroutine performs linear transformation of the spline.
2355 
2356 INPUT PARAMETERS:
2357  C - spline interpolant.
2358  A, B- transformation coefficients: S2(x,y) = A*S(x,y,z) + B
2359 
2360 OUTPUT PARAMETERS:
2361  C - transformed spline
2362 
2363  -- ALGLIB PROJECT --
2364  Copyright 26.04.2012 by Bochkanov Sergey
2365 *************************************************************************/
2366 void spline3dlintransf(const spline3dinterpolant &c, const double a, const double b);
2367 
2368 
2369 /*************************************************************************
2370 Trilinear spline resampling
2371 
2372 INPUT PARAMETERS:
2373  A - array[0..OldXCount*OldYCount*OldZCount-1], function
2374  values at the old grid, :
2375  A[0] x=0,y=0,z=0
2376  A[1] x=1,y=0,z=0
2377  A[..] ...
2378  A[..] x=oldxcount-1,y=0,z=0
2379  A[..] x=0,y=1,z=0
2380  A[..] ...
2381  ...
2382  OldZCount - old Z-count, OldZCount>1
2383  OldYCount - old Y-count, OldYCount>1
2384  OldXCount - old X-count, OldXCount>1
2385  NewZCount - new Z-count, NewZCount>1
2386  NewYCount - new Y-count, NewYCount>1
2387  NewXCount - new X-count, NewXCount>1
2388 
2389 OUTPUT PARAMETERS:
2390  B - array[0..NewXCount*NewYCount*NewZCount-1], function
2391  values at the new grid:
2392  B[0] x=0,y=0,z=0
2393  B[1] x=1,y=0,z=0
2394  B[..] ...
2395  B[..] x=newxcount-1,y=0,z=0
2396  B[..] x=0,y=1,z=0
2397  B[..] ...
2398  ...
2399 
2400  -- ALGLIB routine --
2401  26.04.2012
2402  Copyright by Bochkanov Sergey
2403 *************************************************************************/
2404 void spline3dresampletrilinear(const real_1d_array &a, const ae_int_t oldzcount, const ae_int_t oldycount, const ae_int_t oldxcount, const ae_int_t newzcount, const ae_int_t newycount, const ae_int_t newxcount, real_1d_array &b);
2405 
2406 
2407 /*************************************************************************
2408 This subroutine builds trilinear vector-valued spline.
2409 
2410 INPUT PARAMETERS:
2411  X - spline abscissas, array[0..N-1]
2412  Y - spline ordinates, array[0..M-1]
2413  Z - spline applicates, array[0..L-1]
2414  F - function values, array[0..M*N*L*D-1]:
2415  * first D elements store D values at (X[0],Y[0],Z[0])
2416  * next D elements store D values at (X[1],Y[0],Z[0])
2417  * next D elements store D values at (X[2],Y[0],Z[0])
2418  * ...
2419  * next D elements store D values at (X[0],Y[1],Z[0])
2420  * next D elements store D values at (X[1],Y[1],Z[0])
2421  * next D elements store D values at (X[2],Y[1],Z[0])
2422  * ...
2423  * next D elements store D values at (X[0],Y[0],Z[1])
2424  * next D elements store D values at (X[1],Y[0],Z[1])
2425  * next D elements store D values at (X[2],Y[0],Z[1])
2426  * ...
2427  * general form - D function values at (X[i],Y[j]) are stored
2428  at F[D*(N*(M*K+J)+I)...D*(N*(M*K+J)+I)+D-1].
2429  M,N,
2430  L - grid size, M>=2, N>=2, L>=2
2431  D - vector dimension, D>=1
2432 
2433 OUTPUT PARAMETERS:
2434  C - spline interpolant
2435 
2436  -- ALGLIB PROJECT --
2437  Copyright 26.04.2012 by Bochkanov Sergey
2438 *************************************************************************/
2439 void spline3dbuildtrilinearv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &z, const ae_int_t l, const real_1d_array &f, const ae_int_t d, spline3dinterpolant &c);
2440 
2441 
2442 /*************************************************************************
2443 This subroutine calculates bilinear or bicubic vector-valued spline at the
2444 given point (X,Y,Z).
2445 
2446 INPUT PARAMETERS:
2447  C - spline interpolant.
2448  X, Y,
2449  Z - point
2450  F - output buffer, possibly preallocated array. In case array size
2451  is large enough to store result, it is not reallocated. Array
2452  which is too short will be reallocated
2453 
2454 OUTPUT PARAMETERS:
2455  F - array[D] (or larger) which stores function values
2456 
2457  -- ALGLIB PROJECT --
2458  Copyright 26.04.2012 by Bochkanov Sergey
2459 *************************************************************************/
2460 void spline3dcalcvbuf(const spline3dinterpolant &c, const double x, const double y, const double z, real_1d_array &f);
2461 
2462 
2463 /*************************************************************************
2464 This subroutine calculates trilinear or tricubic vector-valued spline at the
2465 given point (X,Y,Z).
2466 
2467 INPUT PARAMETERS:
2468  C - spline interpolant.
2469  X, Y,
2470  Z - point
2471 
2472 OUTPUT PARAMETERS:
2473  F - array[D] which stores function values. F is out-parameter and
2474  it is reallocated after call to this function. In case you
2475  want to reuse previously allocated F, you may use
2476  Spline2DCalcVBuf(), which reallocates F only when it is too
2477  small.
2478 
2479  -- ALGLIB PROJECT --
2480  Copyright 26.04.2012 by Bochkanov Sergey
2481 *************************************************************************/
2482 void spline3dcalcv(const spline3dinterpolant &c, const double x, const double y, const double z, real_1d_array &f);
2483 
2484 
2485 /*************************************************************************
2486 This subroutine unpacks tri-dimensional spline into the coefficients table
2487 
2488 INPUT PARAMETERS:
2489  C - spline interpolant.
2490 
2491 Result:
2492  N - grid size (X)
2493  M - grid size (Y)
2494  L - grid size (Z)
2495  D - number of components
2496  SType- spline type. Currently, only one spline type is supported:
2497  trilinear spline, as indicated by SType=1.
2498  Tbl - spline coefficients: [0..(N-1)*(M-1)*(L-1)*D-1, 0..13].
2499  For T=0..D-1 (component index), I = 0...N-2 (x index),
2500  J=0..M-2 (y index), K=0..L-2 (z index):
2501  Q := T + I*D + J*D*(N-1) + K*D*(N-1)*(M-1),
2502 
2503  Q-th row stores decomposition for T-th component of the
2504  vector-valued function
2505 
2506  Tbl[Q,0] = X[i]
2507  Tbl[Q,1] = X[i+1]
2508  Tbl[Q,2] = Y[j]
2509  Tbl[Q,3] = Y[j+1]
2510  Tbl[Q,4] = Z[k]
2511  Tbl[Q,5] = Z[k+1]
2512 
2513  Tbl[Q,6] = C000
2514  Tbl[Q,7] = C100
2515  Tbl[Q,8] = C010
2516  Tbl[Q,9] = C110
2517  Tbl[Q,10]= C001
2518  Tbl[Q,11]= C101
2519  Tbl[Q,12]= C011
2520  Tbl[Q,13]= C111
2521  On each grid square spline is equals to:
2522  S(x) = SUM(c[i,j,k]*(x^i)*(y^j)*(z^k), i=0..1, j=0..1, k=0..1)
2523  t = x-x[j]
2524  u = y-y[i]
2525  v = z-z[k]
2526 
2527  NOTE: format of Tbl is given for SType=1. Future versions of
2528  ALGLIB can use different formats for different values of
2529  SType.
2530 
2531  -- ALGLIB PROJECT --
2532  Copyright 26.04.2012 by Bochkanov Sergey
2533 *************************************************************************/
2535 
2536 /*************************************************************************
2537 Conversion from barycentric representation to Chebyshev basis.
2538 This function has O(N^2) complexity.
2539 
2540 INPUT PARAMETERS:
2541  P - polynomial in barycentric form
2542  A,B - base interval for Chebyshev polynomials (see below)
2543  A<>B
2544 
2545 OUTPUT PARAMETERS
2546  T - coefficients of Chebyshev representation;
2547  P(x) = sum { T[i]*Ti(2*(x-A)/(B-A)-1), i=0..N-1 },
2548  where Ti - I-th Chebyshev polynomial.
2549 
2550 NOTES:
2551  barycentric interpolant passed as P may be either polynomial obtained
2552  from polynomial interpolation/ fitting or rational function which is
2553  NOT polynomial. We can't distinguish between these two cases, and this
2554  algorithm just tries to work assuming that P IS a polynomial. If not,
2555  algorithm will return results, but they won't have any meaning.
2556 
2557  -- ALGLIB --
2558  Copyright 30.09.2010 by Bochkanov Sergey
2559 *************************************************************************/
2560 void polynomialbar2cheb(const barycentricinterpolant &p, const double a, const double b, real_1d_array &t);
2561 
2562 
2563 /*************************************************************************
2564 Conversion from Chebyshev basis to barycentric representation.
2565 This function has O(N^2) complexity.
2566 
2567 INPUT PARAMETERS:
2568  T - coefficients of Chebyshev representation;
2569  P(x) = sum { T[i]*Ti(2*(x-A)/(B-A)-1), i=0..N },
2570  where Ti - I-th Chebyshev polynomial.
2571  N - number of coefficients:
2572  * if given, only leading N elements of T are used
2573  * if not given, automatically determined from size of T
2574  A,B - base interval for Chebyshev polynomials (see above)
2575  A<B
2576 
2577 OUTPUT PARAMETERS
2578  P - polynomial in barycentric form
2579 
2580  -- ALGLIB --
2581  Copyright 30.09.2010 by Bochkanov Sergey
2582 *************************************************************************/
2583 void polynomialcheb2bar(const real_1d_array &t, const ae_int_t n, const double a, const double b, barycentricinterpolant &p);
2584 void polynomialcheb2bar(const real_1d_array &t, const double a, const double b, barycentricinterpolant &p);
2585 
2586 
2587 /*************************************************************************
2588 Conversion from barycentric representation to power basis.
2589 This function has O(N^2) complexity.
2590 
2591 INPUT PARAMETERS:
2592  P - polynomial in barycentric form
2593  C - offset (see below); 0.0 is used as default value.
2594  S - scale (see below); 1.0 is used as default value. S<>0.
2595 
2596 OUTPUT PARAMETERS
2597  A - coefficients, P(x) = sum { A[i]*((X-C)/S)^i, i=0..N-1 }
2598  N - number of coefficients (polynomial degree plus 1)
2599 
2600 NOTES:
2601 1. this function accepts offset and scale, which can be set to improve
2602  numerical properties of polynomial. For example, if P was obtained as
2603  result of interpolation on [-1,+1], you can set C=0 and S=1 and
2604  represent P as sum of 1, x, x^2, x^3 and so on. In most cases you it
2605  is exactly what you need.
2606 
2607  However, if your interpolation model was built on [999,1001], you will
2608  see significant growth of numerical errors when using {1, x, x^2, x^3}
2609  as basis. Representing P as sum of 1, (x-1000), (x-1000)^2, (x-1000)^3
2610  will be better option. Such representation can be obtained by using
2611  1000.0 as offset C and 1.0 as scale S.
2612 
2613 2. power basis is ill-conditioned and tricks described above can't solve
2614  this problem completely. This function will return coefficients in
2615  any case, but for N>8 they will become unreliable. However, N's
2616  less than 5 are pretty safe.
2617 
2618 3. barycentric interpolant passed as P may be either polynomial obtained
2619  from polynomial interpolation/ fitting or rational function which is
2620  NOT polynomial. We can't distinguish between these two cases, and this
2621  algorithm just tries to work assuming that P IS a polynomial. If not,
2622  algorithm will return results, but they won't have any meaning.
2623 
2624  -- ALGLIB --
2625  Copyright 30.09.2010 by Bochkanov Sergey
2626 *************************************************************************/
2627 void polynomialbar2pow(const barycentricinterpolant &p, const double c, const double s, real_1d_array &a);
2629 
2630 
2631 /*************************************************************************
2632 Conversion from power basis to barycentric representation.
2633 This function has O(N^2) complexity.
2634 
2635 INPUT PARAMETERS:
2636  A - coefficients, P(x) = sum { A[i]*((X-C)/S)^i, i=0..N-1 }
2637  N - number of coefficients (polynomial degree plus 1)
2638  * if given, only leading N elements of A are used
2639  * if not given, automatically determined from size of A
2640  C - offset (see below); 0.0 is used as default value.
2641  S - scale (see below); 1.0 is used as default value. S<>0.
2642 
2643 OUTPUT PARAMETERS
2644  P - polynomial in barycentric form
2645 
2646 
2647 NOTES:
2648 1. this function accepts offset and scale, which can be set to improve
2649  numerical properties of polynomial. For example, if you interpolate on
2650  [-1,+1], you can set C=0 and S=1 and convert from sum of 1, x, x^2,
2651  x^3 and so on. In most cases you it is exactly what you need.
2652 
2653  However, if your interpolation model was built on [999,1001], you will
2654  see significant growth of numerical errors when using {1, x, x^2, x^3}
2655  as input basis. Converting from sum of 1, (x-1000), (x-1000)^2,
2656  (x-1000)^3 will be better option (you have to specify 1000.0 as offset
2657  C and 1.0 as scale S).
2658 
2659 2. power basis is ill-conditioned and tricks described above can't solve
2660  this problem completely. This function will return barycentric model
2661  in any case, but for N>8 accuracy well degrade. However, N's less than
2662  5 are pretty safe.
2663 
2664  -- ALGLIB --
2665  Copyright 30.09.2010 by Bochkanov Sergey
2666 *************************************************************************/
2667 void polynomialpow2bar(const real_1d_array &a, const ae_int_t n, const double c, const double s, barycentricinterpolant &p);
2669 
2670 
2671 /*************************************************************************
2672 Lagrange intepolant: generation of the model on the general grid.
2673 This function has O(N^2) complexity.
2674 
2675 INPUT PARAMETERS:
2676  X - abscissas, array[0..N-1]
2677  Y - function values, array[0..N-1]
2678  N - number of points, N>=1
2679 
2680 OUTPUT PARAMETERS
2681  P - barycentric model which represents Lagrange interpolant
2682  (see ratint unit info and BarycentricCalc() description for
2683  more information).
2684 
2685  -- ALGLIB --
2686  Copyright 02.12.2009 by Bochkanov Sergey
2687 *************************************************************************/
2690 
2691 
2692 /*************************************************************************
2693 Lagrange intepolant: generation of the model on equidistant grid.
2694 This function has O(N) complexity.
2695 
2696 INPUT PARAMETERS:
2697  A - left boundary of [A,B]
2698  B - right boundary of [A,B]
2699  Y - function values at the nodes, array[0..N-1]
2700  N - number of points, N>=1
2701  for N=1 a constant model is constructed.
2702 
2703 OUTPUT PARAMETERS
2704  P - barycentric model which represents Lagrange interpolant
2705  (see ratint unit info and BarycentricCalc() description for
2706  more information).
2707 
2708  -- ALGLIB --
2709  Copyright 03.12.2009 by Bochkanov Sergey
2710 *************************************************************************/
2711 void polynomialbuildeqdist(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
2712 void polynomialbuildeqdist(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
2713 
2714 
2715 /*************************************************************************
2716 Lagrange intepolant on Chebyshev grid (first kind).
2717 This function has O(N) complexity.
2718 
2719 INPUT PARAMETERS:
2720  A - left boundary of [A,B]
2721  B - right boundary of [A,B]
2722  Y - function values at the nodes, array[0..N-1],
2723  Y[I] = Y(0.5*(B+A) + 0.5*(B-A)*Cos(PI*(2*i+1)/(2*n)))
2724  N - number of points, N>=1
2725  for N=1 a constant model is constructed.
2726 
2727 OUTPUT PARAMETERS
2728  P - barycentric model which represents Lagrange interpolant
2729  (see ratint unit info and BarycentricCalc() description for
2730  more information).
2731 
2732  -- ALGLIB --
2733  Copyright 03.12.2009 by Bochkanov Sergey
2734 *************************************************************************/
2735 void polynomialbuildcheb1(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
2736 void polynomialbuildcheb1(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
2737 
2738 
2739 /*************************************************************************
2740 Lagrange intepolant on Chebyshev grid (second kind).
2741 This function has O(N) complexity.
2742 
2743 INPUT PARAMETERS:
2744  A - left boundary of [A,B]
2745  B - right boundary of [A,B]
2746  Y - function values at the nodes, array[0..N-1],
2747  Y[I] = Y(0.5*(B+A) + 0.5*(B-A)*Cos(PI*i/(n-1)))
2748  N - number of points, N>=1
2749  for N=1 a constant model is constructed.
2750 
2751 OUTPUT PARAMETERS
2752  P - barycentric model which represents Lagrange interpolant
2753  (see ratint unit info and BarycentricCalc() description for
2754  more information).
2755 
2756  -- ALGLIB --
2757  Copyright 03.12.2009 by Bochkanov Sergey
2758 *************************************************************************/
2759 void polynomialbuildcheb2(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
2760 void polynomialbuildcheb2(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
2761 
2762 
2763 /*************************************************************************
2764 Fast equidistant polynomial interpolation function with O(N) complexity
2765 
2766 INPUT PARAMETERS:
2767  A - left boundary of [A,B]
2768  B - right boundary of [A,B]
2769  F - function values, array[0..N-1]
2770  N - number of points on equidistant grid, N>=1
2771  for N=1 a constant model is constructed.
2772  T - position where P(x) is calculated
2773 
2774 RESULT
2775  value of the Lagrange interpolant at T
2776 
2777 IMPORTANT
2778  this function provides fast interface which is not overflow-safe
2779  nor it is very precise.
2780  the best option is to use PolynomialBuildEqDist()/BarycentricCalc()
2781  subroutines unless you are pretty sure that your data will not result
2782  in overflow.
2783 
2784  -- ALGLIB --
2785  Copyright 02.12.2009 by Bochkanov Sergey
2786 *************************************************************************/
2787 double polynomialcalceqdist(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
2788 double polynomialcalceqdist(const double a, const double b, const real_1d_array &f, const double t);
2789 
2790 
2791 /*************************************************************************
2792 Fast polynomial interpolation function on Chebyshev points (first kind)
2793 with O(N) complexity.
2794 
2795 INPUT PARAMETERS:
2796  A - left boundary of [A,B]
2797  B - right boundary of [A,B]
2798  F - function values, array[0..N-1]
2799  N - number of points on Chebyshev grid (first kind),
2800  X[i] = 0.5*(B+A) + 0.5*(B-A)*Cos(PI*(2*i+1)/(2*n))
2801  for N=1 a constant model is constructed.
2802  T - position where P(x) is calculated
2803 
2804 RESULT
2805  value of the Lagrange interpolant at T
2806 
2807 IMPORTANT
2808  this function provides fast interface which is not overflow-safe
2809  nor it is very precise.
2810  the best option is to use PolIntBuildCheb1()/BarycentricCalc()
2811  subroutines unless you are pretty sure that your data will not result
2812  in overflow.
2813 
2814  -- ALGLIB --
2815  Copyright 02.12.2009 by Bochkanov Sergey
2816 *************************************************************************/
2817 double polynomialcalccheb1(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
2818 double polynomialcalccheb1(const double a, const double b, const real_1d_array &f, const double t);
2819 
2820 
2821 /*************************************************************************
2822 Fast polynomial interpolation function on Chebyshev points (second kind)
2823 with O(N) complexity.
2824 
2825 INPUT PARAMETERS:
2826  A - left boundary of [A,B]
2827  B - right boundary of [A,B]
2828  F - function values, array[0..N-1]
2829  N - number of points on Chebyshev grid (second kind),
2830  X[i] = 0.5*(B+A) + 0.5*(B-A)*Cos(PI*i/(n-1))
2831  for N=1 a constant model is constructed.
2832  T - position where P(x) is calculated
2833 
2834 RESULT
2835  value of the Lagrange interpolant at T
2836 
2837 IMPORTANT
2838  this function provides fast interface which is not overflow-safe
2839  nor it is very precise.
2840  the best option is to use PolIntBuildCheb2()/BarycentricCalc()
2841  subroutines unless you are pretty sure that your data will not result
2842  in overflow.
2843 
2844  -- ALGLIB --
2845  Copyright 02.12.2009 by Bochkanov Sergey
2846 *************************************************************************/
2847 double polynomialcalccheb2(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
2848 double polynomialcalccheb2(const double a, const double b, const real_1d_array &f, const double t);
2849 
2850 /*************************************************************************
2851 This subroutine fits piecewise linear curve to points with Ramer-Douglas-
2852 Peucker algorithm, which stops after generating specified number of linear
2853 sections.
2854 
2855 IMPORTANT:
2856 * it does NOT perform least-squares fitting; it builds curve, but this
2857  curve does not minimize some least squares metric. See description of
2858  RDP algorithm (say, in Wikipedia) for more details on WHAT is performed.
2859 * this function does NOT work with parametric curves (i.e. curves which
2860  can be represented as {X(t),Y(t)}. It works with curves which can be
2861  represented as Y(X). Thus, it is impossible to model figures like
2862  circles with this functions.
2863  If you want to work with parametric curves, you should use
2864  ParametricRDPFixed() function provided by "Parametric" subpackage of
2865  "Interpolation" package.
2866 
2867 INPUT PARAMETERS:
2868  X - array of X-coordinates:
2869  * at least N elements
2870  * can be unordered (points are automatically sorted)
2871  * this function may accept non-distinct X (see below for
2872  more information on handling of such inputs)
2873  Y - array of Y-coordinates:
2874  * at least N elements
2875  N - number of elements in X/Y
2876  M - desired number of sections:
2877  * at most M sections are generated by this function
2878  * less than M sections can be generated if we have N<M
2879  (or some X are non-distinct).
2880 
2881 OUTPUT PARAMETERS:
2882  X2 - X-values of corner points for piecewise approximation,
2883  has length NSections+1 or zero (for NSections=0).
2884  Y2 - Y-values of corner points,
2885  has length NSections+1 or zero (for NSections=0).
2886  NSections- number of sections found by algorithm, NSections<=M,
2887  NSections can be zero for degenerate datasets
2888  (N<=1 or all X[] are non-distinct).
2889 
2890 NOTE: X2/Y2 are ordered arrays, i.e. (X2[0],Y2[0]) is a first point of
2891  curve, (X2[NSection-1],Y2[NSection-1]) is the last point.
2892 
2893  -- ALGLIB --
2894  Copyright 02.10.2014 by Bochkanov Sergey
2895 *************************************************************************/
2896 void lstfitpiecewiselinearrdpfixed(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, real_1d_array &x2, real_1d_array &y2, ae_int_t &nsections);
2897 
2898 
2899 /*************************************************************************
2900 This subroutine fits piecewise linear curve to points with Ramer-Douglas-
2901 Peucker algorithm, which stops after achieving desired precision.
2902 
2903 IMPORTANT:
2904 * it performs non-least-squares fitting; it builds curve, but this curve
2905  does not minimize some least squares metric. See description of RDP
2906  algorithm (say, in Wikipedia) for more details on WHAT is performed.
2907 * this function does NOT work with parametric curves (i.e. curves which
2908  can be represented as {X(t),Y(t)}. It works with curves which can be
2909  represented as Y(X). Thus, it is impossible to model figures like circles
2910  with this functions.
2911  If you want to work with parametric curves, you should use
2912  ParametricRDPFixed() function provided by "Parametric" subpackage of
2913  "Interpolation" package.
2914 
2915 INPUT PARAMETERS:
2916  X - array of X-coordinates:
2917  * at least N elements
2918  * can be unordered (points are automatically sorted)
2919  * this function may accept non-distinct X (see below for
2920  more information on handling of such inputs)
2921  Y - array of Y-coordinates:
2922  * at least N elements
2923  N - number of elements in X/Y
2924  Eps - positive number, desired precision.
2925 
2926 
2927 OUTPUT PARAMETERS:
2928  X2 - X-values of corner points for piecewise approximation,
2929  has length NSections+1 or zero (for NSections=0).
2930  Y2 - Y-values of corner points,
2931  has length NSections+1 or zero (for NSections=0).
2932  NSections- number of sections found by algorithm,
2933  NSections can be zero for degenerate datasets
2934  (N<=1 or all X[] are non-distinct).
2935 
2936 NOTE: X2/Y2 are ordered arrays, i.e. (X2[0],Y2[0]) is a first point of
2937  curve, (X2[NSection-1],Y2[NSection-1]) is the last point.
2938 
2939  -- ALGLIB --
2940  Copyright 02.10.2014 by Bochkanov Sergey
2941 *************************************************************************/
2942 void lstfitpiecewiselinearrdp(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double eps, real_1d_array &x2, real_1d_array &y2, ae_int_t &nsections);
2943 
2944 
2945 /*************************************************************************
2946 Fitting by polynomials in barycentric form. This function provides simple
2947 unterface for unconstrained unweighted fitting. See PolynomialFitWC() if
2948 you need constrained fitting.
2949 
2950 Task is linear, so linear least squares solver is used. Complexity of this
2951 computational scheme is O(N*M^2), mostly dominated by least squares solver
2952 
2953 SEE ALSO:
2954  PolynomialFitWC()
2955 
2956 COMMERCIAL EDITION OF ALGLIB:
2957 
2958  ! Commercial version of ALGLIB includes two important improvements of
2959  ! this function, which can be used from C++ and C#:
2960  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
2961  ! * multithreading support
2962  !
2963  ! Intel MKL gives approximately constant (with respect to number of
2964  ! worker threads) acceleration factor which depends on CPU being used,
2965  ! problem size and "baseline" ALGLIB edition which is used for
2966  ! comparison.
2967  !
2968  ! Speed-up provided by multithreading greatly depends on problem size
2969  ! - only large problems (number of coefficients is more than 500) can be
2970  ! efficiently multithreaded.
2971  !
2972  ! Generally, commercial ALGLIB is several times faster than open-source
2973  ! generic C edition, and many times faster than open-source C# edition.
2974  !
2975  ! We recommend you to read 'Working with commercial version' section of
2976  ! ALGLIB Reference Manual in order to find out how to use performance-
2977  ! related features provided by commercial edition of ALGLIB.
2978 
2979 INPUT PARAMETERS:
2980  X - points, array[0..N-1].
2981  Y - function values, array[0..N-1].
2982  N - number of points, N>0
2983  * if given, only leading N elements of X/Y are used
2984  * if not given, automatically determined from sizes of X/Y
2985  M - number of basis functions (= polynomial_degree + 1), M>=1
2986 
2987 OUTPUT PARAMETERS:
2988  Info- same format as in LSFitLinearW() subroutine:
2989  * Info>0 task is solved
2990  * Info<=0 an error occured:
2991  -4 means inconvergence of internal SVD
2992  P - interpolant in barycentric form.
2993  Rep - report, same format as in LSFitLinearW() subroutine.
2994  Following fields are set:
2995  * RMSError rms error on the (X,Y).
2996  * AvgError average error on the (X,Y).
2997  * AvgRelError average relative error on the non-zero Y
2998  * MaxError maximum error
2999  NON-WEIGHTED ERRORS ARE CALCULATED
3000 
3001 NOTES:
3002  you can convert P from barycentric form to the power or Chebyshev
3003  basis with PolynomialBar2Pow() or PolynomialBar2Cheb() functions from
3004  POLINT subpackage.
3005 
3006  -- ALGLIB PROJECT --
3007  Copyright 10.12.2009 by Bochkanov Sergey
3008 *************************************************************************/
3013 
3014 
3015 /*************************************************************************
3016 Weighted fitting by polynomials in barycentric form, with constraints on
3017 function values or first derivatives.
3018 
3019 Small regularizing term is used when solving constrained tasks (to improve
3020 stability).
3021 
3022 Task is linear, so linear least squares solver is used. Complexity of this
3023 computational scheme is O(N*M^2), mostly dominated by least squares solver
3024 
3025 SEE ALSO:
3026  PolynomialFit()
3027 
3028 COMMERCIAL EDITION OF ALGLIB:
3029 
3030  ! Commercial version of ALGLIB includes two important improvements of
3031  ! this function, which can be used from C++ and C#:
3032  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
3033  ! * multithreading support
3034  !
3035  ! Intel MKL gives approximately constant (with respect to number of
3036  ! worker threads) acceleration factor which depends on CPU being used,
3037  ! problem size and "baseline" ALGLIB edition which is used for
3038  ! comparison.
3039  !
3040  ! Speed-up provided by multithreading greatly depends on problem size
3041  ! - only large problems (number of coefficients is more than 500) can be
3042  ! efficiently multithreaded.
3043  !
3044  ! Generally, commercial ALGLIB is several times faster than open-source
3045  ! generic C edition, and many times faster than open-source C# edition.
3046  !
3047  ! We recommend you to read 'Working with commercial version' section of
3048  ! ALGLIB Reference Manual in order to find out how to use performance-
3049  ! related features provided by commercial edition of ALGLIB.
3050 
3051 INPUT PARAMETERS:
3052  X - points, array[0..N-1].
3053  Y - function values, array[0..N-1].
3054  W - weights, array[0..N-1]
3055  Each summand in square sum of approximation deviations from
3056  given values is multiplied by the square of corresponding
3057  weight. Fill it by 1's if you don't want to solve weighted
3058  task.
3059  N - number of points, N>0.
3060  * if given, only leading N elements of X/Y/W are used
3061  * if not given, automatically determined from sizes of X/Y/W
3062  XC - points where polynomial values/derivatives are constrained,
3063  array[0..K-1].
3064  YC - values of constraints, array[0..K-1]
3065  DC - array[0..K-1], types of constraints:
3066  * DC[i]=0 means that P(XC[i])=YC[i]
3067  * DC[i]=1 means that P'(XC[i])=YC[i]
3068  SEE BELOW FOR IMPORTANT INFORMATION ON CONSTRAINTS
3069  K - number of constraints, 0<=K<M.
3070  K=0 means no constraints (XC/YC/DC are not used in such cases)
3071  M - number of basis functions (= polynomial_degree + 1), M>=1
3072 
3073 OUTPUT PARAMETERS:
3074  Info- same format as in LSFitLinearW() subroutine:
3075  * Info>0 task is solved
3076  * Info<=0 an error occured:
3077  -4 means inconvergence of internal SVD
3078  -3 means inconsistent constraints
3079  P - interpolant in barycentric form.
3080  Rep - report, same format as in LSFitLinearW() subroutine.
3081  Following fields are set:
3082  * RMSError rms error on the (X,Y).
3083  * AvgError average error on the (X,Y).
3084  * AvgRelError average relative error on the non-zero Y
3085  * MaxError maximum error
3086  NON-WEIGHTED ERRORS ARE CALCULATED
3087 
3088 IMPORTANT:
3089  this subroitine doesn't calculate task's condition number for K<>0.
3090 
3091 NOTES:
3092  you can convert P from barycentric form to the power or Chebyshev
3093  basis with PolynomialBar2Pow() or PolynomialBar2Cheb() functions from
3094  POLINT subpackage.
3095 
3096 SETTING CONSTRAINTS - DANGERS AND OPPORTUNITIES:
3097 
3098 Setting constraints can lead to undesired results, like ill-conditioned
3099 behavior, or inconsistency being detected. From the other side, it allows
3100 us to improve quality of the fit. Here we summarize our experience with
3101 constrained regression splines:
3102 * even simple constraints can be inconsistent, see Wikipedia article on
3103  this subject: http://en.wikipedia.org/wiki/Birkhoff_interpolation
3104 * the greater is M (given fixed constraints), the more chances that
3105  constraints will be consistent
3106 * in the general case, consistency of constraints is NOT GUARANTEED.
3107 * in the one special cases, however, we can guarantee consistency. This
3108  case is: M>1 and constraints on the function values (NOT DERIVATIVES)
3109 
3110 Our final recommendation is to use constraints WHEN AND ONLY when you
3111 can't solve your task without them. Anything beyond special cases given
3112 above is not guaranteed and may result in inconsistency.
3113 
3114  -- ALGLIB PROJECT --
3115  Copyright 10.12.2009 by Bochkanov Sergey
3116 *************************************************************************/
3117 void polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
3118 void smp_polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
3119 void polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
3121 
3122 
3123 /*************************************************************************
3124 This function calculates value of four-parameter logistic (4PL) model at
3125 specified point X. 4PL model has following form:
3126 
3127  F(x|A,B,C,D) = D+(A-D)/(1+Power(x/C,B))
3128 
3129 INPUT PARAMETERS:
3130  X - current point, X>=0:
3131  * zero X is correctly handled even for B<=0
3132  * negative X results in exception.
3133  A, B, C, D- parameters of 4PL model:
3134  * A is unconstrained
3135  * B is unconstrained; zero or negative values are handled
3136  correctly.
3137  * C>0, non-positive value results in exception
3138  * D is unconstrained
3139 
3140 RESULT:
3141  model value at X
3142 
3143 NOTE: if B=0, denominator is assumed to be equal to 2.0 even for zero X
3144  (strictly speaking, 0^0 is undefined).
3145 
3146 NOTE: this function also throws exception if all input parameters are
3147  correct, but overflow was detected during calculations.
3148 
3149 NOTE: this function performs a lot of checks; if you need really high
3150  performance, consider evaluating model yourself, without checking
3151  for degenerate cases.
3152 
3153 
3154  -- ALGLIB PROJECT --
3155  Copyright 14.05.2014 by Bochkanov Sergey
3156 *************************************************************************/
3157 double logisticcalc4(const double x, const double a, const double b, const double c, const double d);
3158 
3159 
3160 /*************************************************************************
3161 This function calculates value of five-parameter logistic (5PL) model at
3162 specified point X. 5PL model has following form:
3163 
3164  F(x|A,B,C,D,G) = D+(A-D)/Power(1+Power(x/C,B),G)
3165 
3166 INPUT PARAMETERS:
3167  X - current point, X>=0:
3168  * zero X is correctly handled even for B<=0
3169  * negative X results in exception.
3170  A, B, C, D, G- parameters of 5PL model:
3171  * A is unconstrained
3172  * B is unconstrained; zero or negative values are handled
3173  correctly.
3174  * C>0, non-positive value results in exception
3175  * D is unconstrained
3176  * G>0, non-positive value results in exception
3177 
3178 RESULT:
3179  model value at X
3180 
3181 NOTE: if B=0, denominator is assumed to be equal to Power(2.0,G) even for
3182  zero X (strictly speaking, 0^0 is undefined).
3183 
3184 NOTE: this function also throws exception if all input parameters are
3185  correct, but overflow was detected during calculations.
3186 
3187 NOTE: this function performs a lot of checks; if you need really high
3188  performance, consider evaluating model yourself, without checking
3189  for degenerate cases.
3190 
3191 
3192  -- ALGLIB PROJECT --
3193  Copyright 14.05.2014 by Bochkanov Sergey
3194 *************************************************************************/
3195 double logisticcalc5(const double x, const double a, const double b, const double c, const double d, const double g);
3196 
3197 
3198 /*************************************************************************
3199 This function fits four-parameter logistic (4PL) model to data provided
3200 by user. 4PL model has following form:
3201 
3202  F(x|A,B,C,D) = D+(A-D)/(1+Power(x/C,B))
3203 
3204 Here:
3205  * A, D - unconstrained (see LogisticFit4EC() for constrained 4PL)
3206  * B>=0
3207  * C>0
3208 
3209 IMPORTANT: output of this function is constrained in such way that B>0.
3210  Because 4PL model is symmetric with respect to B, there is no
3211  need to explore B<0. Constraining B makes algorithm easier
3212  to stabilize and debug.
3213  Users who for some reason prefer to work with negative B's
3214  should transform output themselves (swap A and D, replace B by
3215  -B).
3216 
3217 4PL fitting is implemented as follows:
3218 * we perform small number of restarts from random locations which helps to
3219  solve problem of bad local extrema. Locations are only partially random
3220  - we use input data to determine good initial guess, but we include
3221  controlled amount of randomness.
3222 * we perform Levenberg-Marquardt fitting with very tight constraints on
3223  parameters B and C - it allows us to find good initial guess for the
3224  second stage without risk of running into "flat spot".
3225 * second Levenberg-Marquardt round is performed without excessive
3226  constraints. Results from the previous round are used as initial guess.
3227 * after fitting is done, we compare results with best values found so far,
3228  rewrite "best solution" if needed, and move to next random location.
3229 
3230 Overall algorithm is very stable and is not prone to bad local extrema.
3231 Furthermore, it automatically scales when input data have very large or
3232 very small range.
3233 
3234 INPUT PARAMETERS:
3235  X - array[N], stores X-values.
3236  MUST include only non-negative numbers (but may include
3237  zero values). Can be unsorted.
3238  Y - array[N], values to fit.
3239  N - number of points. If N is less than length of X/Y, only
3240  leading N elements are used.
3241 
3242 OUTPUT PARAMETERS:
3243  A, B, C, D- parameters of 4PL model
3244  Rep - fitting report. This structure has many fields, but ONLY
3245  ONES LISTED BELOW ARE SET:
3246  * Rep.IterationsCount - number of iterations performed
3247  * Rep.RMSError - root-mean-square error
3248  * Rep.AvgError - average absolute error
3249  * Rep.AvgRelError - average relative error (calculated for
3250  non-zero Y-values)
3251  * Rep.MaxError - maximum absolute error
3252  * Rep.R2 - coefficient of determination, R-squared. This
3253  coefficient is calculated as R2=1-RSS/TSS (in case
3254  of nonlinear regression there are multiple ways to
3255  define R2, each of them giving different results).
3256 
3257 NOTE: after you obtained coefficients, you can evaluate model with
3258  LogisticCalc4() function.
3259 
3260 NOTE: if you need better control over fitting process than provided by this
3261  function, you may use LogisticFit45X().
3262 
3263 NOTE: step is automatically scaled according to scale of parameters being
3264  fitted before we compare its length with EpsX. Thus, this function
3265  can be used to fit data with very small or very large values without
3266  changing EpsX.
3267 
3268 
3269  -- ALGLIB PROJECT --
3270  Copyright 14.02.2014 by Bochkanov Sergey
3271 *************************************************************************/
3272 void logisticfit4(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, double &a, double &b, double &c, double &d, lsfitreport &rep);
3273 
3274 
3275 /*************************************************************************
3276 This function fits four-parameter logistic (4PL) model to data provided
3277 by user, with optional constraints on parameters A and D. 4PL model has
3278 following form:
3279 
3280  F(x|A,B,C,D) = D+(A-D)/(1+Power(x/C,B))
3281 
3282 Here:
3283  * A, D - with optional equality constraints
3284  * B>=0
3285  * C>0
3286 
3287 IMPORTANT: output of this function is constrained in such way that B>0.
3288  Because 4PL model is symmetric with respect to B, there is no
3289  need to explore B<0. Constraining B makes algorithm easier
3290  to stabilize and debug.
3291  Users who for some reason prefer to work with negative B's
3292  should transform output themselves (swap A and D, replace B by
3293  -B).
3294 
3295 4PL fitting is implemented as follows:
3296 * we perform small number of restarts from random locations which helps to
3297  solve problem of bad local extrema. Locations are only partially random
3298  - we use input data to determine good initial guess, but we include
3299  controlled amount of randomness.
3300 * we perform Levenberg-Marquardt fitting with very tight constraints on
3301  parameters B and C - it allows us to find good initial guess for the
3302  second stage without risk of running into "flat spot".
3303 * second Levenberg-Marquardt round is performed without excessive
3304  constraints. Results from the previous round are used as initial guess.
3305 * after fitting is done, we compare results with best values found so far,
3306  rewrite "best solution" if needed, and move to next random location.
3307 
3308 Overall algorithm is very stable and is not prone to bad local extrema.
3309 Furthermore, it automatically scales when input data have very large or
3310 very small range.
3311 
3312 INPUT PARAMETERS:
3313  X - array[N], stores X-values.
3314  MUST include only non-negative numbers (but may include
3315  zero values). Can be unsorted.
3316  Y - array[N], values to fit.
3317  N - number of points. If N is less than length of X/Y, only
3318  leading N elements are used.
3319  CnstrLeft- optional equality constraint for model value at the left
3320  boundary (at X=0). Specify NAN (Not-a-Number) if you do
3321  not need constraint on the model value at X=0 (in C++ you
3322  can pass alglib::fp_nan as parameter, in C# it will be
3323  Double.NaN).
3324  See below, section "EQUALITY CONSTRAINTS" for more
3325  information about constraints.
3326  CnstrRight- optional equality constraint for model value at X=infinity.
3327  Specify NAN (Not-a-Number) if you do not need constraint
3328  on the model value (in C++ you can pass alglib::fp_nan as
3329  parameter, in C# it will be Double.NaN).
3330  See below, section "EQUALITY CONSTRAINTS" for more
3331  information about constraints.
3332 
3333 OUTPUT PARAMETERS:
3334  A, B, C, D- parameters of 4PL model
3335  Rep - fitting report. This structure has many fields, but ONLY
3336  ONES LISTED BELOW ARE SET:
3337  * Rep.IterationsCount - number of iterations performed
3338  * Rep.RMSError - root-mean-square error
3339  * Rep.AvgError - average absolute error
3340  * Rep.AvgRelError - average relative error (calculated for
3341  non-zero Y-values)
3342  * Rep.MaxError - maximum absolute error
3343  * Rep.R2 - coefficient of determination, R-squared. This
3344  coefficient is calculated as R2=1-RSS/TSS (in case
3345  of nonlinear regression there are multiple ways to
3346  define R2, each of them giving different results).
3347 
3348 NOTE: after you obtained coefficients, you can evaluate model with
3349  LogisticCalc4() function.
3350 
3351 NOTE: if you need better control over fitting process than provided by this
3352  function, you may use LogisticFit45X().
3353 
3354 NOTE: step is automatically scaled according to scale of parameters being
3355  fitted before we compare its length with EpsX. Thus, this function
3356  can be used to fit data with very small or very large values without
3357  changing EpsX.
3358 
3359 EQUALITY CONSTRAINTS ON PARAMETERS
3360 
3361 4PL/5PL solver supports equality constraints on model values at the left
3362 boundary (X=0) and right boundary (X=infinity). These constraints are
3363 completely optional and you can specify both of them, only one - or no
3364 constraints at all.
3365 
3366 Parameter CnstrLeft contains left constraint (or NAN for unconstrained
3367 fitting), and CnstrRight contains right one. For 4PL, left constraint
3368 ALWAYS corresponds to parameter A, and right one is ALWAYS constraint on
3369 D. That's because 4PL model is normalized in such way that B>=0.
3370 
3371 
3372  -- ALGLIB PROJECT --
3373  Copyright 14.02.2014 by Bochkanov Sergey
3374 *************************************************************************/
3375 void logisticfit4ec(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, double &a, double &b, double &c, double &d, lsfitreport &rep);
3376 
3377 
3378 /*************************************************************************
3379 This function fits five-parameter logistic (5PL) model to data provided
3380 by user. 5PL model has following form:
3381 
3382  F(x|A,B,C,D,G) = D+(A-D)/Power(1+Power(x/C,B),G)
3383 
3384 Here:
3385  * A, D - unconstrained
3386  * B - unconstrained
3387  * C>0
3388  * G>0
3389 
3390 IMPORTANT: unlike in 4PL fitting, output of this function is NOT
3391  constrained in such way that B is guaranteed to be positive.
3392  Furthermore, unlike 4PL, 5PL model is NOT symmetric with
3393  respect to B, so you can NOT transform model to equivalent one,
3394  with B having desired sign (>0 or <0).
3395 
3396 5PL fitting is implemented as follows:
3397 * we perform small number of restarts from random locations which helps to
3398  solve problem of bad local extrema. Locations are only partially random
3399  - we use input data to determine good initial guess, but we include
3400  controlled amount of randomness.
3401 * we perform Levenberg-Marquardt fitting with very tight constraints on
3402  parameters B and C - it allows us to find good initial guess for the
3403  second stage without risk of running into "flat spot". Parameter G is
3404  fixed at G=1.
3405 * second Levenberg-Marquardt round is performed without excessive
3406  constraints on B and C, but with G still equal to 1. Results from the
3407  previous round are used as initial guess.
3408 * third Levenberg-Marquardt round relaxes constraints on G and tries two
3409  different models - one with B>0 and one with B<0.
3410 * after fitting is done, we compare results with best values found so far,
3411  rewrite "best solution" if needed, and move to next random location.
3412 
3413 Overall algorithm is very stable and is not prone to bad local extrema.
3414 Furthermore, it automatically scales when input data have very large or
3415 very small range.
3416 
3417 INPUT PARAMETERS:
3418  X - array[N], stores X-values.
3419  MUST include only non-negative numbers (but may include
3420  zero values). Can be unsorted.
3421  Y - array[N], values to fit.
3422  N - number of points. If N is less than length of X/Y, only
3423  leading N elements are used.
3424 
3425 OUTPUT PARAMETERS:
3426  A,B,C,D,G- parameters of 5PL model
3427  Rep - fitting report. This structure has many fields, but ONLY
3428  ONES LISTED BELOW ARE SET:
3429  * Rep.IterationsCount - number of iterations performed
3430  * Rep.RMSError - root-mean-square error
3431  * Rep.AvgError - average absolute error
3432  * Rep.AvgRelError - average relative error (calculated for
3433  non-zero Y-values)
3434  * Rep.MaxError - maximum absolute error
3435  * Rep.R2 - coefficient of determination, R-squared. This
3436  coefficient is calculated as R2=1-RSS/TSS (in case
3437  of nonlinear regression there are multiple ways to
3438  define R2, each of them giving different results).
3439 
3440 NOTE: after you obtained coefficients, you can evaluate model with
3441  LogisticCalc5() function.
3442 
3443 NOTE: if you need better control over fitting process than provided by this
3444  function, you may use LogisticFit45X().
3445 
3446 NOTE: step is automatically scaled according to scale of parameters being
3447  fitted before we compare its length with EpsX. Thus, this function
3448  can be used to fit data with very small or very large values without
3449  changing EpsX.
3450 
3451 
3452  -- ALGLIB PROJECT --
3453  Copyright 14.02.2014 by Bochkanov Sergey
3454 *************************************************************************/
3455 void logisticfit5(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep);
3456 
3457 
3458 /*************************************************************************
3459 This function fits five-parameter logistic (5PL) model to data provided
3460 by user, subject to optional equality constraints on parameters A and D.
3461 5PL model has following form:
3462 
3463  F(x|A,B,C,D,G) = D+(A-D)/Power(1+Power(x/C,B),G)
3464 
3465 Here:
3466  * A, D - with optional equality constraints
3467  * B - unconstrained
3468  * C>0
3469  * G>0
3470 
3471 IMPORTANT: unlike in 4PL fitting, output of this function is NOT
3472  constrained in such way that B is guaranteed to be positive.
3473  Furthermore, unlike 4PL, 5PL model is NOT symmetric with
3474  respect to B, so you can NOT transform model to equivalent one,
3475  with B having desired sign (>0 or <0).
3476 
3477 5PL fitting is implemented as follows:
3478 * we perform small number of restarts from random locations which helps to
3479  solve problem of bad local extrema. Locations are only partially random
3480  - we use input data to determine good initial guess, but we include
3481  controlled amount of randomness.
3482 * we perform Levenberg-Marquardt fitting with very tight constraints on
3483  parameters B and C - it allows us to find good initial guess for the
3484  second stage without risk of running into "flat spot". Parameter G is
3485  fixed at G=1.
3486 * second Levenberg-Marquardt round is performed without excessive
3487  constraints on B and C, but with G still equal to 1. Results from the
3488  previous round are used as initial guess.
3489 * third Levenberg-Marquardt round relaxes constraints on G and tries two
3490  different models - one with B>0 and one with B<0.
3491 * after fitting is done, we compare results with best values found so far,
3492  rewrite "best solution" if needed, and move to next random location.
3493 
3494 Overall algorithm is very stable and is not prone to bad local extrema.
3495 Furthermore, it automatically scales when input data have very large or
3496 very small range.
3497 
3498 INPUT PARAMETERS:
3499  X - array[N], stores X-values.
3500  MUST include only non-negative numbers (but may include
3501  zero values). Can be unsorted.
3502  Y - array[N], values to fit.
3503  N - number of points. If N is less than length of X/Y, only
3504  leading N elements are used.
3505  CnstrLeft- optional equality constraint for model value at the left
3506  boundary (at X=0). Specify NAN (Not-a-Number) if you do
3507  not need constraint on the model value at X=0 (in C++ you
3508  can pass alglib::fp_nan as parameter, in C# it will be
3509  Double.NaN).
3510  See below, section "EQUALITY CONSTRAINTS" for more
3511  information about constraints.
3512  CnstrRight- optional equality constraint for model value at X=infinity.
3513  Specify NAN (Not-a-Number) if you do not need constraint
3514  on the model value (in C++ you can pass alglib::fp_nan as
3515  parameter, in C# it will be Double.NaN).
3516  See below, section "EQUALITY CONSTRAINTS" for more
3517  information about constraints.
3518 
3519 OUTPUT PARAMETERS:
3520  A,B,C,D,G- parameters of 5PL model
3521  Rep - fitting report. This structure has many fields, but ONLY
3522  ONES LISTED BELOW ARE SET:
3523  * Rep.IterationsCount - number of iterations performed
3524  * Rep.RMSError - root-mean-square error
3525  * Rep.AvgError - average absolute error
3526  * Rep.AvgRelError - average relative error (calculated for
3527  non-zero Y-values)
3528  * Rep.MaxError - maximum absolute error
3529  * Rep.R2 - coefficient of determination, R-squared. This
3530  coefficient is calculated as R2=1-RSS/TSS (in case
3531  of nonlinear regression there are multiple ways to
3532  define R2, each of them giving different results).
3533 
3534 NOTE: after you obtained coefficients, you can evaluate model with
3535  LogisticCalc5() function.
3536 
3537 NOTE: if you need better control over fitting process than provided by this
3538  function, you may use LogisticFit45X().
3539 
3540 NOTE: step is automatically scaled according to scale of parameters being
3541  fitted before we compare its length with EpsX. Thus, this function
3542  can be used to fit data with very small or very large values without
3543  changing EpsX.
3544 
3545 EQUALITY CONSTRAINTS ON PARAMETERS
3546 
3547 5PL solver supports equality constraints on model values at the left
3548 boundary (X=0) and right boundary (X=infinity). These constraints are
3549 completely optional and you can specify both of them, only one - or no
3550 constraints at all.
3551 
3552 Parameter CnstrLeft contains left constraint (or NAN for unconstrained
3553 fitting), and CnstrRight contains right one.
3554 
3555 Unlike 4PL one, 5PL model is NOT symmetric with respect to change in sign
3556 of B. Thus, negative B's are possible, and left constraint may constrain
3557 parameter A (for positive B's) - or parameter D (for negative B's).
3558 Similarly changes meaning of right constraint.
3559 
3560 You do not have to decide what parameter to constrain - algorithm will
3561 automatically determine correct parameters as fitting progresses. However,
3562 question highlighted above is important when you interpret fitting results.
3563 
3564 
3565  -- ALGLIB PROJECT --
3566  Copyright 14.02.2014 by Bochkanov Sergey
3567 *************************************************************************/
3568 void logisticfit5ec(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep);
3569 
3570 
3571 /*************************************************************************
3572 This is "expert" 4PL/5PL fitting function, which can be used if you need
3573 better control over fitting process than provided by LogisticFit4() or
3574 LogisticFit5().
3575 
3576 This function fits model of the form
3577 
3578  F(x|A,B,C,D) = D+(A-D)/(1+Power(x/C,B)) (4PL model)
3579 
3580 or
3581 
3582  F(x|A,B,C,D,G) = D+(A-D)/Power(1+Power(x/C,B),G) (5PL model)
3583 
3584 Here:
3585  * A, D - unconstrained
3586  * B>=0 for 4PL, unconstrained for 5PL
3587  * C>0
3588  * G>0 (if present)
3589 
3590 INPUT PARAMETERS:
3591  X - array[N], stores X-values.
3592  MUST include only non-negative numbers (but may include
3593  zero values). Can be unsorted.
3594  Y - array[N], values to fit.
3595  N - number of points. If N is less than length of X/Y, only
3596  leading N elements are used.
3597  CnstrLeft- optional equality constraint for model value at the left
3598  boundary (at X=0). Specify NAN (Not-a-Number) if you do
3599  not need constraint on the model value at X=0 (in C++ you
3600  can pass alglib::fp_nan as parameter, in C# it will be
3601  Double.NaN).
3602  See below, section "EQUALITY CONSTRAINTS" for more
3603  information about constraints.
3604  CnstrRight- optional equality constraint for model value at X=infinity.
3605  Specify NAN (Not-a-Number) if you do not need constraint
3606  on the model value (in C++ you can pass alglib::fp_nan as
3607  parameter, in C# it will be Double.NaN).
3608  See below, section "EQUALITY CONSTRAINTS" for more
3609  information about constraints.
3610  Is4PL - whether 4PL or 5PL models are fitted
3611  LambdaV - regularization coefficient, LambdaV>=0.
3612  Set it to zero unless you know what you are doing.
3613  EpsX - stopping condition (step size), EpsX>=0.
3614  Zero value means that small step is automatically chosen.
3615  See notes below for more information.
3616  RsCnt - number of repeated restarts from random points. 4PL/5PL
3617  models are prone to problem of bad local extrema. Utilizing
3618  multiple random restarts allows us to improve algorithm
3619  convergence.
3620  RsCnt>=0.
3621  Zero value means that function automatically choose small
3622  amount of restarts (recommended).
3623 
3624 OUTPUT PARAMETERS:
3625  A, B, C, D- parameters of 4PL model
3626  G - parameter of 5PL model; for Is4PL=True, G=1 is returned.
3627  Rep - fitting report. This structure has many fields, but ONLY
3628  ONES LISTED BELOW ARE SET:
3629  * Rep.IterationsCount - number of iterations performed
3630  * Rep.RMSError - root-mean-square error
3631  * Rep.AvgError - average absolute error
3632  * Rep.AvgRelError - average relative error (calculated for
3633  non-zero Y-values)
3634  * Rep.MaxError - maximum absolute error
3635  * Rep.R2 - coefficient of determination, R-squared. This
3636  coefficient is calculated as R2=1-RSS/TSS (in case
3637  of nonlinear regression there are multiple ways to
3638  define R2, each of them giving different results).
3639 
3640 NOTE: after you obtained coefficients, you can evaluate model with
3641  LogisticCalc5() function.
3642 
3643 NOTE: step is automatically scaled according to scale of parameters being
3644  fitted before we compare its length with EpsX. Thus, this function
3645  can be used to fit data with very small or very large values without
3646  changing EpsX.
3647 
3648 EQUALITY CONSTRAINTS ON PARAMETERS
3649 
3650 4PL/5PL solver supports equality constraints on model values at the left
3651 boundary (X=0) and right boundary (X=infinity). These constraints are
3652 completely optional and you can specify both of them, only one - or no
3653 constraints at all.
3654 
3655 Parameter CnstrLeft contains left constraint (or NAN for unconstrained
3656 fitting), and CnstrRight contains right one. For 4PL, left constraint
3657 ALWAYS corresponds to parameter A, and right one is ALWAYS constraint on
3658 D. That's because 4PL model is normalized in such way that B>=0.
3659 
3660 For 5PL model things are different. Unlike 4PL one, 5PL model is NOT
3661 symmetric with respect to change in sign of B. Thus, negative B's are
3662 possible, and left constraint may constrain parameter A (for positive B's)
3663 - or parameter D (for negative B's). Similarly changes meaning of right
3664 constraint.
3665 
3666 You do not have to decide what parameter to constrain - algorithm will
3667 automatically determine correct parameters as fitting progresses. However,
3668 question highlighted above is important when you interpret fitting results.
3669 
3670 
3671  -- ALGLIB PROJECT --
3672  Copyright 14.02.2014 by Bochkanov Sergey
3673 *************************************************************************/
3674 void logisticfit45x(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, const bool is4pl, const double lambdav, const double epsx, const ae_int_t rscnt, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep);
3675 
3676 
3677 /*************************************************************************
3678 Weghted rational least squares fitting using Floater-Hormann rational
3679 functions with optimal D chosen from [0,9], with constraints and
3680 individual weights.
3681 
3682 Equidistant grid with M node on [min(x),max(x)] is used to build basis
3683 functions. Different values of D are tried, optimal D (least WEIGHTED root
3684 mean square error) is chosen. Task is linear, so linear least squares
3685 solver is used. Complexity of this computational scheme is O(N*M^2)
3686 (mostly dominated by the least squares solver).
3687 
3688 SEE ALSO
3689 * BarycentricFitFloaterHormann(), "lightweight" fitting without invididual
3690  weights and constraints.
3691 
3692 COMMERCIAL EDITION OF ALGLIB:
3693 
3694  ! Commercial version of ALGLIB includes two important improvements of
3695  ! this function, which can be used from C++ and C#:
3696  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
3697  ! * multithreading support
3698  !
3699  ! Intel MKL gives approximately constant (with respect to number of
3700  ! worker threads) acceleration factor which depends on CPU being used,
3701  ! problem size and "baseline" ALGLIB edition which is used for
3702  ! comparison.
3703  !
3704  ! Speed-up provided by multithreading greatly depends on problem size
3705  ! - only large problems (number of coefficients is more than 500) can be
3706  ! efficiently multithreaded.
3707  !
3708  ! Generally, commercial ALGLIB is several times faster than open-source
3709  ! generic C edition, and many times faster than open-source C# edition.
3710  !
3711  ! We recommend you to read 'Working with commercial version' section of
3712  ! ALGLIB Reference Manual in order to find out how to use performance-
3713  ! related features provided by commercial edition of ALGLIB.
3714 
3715 INPUT PARAMETERS:
3716  X - points, array[0..N-1].
3717  Y - function values, array[0..N-1].
3718  W - weights, array[0..N-1]
3719  Each summand in square sum of approximation deviations from
3720  given values is multiplied by the square of corresponding
3721  weight. Fill it by 1's if you don't want to solve weighted
3722  task.
3723  N - number of points, N>0.
3724  XC - points where function values/derivatives are constrained,
3725  array[0..K-1].
3726  YC - values of constraints, array[0..K-1]
3727  DC - array[0..K-1], types of constraints:
3728  * DC[i]=0 means that S(XC[i])=YC[i]
3729  * DC[i]=1 means that S'(XC[i])=YC[i]
3730  SEE BELOW FOR IMPORTANT INFORMATION ON CONSTRAINTS
3731  K - number of constraints, 0<=K<M.
3732  K=0 means no constraints (XC/YC/DC are not used in such cases)
3733  M - number of basis functions ( = number_of_nodes), M>=2.
3734 
3735 OUTPUT PARAMETERS:
3736  Info- same format as in LSFitLinearWC() subroutine.
3737  * Info>0 task is solved
3738  * Info<=0 an error occured:
3739  -4 means inconvergence of internal SVD
3740  -3 means inconsistent constraints
3741  -1 means another errors in parameters passed
3742  (N<=0, for example)
3743  B - barycentric interpolant.
3744  Rep - report, same format as in LSFitLinearWC() subroutine.
3745  Following fields are set:
3746  * DBest best value of the D parameter
3747  * RMSError rms error on the (X,Y).
3748  * AvgError average error on the (X,Y).
3749  * AvgRelError average relative error on the non-zero Y
3750  * MaxError maximum error
3751  NON-WEIGHTED ERRORS ARE CALCULATED
3752 
3753 IMPORTANT:
3754  this subroutine doesn't calculate task's condition number for K<>0.
3755 
3756 SETTING CONSTRAINTS - DANGERS AND OPPORTUNITIES:
3757 
3758 Setting constraints can lead to undesired results, like ill-conditioned
3759 behavior, or inconsistency being detected. From the other side, it allows
3760 us to improve quality of the fit. Here we summarize our experience with
3761 constrained barycentric interpolants:
3762 * excessive constraints can be inconsistent. Floater-Hormann basis
3763  functions aren't as flexible as splines (although they are very smooth).
3764 * the more evenly constraints are spread across [min(x),max(x)], the more
3765  chances that they will be consistent
3766 * the greater is M (given fixed constraints), the more chances that
3767  constraints will be consistent
3768 * in the general case, consistency of constraints IS NOT GUARANTEED.
3769 * in the several special cases, however, we CAN guarantee consistency.
3770 * one of this cases is constraints on the function VALUES at the interval
3771  boundaries. Note that consustency of the constraints on the function
3772  DERIVATIVES is NOT guaranteed (you can use in such cases cubic splines
3773  which are more flexible).
3774 * another special case is ONE constraint on the function value (OR, but
3775  not AND, derivative) anywhere in the interval
3776 
3777 Our final recommendation is to use constraints WHEN AND ONLY WHEN you
3778 can't solve your task without them. Anything beyond special cases given
3779 above is not guaranteed and may result in inconsistency.
3780 
3781  -- ALGLIB PROJECT --
3782  Copyright 18.08.2009 by Bochkanov Sergey
3783 *************************************************************************/
3784 void barycentricfitfloaterhormannwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep);
3786 
3787 
3788 /*************************************************************************
3789 Rational least squares fitting using Floater-Hormann rational functions
3790 with optimal D chosen from [0,9].
3791 
3792 Equidistant grid with M node on [min(x),max(x)] is used to build basis
3793 functions. Different values of D are tried, optimal D (least root mean
3794 square error) is chosen. Task is linear, so linear least squares solver
3795 is used. Complexity of this computational scheme is O(N*M^2) (mostly
3796 dominated by the least squares solver).
3797 
3798 COMMERCIAL EDITION OF ALGLIB:
3799 
3800  ! Commercial version of ALGLIB includes two important improvements of
3801  ! this function, which can be used from C++ and C#:
3802  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
3803  ! * multithreading support
3804  !
3805  ! Intel MKL gives approximately constant (with respect to number of
3806  ! worker threads) acceleration factor which depends on CPU being used,
3807  ! problem size and "baseline" ALGLIB edition which is used for
3808  ! comparison.
3809  !
3810  ! Speed-up provided by multithreading greatly depends on problem size
3811  ! - only large problems (number of coefficients is more than 500) can be
3812  ! efficiently multithreaded.
3813  !
3814  ! Generally, commercial ALGLIB is several times faster than open-source
3815  ! generic C edition, and many times faster than open-source C# edition.
3816  !
3817  ! We recommend you to read 'Working with commercial version' section of
3818  ! ALGLIB Reference Manual in order to find out how to use performance-
3819  ! related features provided by commercial edition of ALGLIB.
3820 
3821 INPUT PARAMETERS:
3822  X - points, array[0..N-1].
3823  Y - function values, array[0..N-1].
3824  N - number of points, N>0.
3825  M - number of basis functions ( = number_of_nodes), M>=2.
3826 
3827 OUTPUT PARAMETERS:
3828  Info- same format as in LSFitLinearWC() subroutine.
3829  * Info>0 task is solved
3830  * Info<=0 an error occured:
3831  -4 means inconvergence of internal SVD
3832  -3 means inconsistent constraints
3833  B - barycentric interpolant.
3834  Rep - report, same format as in LSFitLinearWC() subroutine.
3835  Following fields are set:
3836  * DBest best value of the D parameter
3837  * RMSError rms error on the (X,Y).
3838  * AvgError average error on the (X,Y).
3839  * AvgRelError average relative error on the non-zero Y
3840  * MaxError maximum error
3841  NON-WEIGHTED ERRORS ARE CALCULATED
3842 
3843  -- ALGLIB PROJECT --
3844  Copyright 18.08.2009 by Bochkanov Sergey
3845 *************************************************************************/
3848 
3849 
3850 /*************************************************************************
3851 Fitting by penalized cubic spline.
3852 
3853 Equidistant grid with M nodes on [min(x,xc),max(x,xc)] is used to build
3854 basis functions. Basis functions are cubic splines with natural boundary
3855 conditions. Problem is regularized by adding non-linearity penalty to the
3856 usual least squares penalty function:
3857 
3858  S(x) = arg min { LS + P }, where
3859  LS = SUM { w[i]^2*(y[i] - S(x[i]))^2 } - least squares penalty
3860  P = C*10^rho*integral{ S''(x)^2*dx } - non-linearity penalty
3861  rho - tunable constant given by user
3862  C - automatically determined scale parameter,
3863  makes penalty invariant with respect to scaling of X, Y, W.
3864 
3865 COMMERCIAL EDITION OF ALGLIB:
3866 
3867  ! Commercial version of ALGLIB includes two important improvements of
3868  ! this function, which can be used from C++ and C#:
3869  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
3870  ! * multithreading support
3871  !
3872  ! Intel MKL gives approximately constant (with respect to number of
3873  ! worker threads) acceleration factor which depends on CPU being used,
3874  ! problem size and "baseline" ALGLIB edition which is used for
3875  ! comparison.
3876  !
3877  ! Speed-up provided by multithreading greatly depends on problem size
3878  ! - only large problems (number of coefficients is more than 500) can be
3879  ! efficiently multithreaded.
3880  !
3881  ! Generally, commercial ALGLIB is several times faster than open-source
3882  ! generic C edition, and many times faster than open-source C# edition.
3883  !
3884  ! We recommend you to read 'Working with commercial version' section of
3885  ! ALGLIB Reference Manual in order to find out how to use performance-
3886  ! related features provided by commercial edition of ALGLIB.
3887 
3888 INPUT PARAMETERS:
3889  X - points, array[0..N-1].
3890  Y - function values, array[0..N-1].
3891  N - number of points (optional):
3892  * N>0
3893  * if given, only first N elements of X/Y are processed
3894  * if not given, automatically determined from X/Y sizes
3895  M - number of basis functions ( = number_of_nodes), M>=4.
3896  Rho - regularization constant passed by user. It penalizes
3897  nonlinearity in the regression spline. It is logarithmically
3898  scaled, i.e. actual value of regularization constant is
3899  calculated as 10^Rho. It is automatically scaled so that:
3900  * Rho=2.0 corresponds to moderate amount of nonlinearity
3901  * generally, it should be somewhere in the [-8.0,+8.0]
3902  If you do not want to penalize nonlineary,
3903  pass small Rho. Values as low as -15 should work.
3904 
3905 OUTPUT PARAMETERS:
3906  Info- same format as in LSFitLinearWC() subroutine.
3907  * Info>0 task is solved
3908  * Info<=0 an error occured:
3909  -4 means inconvergence of internal SVD or
3910  Cholesky decomposition; problem may be
3911  too ill-conditioned (very rare)
3912  S - spline interpolant.
3913  Rep - Following fields are set:
3914  * RMSError rms error on the (X,Y).
3915  * AvgError average error on the (X,Y).
3916  * AvgRelError average relative error on the non-zero Y
3917  * MaxError maximum error
3918  NON-WEIGHTED ERRORS ARE CALCULATED
3919 
3920 IMPORTANT:
3921  this subroitine doesn't calculate task's condition number for K<>0.
3922 
3923 NOTE 1: additional nodes are added to the spline outside of the fitting
3924 interval to force linearity when x<min(x,xc) or x>max(x,xc). It is done
3925 for consistency - we penalize non-linearity at [min(x,xc),max(x,xc)], so
3926 it is natural to force linearity outside of this interval.
3927 
3928 NOTE 2: function automatically sorts points, so caller may pass unsorted
3929 array.
3930 
3931  -- ALGLIB PROJECT --
3932  Copyright 18.08.2009 by Bochkanov Sergey
3933 *************************************************************************/
3934 void spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
3935 void smp_spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
3936 void spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
3937 void smp_spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
3938 
3939 
3940 /*************************************************************************
3941 Weighted fitting by penalized cubic spline.
3942 
3943 Equidistant grid with M nodes on [min(x,xc),max(x,xc)] is used to build
3944 basis functions. Basis functions are cubic splines with natural boundary
3945 conditions. Problem is regularized by adding non-linearity penalty to the
3946 usual least squares penalty function:
3947 
3948  S(x) = arg min { LS + P }, where
3949  LS = SUM { w[i]^2*(y[i] - S(x[i]))^2 } - least squares penalty
3950  P = C*10^rho*integral{ S''(x)^2*dx } - non-linearity penalty
3951  rho - tunable constant given by user
3952  C - automatically determined scale parameter,
3953  makes penalty invariant with respect to scaling of X, Y, W.
3954 
3955 COMMERCIAL EDITION OF ALGLIB:
3956 
3957  ! Commercial version of ALGLIB includes two important improvements of
3958  ! this function, which can be used from C++ and C#:
3959  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
3960  ! * multithreading support
3961  !
3962  ! Intel MKL gives approximately constant (with respect to number of
3963  ! worker threads) acceleration factor which depends on CPU being used,
3964  ! problem size and "baseline" ALGLIB edition which is used for
3965  ! comparison.
3966  !
3967  ! Speed-up provided by multithreading greatly depends on problem size
3968  ! - only large problems (number of coefficients is more than 500) can be
3969  ! efficiently multithreaded.
3970  !
3971  ! Generally, commercial ALGLIB is several times faster than open-source
3972  ! generic C edition, and many times faster than open-source C# edition.
3973  !
3974  ! We recommend you to read 'Working with commercial version' section of
3975  ! ALGLIB Reference Manual in order to find out how to use performance-
3976  ! related features provided by commercial edition of ALGLIB.
3977 
3978 INPUT PARAMETERS:
3979  X - points, array[0..N-1].
3980  Y - function values, array[0..N-1].
3981  W - weights, array[0..N-1]
3982  Each summand in square sum of approximation deviations from
3983  given values is multiplied by the square of corresponding
3984  weight. Fill it by 1's if you don't want to solve weighted
3985  problem.
3986  N - number of points (optional):
3987  * N>0
3988  * if given, only first N elements of X/Y/W are processed
3989  * if not given, automatically determined from X/Y/W sizes
3990  M - number of basis functions ( = number_of_nodes), M>=4.
3991  Rho - regularization constant passed by user. It penalizes
3992  nonlinearity in the regression spline. It is logarithmically
3993  scaled, i.e. actual value of regularization constant is
3994  calculated as 10^Rho. It is automatically scaled so that:
3995  * Rho=2.0 corresponds to moderate amount of nonlinearity
3996  * generally, it should be somewhere in the [-8.0,+8.0]
3997  If you do not want to penalize nonlineary,
3998  pass small Rho. Values as low as -15 should work.
3999 
4000 OUTPUT PARAMETERS:
4001  Info- same format as in LSFitLinearWC() subroutine.
4002  * Info>0 task is solved
4003  * Info<=0 an error occured:
4004  -4 means inconvergence of internal SVD or
4005  Cholesky decomposition; problem may be
4006  too ill-conditioned (very rare)
4007  S - spline interpolant.
4008  Rep - Following fields are set:
4009  * RMSError rms error on the (X,Y).
4010  * AvgError average error on the (X,Y).
4011  * AvgRelError average relative error on the non-zero Y
4012  * MaxError maximum error
4013  NON-WEIGHTED ERRORS ARE CALCULATED
4014 
4015 IMPORTANT:
4016  this subroitine doesn't calculate task's condition number for K<>0.
4017 
4018 NOTE 1: additional nodes are added to the spline outside of the fitting
4019 interval to force linearity when x<min(x,xc) or x>max(x,xc). It is done
4020 for consistency - we penalize non-linearity at [min(x,xc),max(x,xc)], so
4021 it is natural to force linearity outside of this interval.
4022 
4023 NOTE 2: function automatically sorts points, so caller may pass unsorted
4024 array.
4025 
4026  -- ALGLIB PROJECT --
4027  Copyright 19.10.2010 by Bochkanov Sergey
4028 *************************************************************************/
4029 void spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4030 void smp_spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4031 void spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4032 void smp_spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4033 
4034 
4035 /*************************************************************************
4036 Weighted fitting by cubic spline, with constraints on function values or
4037 derivatives.
4038 
4039 Equidistant grid with M-2 nodes on [min(x,xc),max(x,xc)] is used to build
4040 basis functions. Basis functions are cubic splines with continuous second
4041 derivatives and non-fixed first derivatives at interval ends. Small
4042 regularizing term is used when solving constrained tasks (to improve
4043 stability).
4044 
4045 Task is linear, so linear least squares solver is used. Complexity of this
4046 computational scheme is O(N*M^2), mostly dominated by least squares solver
4047 
4048 SEE ALSO
4049  Spline1DFitHermiteWC() - fitting by Hermite splines (more flexible,
4050  less smooth)
4051  Spline1DFitCubic() - "lightweight" fitting by cubic splines,
4052  without invididual weights and constraints
4053 
4054 COMMERCIAL EDITION OF ALGLIB:
4055 
4056  ! Commercial version of ALGLIB includes two important improvements of
4057  ! this function, which can be used from C++ and C#:
4058  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
4059  ! * multithreading support
4060  !
4061  ! Intel MKL gives approximately constant (with respect to number of
4062  ! worker threads) acceleration factor which depends on CPU being used,
4063  ! problem size and "baseline" ALGLIB edition which is used for
4064  ! comparison.
4065  !
4066  ! Speed-up provided by multithreading greatly depends on problem size
4067  ! - only large problems (number of coefficients is more than 500) can be
4068  ! efficiently multithreaded.
4069  !
4070  ! Generally, commercial ALGLIB is several times faster than open-source
4071  ! generic C edition, and many times faster than open-source C# edition.
4072  !
4073  ! We recommend you to read 'Working with commercial version' section of
4074  ! ALGLIB Reference Manual in order to find out how to use performance-
4075  ! related features provided by commercial edition of ALGLIB.
4076 
4077 INPUT PARAMETERS:
4078  X - points, array[0..N-1].
4079  Y - function values, array[0..N-1].
4080  W - weights, array[0..N-1]
4081  Each summand in square sum of approximation deviations from
4082  given values is multiplied by the square of corresponding
4083  weight. Fill it by 1's if you don't want to solve weighted
4084  task.
4085  N - number of points (optional):
4086  * N>0
4087  * if given, only first N elements of X/Y/W are processed
4088  * if not given, automatically determined from X/Y/W sizes
4089  XC - points where spline values/derivatives are constrained,
4090  array[0..K-1].
4091  YC - values of constraints, array[0..K-1]
4092  DC - array[0..K-1], types of constraints:
4093  * DC[i]=0 means that S(XC[i])=YC[i]
4094  * DC[i]=1 means that S'(XC[i])=YC[i]
4095  SEE BELOW FOR IMPORTANT INFORMATION ON CONSTRAINTS
4096  K - number of constraints (optional):
4097  * 0<=K<M.
4098  * K=0 means no constraints (XC/YC/DC are not used)
4099  * if given, only first K elements of XC/YC/DC are used
4100  * if not given, automatically determined from XC/YC/DC
4101  M - number of basis functions ( = number_of_nodes+2), M>=4.
4102 
4103 OUTPUT PARAMETERS:
4104  Info- same format as in LSFitLinearWC() subroutine.
4105  * Info>0 task is solved
4106  * Info<=0 an error occured:
4107  -4 means inconvergence of internal SVD
4108  -3 means inconsistent constraints
4109  S - spline interpolant.
4110  Rep - report, same format as in LSFitLinearWC() subroutine.
4111  Following fields are set:
4112  * RMSError rms error on the (X,Y).
4113  * AvgError average error on the (X,Y).
4114  * AvgRelError average relative error on the non-zero Y
4115  * MaxError maximum error
4116  NON-WEIGHTED ERRORS ARE CALCULATED
4117 
4118 IMPORTANT:
4119  this subroitine doesn't calculate task's condition number for K<>0.
4120 
4121 
4122 ORDER OF POINTS
4123 
4124 Subroutine automatically sorts points, so caller may pass unsorted array.
4125 
4126 SETTING CONSTRAINTS - DANGERS AND OPPORTUNITIES:
4127 
4128 Setting constraints can lead to undesired results, like ill-conditioned
4129 behavior, or inconsistency being detected. From the other side, it allows
4130 us to improve quality of the fit. Here we summarize our experience with
4131 constrained regression splines:
4132 * excessive constraints can be inconsistent. Splines are piecewise cubic
4133  functions, and it is easy to create an example, where large number of
4134  constraints concentrated in small area will result in inconsistency.
4135  Just because spline is not flexible enough to satisfy all of them. And
4136  same constraints spread across the [min(x),max(x)] will be perfectly
4137  consistent.
4138 * the more evenly constraints are spread across [min(x),max(x)], the more
4139  chances that they will be consistent
4140 * the greater is M (given fixed constraints), the more chances that
4141  constraints will be consistent
4142 * in the general case, consistency of constraints IS NOT GUARANTEED.
4143 * in the several special cases, however, we CAN guarantee consistency.
4144 * one of this cases is constraints on the function values AND/OR its
4145  derivatives at the interval boundaries.
4146 * another special case is ONE constraint on the function value (OR, but
4147  not AND, derivative) anywhere in the interval
4148 
4149 Our final recommendation is to use constraints WHEN AND ONLY WHEN you
4150 can't solve your task without them. Anything beyond special cases given
4151 above is not guaranteed and may result in inconsistency.
4152 
4153 
4154  -- ALGLIB PROJECT --
4155  Copyright 18.08.2009 by Bochkanov Sergey
4156 *************************************************************************/
4157 void spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4158 void smp_spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4159 void spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4160 void smp_spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4161 
4162 
4163 /*************************************************************************
4164 Weighted fitting by Hermite spline, with constraints on function values
4165 or first derivatives.
4166 
4167 Equidistant grid with M nodes on [min(x,xc),max(x,xc)] is used to build
4168 basis functions. Basis functions are Hermite splines. Small regularizing
4169 term is used when solving constrained tasks (to improve stability).
4170 
4171 Task is linear, so linear least squares solver is used. Complexity of this
4172 computational scheme is O(N*M^2), mostly dominated by least squares solver
4173 
4174 SEE ALSO
4175  Spline1DFitCubicWC() - fitting by Cubic splines (less flexible,
4176  more smooth)
4177  Spline1DFitHermite() - "lightweight" Hermite fitting, without
4178  invididual weights and constraints
4179 
4180 COMMERCIAL EDITION OF ALGLIB:
4181 
4182  ! Commercial version of ALGLIB includes two important improvements of
4183  ! this function, which can be used from C++ and C#:
4184  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
4185  ! * multithreading support
4186  !
4187  ! Intel MKL gives approximately constant (with respect to number of
4188  ! worker threads) acceleration factor which depends on CPU being used,
4189  ! problem size and "baseline" ALGLIB edition which is used for
4190  ! comparison.
4191  !
4192  ! Speed-up provided by multithreading greatly depends on problem size
4193  ! - only large problems (number of coefficients is more than 500) can be
4194  ! efficiently multithreaded.
4195  !
4196  ! Generally, commercial ALGLIB is several times faster than open-source
4197  ! generic C edition, and many times faster than open-source C# edition.
4198  !
4199  ! We recommend you to read 'Working with commercial version' section of
4200  ! ALGLIB Reference Manual in order to find out how to use performance-
4201  ! related features provided by commercial edition of ALGLIB.
4202 
4203 INPUT PARAMETERS:
4204  X - points, array[0..N-1].
4205  Y - function values, array[0..N-1].
4206  W - weights, array[0..N-1]
4207  Each summand in square sum of approximation deviations from
4208  given values is multiplied by the square of corresponding
4209  weight. Fill it by 1's if you don't want to solve weighted
4210  task.
4211  N - number of points (optional):
4212  * N>0
4213  * if given, only first N elements of X/Y/W are processed
4214  * if not given, automatically determined from X/Y/W sizes
4215  XC - points where spline values/derivatives are constrained,
4216  array[0..K-1].
4217  YC - values of constraints, array[0..K-1]
4218  DC - array[0..K-1], types of constraints:
4219  * DC[i]=0 means that S(XC[i])=YC[i]
4220  * DC[i]=1 means that S'(XC[i])=YC[i]
4221  SEE BELOW FOR IMPORTANT INFORMATION ON CONSTRAINTS
4222  K - number of constraints (optional):
4223  * 0<=K<M.
4224  * K=0 means no constraints (XC/YC/DC are not used)
4225  * if given, only first K elements of XC/YC/DC are used
4226  * if not given, automatically determined from XC/YC/DC
4227  M - number of basis functions (= 2 * number of nodes),
4228  M>=4,
4229  M IS EVEN!
4230 
4231 OUTPUT PARAMETERS:
4232  Info- same format as in LSFitLinearW() subroutine:
4233  * Info>0 task is solved
4234  * Info<=0 an error occured:
4235  -4 means inconvergence of internal SVD
4236  -3 means inconsistent constraints
4237  -2 means odd M was passed (which is not supported)
4238  -1 means another errors in parameters passed
4239  (N<=0, for example)
4240  S - spline interpolant.
4241  Rep - report, same format as in LSFitLinearW() subroutine.
4242  Following fields are set:
4243  * RMSError rms error on the (X,Y).
4244  * AvgError average error on the (X,Y).
4245  * AvgRelError average relative error on the non-zero Y
4246  * MaxError maximum error
4247  NON-WEIGHTED ERRORS ARE CALCULATED
4248 
4249 IMPORTANT:
4250  this subroitine doesn't calculate task's condition number for K<>0.
4251 
4252 IMPORTANT:
4253  this subroitine supports only even M's
4254 
4255 
4256 ORDER OF POINTS
4257 
4258 Subroutine automatically sorts points, so caller may pass unsorted array.
4259 
4260 SETTING CONSTRAINTS - DANGERS AND OPPORTUNITIES:
4261 
4262 Setting constraints can lead to undesired results, like ill-conditioned
4263 behavior, or inconsistency being detected. From the other side, it allows
4264 us to improve quality of the fit. Here we summarize our experience with
4265 constrained regression splines:
4266 * excessive constraints can be inconsistent. Splines are piecewise cubic
4267  functions, and it is easy to create an example, where large number of
4268  constraints concentrated in small area will result in inconsistency.
4269  Just because spline is not flexible enough to satisfy all of them. And
4270  same constraints spread across the [min(x),max(x)] will be perfectly
4271  consistent.
4272 * the more evenly constraints are spread across [min(x),max(x)], the more
4273  chances that they will be consistent
4274 * the greater is M (given fixed constraints), the more chances that
4275  constraints will be consistent
4276 * in the general case, consistency of constraints is NOT GUARANTEED.
4277 * in the several special cases, however, we can guarantee consistency.
4278 * one of this cases is M>=4 and constraints on the function value
4279  (AND/OR its derivative) at the interval boundaries.
4280 * another special case is M>=4 and ONE constraint on the function value
4281  (OR, BUT NOT AND, derivative) anywhere in [min(x),max(x)]
4282 
4283 Our final recommendation is to use constraints WHEN AND ONLY when you
4284 can't solve your task without them. Anything beyond special cases given
4285 above is not guaranteed and may result in inconsistency.
4286 
4287  -- ALGLIB PROJECT --
4288  Copyright 18.08.2009 by Bochkanov Sergey
4289 *************************************************************************/
4290 void spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4291 void smp_spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4292 void spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
4294 
4295 
4296 /*************************************************************************
4297 Least squares fitting by cubic spline.
4298 
4299 This subroutine is "lightweight" alternative for more complex and feature-
4300 rich Spline1DFitCubicWC(). See Spline1DFitCubicWC() for more information
4301 about subroutine parameters (we don't duplicate it here because of length)
4302 
4303 COMMERCIAL EDITION OF ALGLIB:
4304 
4305  ! Commercial version of ALGLIB includes two important improvements of
4306  ! this function, which can be used from C++ and C#:
4307  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
4308  ! * multithreading support
4309  !
4310  ! Intel MKL gives approximately constant (with respect to number of
4311  ! worker threads) acceleration factor which depends on CPU being used,
4312  ! problem size and "baseline" ALGLIB edition which is used for
4313  ! comparison.
4314  !
4315  ! Speed-up provided by multithreading greatly depends on problem size
4316  ! - only large problems (number of coefficients is more than 500) can be
4317  ! efficiently multithreaded.
4318  !
4319  ! Generally, commercial ALGLIB is several times faster than open-source
4320  ! generic C edition, and many times faster than open-source C# edition.
4321  !
4322  ! We recommend you to read 'Working with commercial version' section of
4323  ! ALGLIB Reference Manual in order to find out how to use performance-
4324  ! related features provided by commercial edition of ALGLIB.
4325 
4326  -- ALGLIB PROJECT --
4327  Copyright 18.08.2009 by Bochkanov Sergey
4328 *************************************************************************/
4333 
4334 
4335 /*************************************************************************
4336 Least squares fitting by Hermite spline.
4337 
4338 This subroutine is "lightweight" alternative for more complex and feature-
4339 rich Spline1DFitHermiteWC(). See Spline1DFitHermiteWC() description for
4340 more information about subroutine parameters (we don't duplicate it here
4341 because of length).
4342 
4343 COMMERCIAL EDITION OF ALGLIB:
4344 
4345  ! Commercial version of ALGLIB includes two important improvements of
4346  ! this function, which can be used from C++ and C#:
4347  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
4348  ! * multithreading support
4349  !
4350  ! Intel MKL gives approximately constant (with respect to number of
4351  ! worker threads) acceleration factor which depends on CPU being used,
4352  ! problem size and "baseline" ALGLIB edition which is used for
4353  ! comparison.
4354  !
4355  ! Speed-up provided by multithreading greatly depends on problem size
4356  ! - only large problems (number of coefficients is more than 500) can be
4357  ! efficiently multithreaded.
4358  !
4359  ! Generally, commercial ALGLIB is several times faster than open-source
4360  ! generic C edition, and many times faster than open-source C# edition.
4361  !
4362  ! We recommend you to read 'Working with commercial version' section of
4363  ! ALGLIB Reference Manual in order to find out how to use performance-
4364  ! related features provided by commercial edition of ALGLIB.
4365 
4366  -- ALGLIB PROJECT --
4367  Copyright 18.08.2009 by Bochkanov Sergey
4368 *************************************************************************/
4373 
4374 
4375 /*************************************************************************
4376 Weighted linear least squares fitting.
4377 
4378 QR decomposition is used to reduce task to MxM, then triangular solver or
4379 SVD-based solver is used depending on condition number of the system. It
4380 allows to maximize speed and retain decent accuracy.
4381 
4382 IMPORTANT: if you want to perform polynomial fitting, it may be more
4383  convenient to use PolynomialFit() function. This function gives
4384  best results on polynomial problems and solves numerical
4385  stability issues which arise when you fit high-degree
4386  polynomials to your data.
4387 
4388 COMMERCIAL EDITION OF ALGLIB:
4389 
4390  ! Commercial version of ALGLIB includes two important improvements of
4391  ! this function, which can be used from C++ and C#:
4392  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
4393  ! * multithreading support
4394  !
4395  ! Intel MKL gives approximately constant (with respect to number of
4396  ! worker threads) acceleration factor which depends on CPU being used,
4397  ! problem size and "baseline" ALGLIB edition which is used for
4398  ! comparison.
4399  !
4400  ! Speed-up provided by multithreading greatly depends on problem size
4401  ! - only large problems (number of coefficients is more than 500) can be
4402  ! efficiently multithreaded.
4403  !
4404  ! Generally, commercial ALGLIB is several times faster than open-source
4405  ! generic C edition, and many times faster than open-source C# edition.
4406  !
4407  ! We recommend you to read 'Working with commercial version' section of
4408  ! ALGLIB Reference Manual in order to find out how to use performance-
4409  ! related features provided by commercial edition of ALGLIB.
4410 
4411 INPUT PARAMETERS:
4412  Y - array[0..N-1] Function values in N points.
4413  W - array[0..N-1] Weights corresponding to function values.
4414  Each summand in square sum of approximation deviations
4415  from given values is multiplied by the square of
4416  corresponding weight.
4417  FMatrix - a table of basis functions values, array[0..N-1, 0..M-1].
4418  FMatrix[I, J] - value of J-th basis function in I-th point.
4419  N - number of points used. N>=1.
4420  M - number of basis functions, M>=1.
4421 
4422 OUTPUT PARAMETERS:
4423  Info - error code:
4424  * -4 internal SVD decomposition subroutine failed (very
4425  rare and for degenerate systems only)
4426  * -1 incorrect N/M were specified
4427  * 1 task is solved
4428  C - decomposition coefficients, array[0..M-1]
4429  Rep - fitting report. Following fields are set:
4430  * Rep.TaskRCond reciprocal of condition number
4431  * R2 non-adjusted coefficient of determination
4432  (non-weighted)
4433  * RMSError rms error on the (X,Y).
4434  * AvgError average error on the (X,Y).
4435  * AvgRelError average relative error on the non-zero Y
4436  * MaxError maximum error
4437  NON-WEIGHTED ERRORS ARE CALCULATED
4438 
4439 ERRORS IN PARAMETERS
4440 
4441 This solver also calculates different kinds of errors in parameters and
4442 fills corresponding fields of report:
4443 * Rep.CovPar covariance matrix for parameters, array[K,K].
4444 * Rep.ErrPar errors in parameters, array[K],
4445  errpar = sqrt(diag(CovPar))
4446 * Rep.ErrCurve vector of fit errors - standard deviations of empirical
4447  best-fit curve from "ideal" best-fit curve built with
4448  infinite number of samples, array[N].
4449  errcurve = sqrt(diag(F*CovPar*F')),
4450  where F is functions matrix.
4451 * Rep.Noise vector of per-point estimates of noise, array[N]
4452 
4453 NOTE: noise in the data is estimated as follows:
4454  * for fitting without user-supplied weights all points are
4455  assumed to have same level of noise, which is estimated from
4456  the data
4457  * for fitting with user-supplied weights we assume that noise
4458  level in I-th point is inversely proportional to Ith weight.
4459  Coefficient of proportionality is estimated from the data.
4460 
4461 NOTE: we apply small amount of regularization when we invert squared
4462  Jacobian and calculate covariance matrix. It guarantees that
4463  algorithm won't divide by zero during inversion, but skews
4464  error estimates a bit (fractional error is about 10^-9).
4465 
4466  However, we believe that this difference is insignificant for
4467  all practical purposes except for the situation when you want
4468  to compare ALGLIB results with "reference" implementation up
4469  to the last significant digit.
4470 
4471 NOTE: covariance matrix is estimated using correction for degrees
4472  of freedom (covariances are divided by N-M instead of dividing
4473  by N).
4474 
4475  -- ALGLIB --
4476  Copyright 17.08.2009 by Bochkanov Sergey
4477 *************************************************************************/
4478 void lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4479 void smp_lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4480 void lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4481 void smp_lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4482 
4483 
4484 /*************************************************************************
4485 Weighted constained linear least squares fitting.
4486 
4487 This is variation of LSFitLinearW(), which searchs for min|A*x=b| given
4488 that K additional constaints C*x=bc are satisfied. It reduces original
4489 task to modified one: min|B*y-d| WITHOUT constraints, then LSFitLinearW()
4490 is called.
4491 
4492 IMPORTANT: if you want to perform polynomial fitting, it may be more
4493  convenient to use PolynomialFit() function. This function gives
4494  best results on polynomial problems and solves numerical
4495  stability issues which arise when you fit high-degree
4496  polynomials to your data.
4497 
4498 COMMERCIAL EDITION OF ALGLIB:
4499 
4500  ! Commercial version of ALGLIB includes two important improvements of
4501  ! this function, which can be used from C++ and C#:
4502  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
4503  ! * multithreading support
4504  !
4505  ! Intel MKL gives approximately constant (with respect to number of
4506  ! worker threads) acceleration factor which depends on CPU being used,
4507  ! problem size and "baseline" ALGLIB edition which is used for
4508  ! comparison.
4509  !
4510  ! Speed-up provided by multithreading greatly depends on problem size
4511  ! - only large problems (number of coefficients is more than 500) can be
4512  ! efficiently multithreaded.
4513  !
4514  ! Generally, commercial ALGLIB is several times faster than open-source
4515  ! generic C edition, and many times faster than open-source C# edition.
4516  !
4517  ! We recommend you to read 'Working with commercial version' section of
4518  ! ALGLIB Reference Manual in order to find out how to use performance-
4519  ! related features provided by commercial edition of ALGLIB.
4520 
4521 INPUT PARAMETERS:
4522  Y - array[0..N-1] Function values in N points.
4523  W - array[0..N-1] Weights corresponding to function values.
4524  Each summand in square sum of approximation deviations
4525  from given values is multiplied by the square of
4526  corresponding weight.
4527  FMatrix - a table of basis functions values, array[0..N-1, 0..M-1].
4528  FMatrix[I,J] - value of J-th basis function in I-th point.
4529  CMatrix - a table of constaints, array[0..K-1,0..M].
4530  I-th row of CMatrix corresponds to I-th linear constraint:
4531  CMatrix[I,0]*C[0] + ... + CMatrix[I,M-1]*C[M-1] = CMatrix[I,M]
4532  N - number of points used. N>=1.
4533  M - number of basis functions, M>=1.
4534  K - number of constraints, 0 <= K < M
4535  K=0 corresponds to absence of constraints.
4536 
4537 OUTPUT PARAMETERS:
4538  Info - error code:
4539  * -4 internal SVD decomposition subroutine failed (very
4540  rare and for degenerate systems only)
4541  * -3 either too many constraints (M or more),
4542  degenerate constraints (some constraints are
4543  repetead twice) or inconsistent constraints were
4544  specified.
4545  * 1 task is solved
4546  C - decomposition coefficients, array[0..M-1]
4547  Rep - fitting report. Following fields are set:
4548  * R2 non-adjusted coefficient of determination
4549  (non-weighted)
4550  * RMSError rms error on the (X,Y).
4551  * AvgError average error on the (X,Y).
4552  * AvgRelError average relative error on the non-zero Y
4553  * MaxError maximum error
4554  NON-WEIGHTED ERRORS ARE CALCULATED
4555 
4556 IMPORTANT:
4557  this subroitine doesn't calculate task's condition number for K<>0.
4558 
4559 ERRORS IN PARAMETERS
4560 
4561 This solver also calculates different kinds of errors in parameters and
4562 fills corresponding fields of report:
4563 * Rep.CovPar covariance matrix for parameters, array[K,K].
4564 * Rep.ErrPar errors in parameters, array[K],
4565  errpar = sqrt(diag(CovPar))
4566 * Rep.ErrCurve vector of fit errors - standard deviations of empirical
4567  best-fit curve from "ideal" best-fit curve built with
4568  infinite number of samples, array[N].
4569  errcurve = sqrt(diag(F*CovPar*F')),
4570  where F is functions matrix.
4571 * Rep.Noise vector of per-point estimates of noise, array[N]
4572 
4573 IMPORTANT: errors in parameters are calculated without taking into
4574  account boundary/linear constraints! Presence of constraints
4575  changes distribution of errors, but there is no easy way to
4576  account for constraints when you calculate covariance matrix.
4577 
4578 NOTE: noise in the data is estimated as follows:
4579  * for fitting without user-supplied weights all points are
4580  assumed to have same level of noise, which is estimated from
4581  the data
4582  * for fitting with user-supplied weights we assume that noise
4583  level in I-th point is inversely proportional to Ith weight.
4584  Coefficient of proportionality is estimated from the data.
4585 
4586 NOTE: we apply small amount of regularization when we invert squared
4587  Jacobian and calculate covariance matrix. It guarantees that
4588  algorithm won't divide by zero during inversion, but skews
4589  error estimates a bit (fractional error is about 10^-9).
4590 
4591  However, we believe that this difference is insignificant for
4592  all practical purposes except for the situation when you want
4593  to compare ALGLIB results with "reference" implementation up
4594  to the last significant digit.
4595 
4596 NOTE: covariance matrix is estimated using correction for degrees
4597  of freedom (covariances are divided by N-M instead of dividing
4598  by N).
4599 
4600  -- ALGLIB --
4601  Copyright 07.09.2009 by Bochkanov Sergey
4602 *************************************************************************/
4603 void lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4604 void smp_lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4605 void lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4606 void smp_lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4607 
4608 
4609 /*************************************************************************
4610 Linear least squares fitting.
4611 
4612 QR decomposition is used to reduce task to MxM, then triangular solver or
4613 SVD-based solver is used depending on condition number of the system. It
4614 allows to maximize speed and retain decent accuracy.
4615 
4616 IMPORTANT: if you want to perform polynomial fitting, it may be more
4617  convenient to use PolynomialFit() function. This function gives
4618  best results on polynomial problems and solves numerical
4619  stability issues which arise when you fit high-degree
4620  polynomials to your data.
4621 
4622 COMMERCIAL EDITION OF ALGLIB:
4623 
4624  ! Commercial version of ALGLIB includes two important improvements of
4625  ! this function, which can be used from C++ and C#:
4626  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
4627  ! * multithreading support
4628  !
4629  ! Intel MKL gives approximately constant (with respect to number of
4630  ! worker threads) acceleration factor which depends on CPU being used,
4631  ! problem size and "baseline" ALGLIB edition which is used for
4632  ! comparison.
4633  !
4634  ! Speed-up provided by multithreading greatly depends on problem size
4635  ! - only large problems (number of coefficients is more than 500) can be
4636  ! efficiently multithreaded.
4637  !
4638  ! Generally, commercial ALGLIB is several times faster than open-source
4639  ! generic C edition, and many times faster than open-source C# edition.
4640  !
4641  ! We recommend you to read 'Working with commercial version' section of
4642  ! ALGLIB Reference Manual in order to find out how to use performance-
4643  ! related features provided by commercial edition of ALGLIB.
4644 
4645 INPUT PARAMETERS:
4646  Y - array[0..N-1] Function values in N points.
4647  FMatrix - a table of basis functions values, array[0..N-1, 0..M-1].
4648  FMatrix[I, J] - value of J-th basis function in I-th point.
4649  N - number of points used. N>=1.
4650  M - number of basis functions, M>=1.
4651 
4652 OUTPUT PARAMETERS:
4653  Info - error code:
4654  * -4 internal SVD decomposition subroutine failed (very
4655  rare and for degenerate systems only)
4656  * 1 task is solved
4657  C - decomposition coefficients, array[0..M-1]
4658  Rep - fitting report. Following fields are set:
4659  * Rep.TaskRCond reciprocal of condition number
4660  * R2 non-adjusted coefficient of determination
4661  (non-weighted)
4662  * RMSError rms error on the (X,Y).
4663  * AvgError average error on the (X,Y).
4664  * AvgRelError average relative error on the non-zero Y
4665  * MaxError maximum error
4666  NON-WEIGHTED ERRORS ARE CALCULATED
4667 
4668 ERRORS IN PARAMETERS
4669 
4670 This solver also calculates different kinds of errors in parameters and
4671 fills corresponding fields of report:
4672 * Rep.CovPar covariance matrix for parameters, array[K,K].
4673 * Rep.ErrPar errors in parameters, array[K],
4674  errpar = sqrt(diag(CovPar))
4675 * Rep.ErrCurve vector of fit errors - standard deviations of empirical
4676  best-fit curve from "ideal" best-fit curve built with
4677  infinite number of samples, array[N].
4678  errcurve = sqrt(diag(F*CovPar*F')),
4679  where F is functions matrix.
4680 * Rep.Noise vector of per-point estimates of noise, array[N]
4681 
4682 NOTE: noise in the data is estimated as follows:
4683  * for fitting without user-supplied weights all points are
4684  assumed to have same level of noise, which is estimated from
4685  the data
4686  * for fitting with user-supplied weights we assume that noise
4687  level in I-th point is inversely proportional to Ith weight.
4688  Coefficient of proportionality is estimated from the data.
4689 
4690 NOTE: we apply small amount of regularization when we invert squared
4691  Jacobian and calculate covariance matrix. It guarantees that
4692  algorithm won't divide by zero during inversion, but skews
4693  error estimates a bit (fractional error is about 10^-9).
4694 
4695  However, we believe that this difference is insignificant for
4696  all practical purposes except for the situation when you want
4697  to compare ALGLIB results with "reference" implementation up
4698  to the last significant digit.
4699 
4700 NOTE: covariance matrix is estimated using correction for degrees
4701  of freedom (covariances are divided by N-M instead of dividing
4702  by N).
4703 
4704  -- ALGLIB --
4705  Copyright 17.08.2009 by Bochkanov Sergey
4706 *************************************************************************/
4707 void lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4708 void smp_lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4709 void lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4710 void smp_lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4711 
4712 
4713 /*************************************************************************
4714 Constained linear least squares fitting.
4715 
4716 This is variation of LSFitLinear(), which searchs for min|A*x=b| given
4717 that K additional constaints C*x=bc are satisfied. It reduces original
4718 task to modified one: min|B*y-d| WITHOUT constraints, then LSFitLinear()
4719 is called.
4720 
4721 IMPORTANT: if you want to perform polynomial fitting, it may be more
4722  convenient to use PolynomialFit() function. This function gives
4723  best results on polynomial problems and solves numerical
4724  stability issues which arise when you fit high-degree
4725  polynomials to your data.
4726 
4727 COMMERCIAL EDITION OF ALGLIB:
4728 
4729  ! Commercial version of ALGLIB includes two important improvements of
4730  ! this function, which can be used from C++ and C#:
4731  ! * Intel MKL support (lightweight Intel MKL is shipped with ALGLIB)
4732  ! * multithreading support
4733  !
4734  ! Intel MKL gives approximately constant (with respect to number of
4735  ! worker threads) acceleration factor which depends on CPU being used,
4736  ! problem size and "baseline" ALGLIB edition which is used for
4737  ! comparison.
4738  !
4739  ! Speed-up provided by multithreading greatly depends on problem size
4740  ! - only large problems (number of coefficients is more than 500) can be
4741  ! efficiently multithreaded.
4742  !
4743  ! Generally, commercial ALGLIB is several times faster than open-source
4744  ! generic C edition, and many times faster than open-source C# edition.
4745  !
4746  ! We recommend you to read 'Working with commercial version' section of
4747  ! ALGLIB Reference Manual in order to find out how to use performance-
4748  ! related features provided by commercial edition of ALGLIB.
4749 
4750 INPUT PARAMETERS:
4751  Y - array[0..N-1] Function values in N points.
4752  FMatrix - a table of basis functions values, array[0..N-1, 0..M-1].
4753  FMatrix[I,J] - value of J-th basis function in I-th point.
4754  CMatrix - a table of constaints, array[0..K-1,0..M].
4755  I-th row of CMatrix corresponds to I-th linear constraint:
4756  CMatrix[I,0]*C[0] + ... + CMatrix[I,M-1]*C[M-1] = CMatrix[I,M]
4757  N - number of points used. N>=1.
4758  M - number of basis functions, M>=1.
4759  K - number of constraints, 0 <= K < M
4760  K=0 corresponds to absence of constraints.
4761 
4762 OUTPUT PARAMETERS:
4763  Info - error code:
4764  * -4 internal SVD decomposition subroutine failed (very
4765  rare and for degenerate systems only)
4766  * -3 either too many constraints (M or more),
4767  degenerate constraints (some constraints are
4768  repetead twice) or inconsistent constraints were
4769  specified.
4770  * 1 task is solved
4771  C - decomposition coefficients, array[0..M-1]
4772  Rep - fitting report. Following fields are set:
4773  * R2 non-adjusted coefficient of determination
4774  (non-weighted)
4775  * RMSError rms error on the (X,Y).
4776  * AvgError average error on the (X,Y).
4777  * AvgRelError average relative error on the non-zero Y
4778  * MaxError maximum error
4779  NON-WEIGHTED ERRORS ARE CALCULATED
4780 
4781 IMPORTANT:
4782  this subroitine doesn't calculate task's condition number for K<>0.
4783 
4784 ERRORS IN PARAMETERS
4785 
4786 This solver also calculates different kinds of errors in parameters and
4787 fills corresponding fields of report:
4788 * Rep.CovPar covariance matrix for parameters, array[K,K].
4789 * Rep.ErrPar errors in parameters, array[K],
4790  errpar = sqrt(diag(CovPar))
4791 * Rep.ErrCurve vector of fit errors - standard deviations of empirical
4792  best-fit curve from "ideal" best-fit curve built with
4793  infinite number of samples, array[N].
4794  errcurve = sqrt(diag(F*CovPar*F')),
4795  where F is functions matrix.
4796 * Rep.Noise vector of per-point estimates of noise, array[N]
4797 
4798 IMPORTANT: errors in parameters are calculated without taking into
4799  account boundary/linear constraints! Presence of constraints
4800  changes distribution of errors, but there is no easy way to
4801  account for constraints when you calculate covariance matrix.
4802 
4803 NOTE: noise in the data is estimated as follows:
4804  * for fitting without user-supplied weights all points are
4805  assumed to have same level of noise, which is estimated from
4806  the data
4807  * for fitting with user-supplied weights we assume that noise
4808  level in I-th point is inversely proportional to Ith weight.
4809  Coefficient of proportionality is estimated from the data.
4810 
4811 NOTE: we apply small amount of regularization when we invert squared
4812  Jacobian and calculate covariance matrix. It guarantees that
4813  algorithm won't divide by zero during inversion, but skews
4814  error estimates a bit (fractional error is about 10^-9).
4815 
4816  However, we believe that this difference is insignificant for
4817  all practical purposes except for the situation when you want
4818  to compare ALGLIB results with "reference" implementation up
4819  to the last significant digit.
4820 
4821 NOTE: covariance matrix is estimated using correction for degrees
4822  of freedom (covariances are divided by N-M instead of dividing
4823  by N).
4824 
4825  -- ALGLIB --
4826  Copyright 07.09.2009 by Bochkanov Sergey
4827 *************************************************************************/
4828 void lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4829 void smp_lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4830 void lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4831 void smp_lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
4832 
4833 
4834 /*************************************************************************
4835 Weighted nonlinear least squares fitting using function values only.
4836 
4837 Combination of numerical differentiation and secant updates is used to
4838 obtain function Jacobian.
4839 
4840 Nonlinear task min(F(c)) is solved, where
4841 
4842  F(c) = (w[0]*(f(c,x[0])-y[0]))^2 + ... + (w[n-1]*(f(c,x[n-1])-y[n-1]))^2,
4843 
4844  * N is a number of points,
4845  * M is a dimension of a space points belong to,
4846  * K is a dimension of a space of parameters being fitted,
4847  * w is an N-dimensional vector of weight coefficients,
4848  * x is a set of N points, each of them is an M-dimensional vector,
4849  * c is a K-dimensional vector of parameters being fitted
4850 
4851 This subroutine uses only f(c,x[i]).
4852 
4853 INPUT PARAMETERS:
4854  X - array[0..N-1,0..M-1], points (one row = one point)
4855  Y - array[0..N-1], function values.
4856  W - weights, array[0..N-1]
4857  C - array[0..K-1], initial approximation to the solution,
4858  N - number of points, N>1
4859  M - dimension of space
4860  K - number of parameters being fitted
4861  DiffStep- numerical differentiation step;
4862  should not be very small or large;
4863  large = loss of accuracy
4864  small = growth of round-off errors
4865 
4866 OUTPUT PARAMETERS:
4867  State - structure which stores algorithm state
4868 
4869  -- ALGLIB --
4870  Copyright 18.10.2008 by Bochkanov Sergey
4871 *************************************************************************/
4872 void lsfitcreatewf(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const double diffstep, lsfitstate &state);
4873 void lsfitcreatewf(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const double diffstep, lsfitstate &state);
4874 
4875 
4876 /*************************************************************************
4877 Nonlinear least squares fitting using function values only.
4878 
4879 Combination of numerical differentiation and secant updates is used to
4880 obtain function Jacobian.
4881 
4882 Nonlinear task min(F(c)) is solved, where
4883 
4884  F(c) = (f(c,x[0])-y[0])^2 + ... + (f(c,x[n-1])-y[n-1])^2,
4885 
4886  * N is a number of points,
4887  * M is a dimension of a space points belong to,
4888  * K is a dimension of a space of parameters being fitted,
4889  * w is an N-dimensional vector of weight coefficients,
4890  * x is a set of N points, each of them is an M-dimensional vector,
4891  * c is a K-dimensional vector of parameters being fitted
4892 
4893 This subroutine uses only f(c,x[i]).
4894 
4895 INPUT PARAMETERS:
4896  X - array[0..N-1,0..M-1], points (one row = one point)
4897  Y - array[0..N-1], function values.
4898  C - array[0..K-1], initial approximation to the solution,
4899  N - number of points, N>1
4900  M - dimension of space
4901  K - number of parameters being fitted
4902  DiffStep- numerical differentiation step;
4903  should not be very small or large;
4904  large = loss of accuracy
4905  small = growth of round-off errors
4906 
4907 OUTPUT PARAMETERS:
4908  State - structure which stores algorithm state
4909 
4910  -- ALGLIB --
4911  Copyright 18.10.2008 by Bochkanov Sergey
4912 *************************************************************************/
4913 void lsfitcreatef(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const double diffstep, lsfitstate &state);
4914 void lsfitcreatef(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const double diffstep, lsfitstate &state);
4915 
4916 
4917 /*************************************************************************
4918 Weighted nonlinear least squares fitting using gradient only.
4919 
4920 Nonlinear task min(F(c)) is solved, where
4921 
4922  F(c) = (w[0]*(f(c,x[0])-y[0]))^2 + ... + (w[n-1]*(f(c,x[n-1])-y[n-1]))^2,
4923 
4924  * N is a number of points,
4925  * M is a dimension of a space points belong to,
4926  * K is a dimension of a space of parameters being fitted,
4927  * w is an N-dimensional vector of weight coefficients,
4928  * x is a set of N points, each of them is an M-dimensional vector,
4929  * c is a K-dimensional vector of parameters being fitted
4930 
4931 This subroutine uses only f(c,x[i]) and its gradient.
4932 
4933 INPUT PARAMETERS:
4934  X - array[0..N-1,0..M-1], points (one row = one point)
4935  Y - array[0..N-1], function values.
4936  W - weights, array[0..N-1]
4937  C - array[0..K-1], initial approximation to the solution,
4938  N - number of points, N>1
4939  M - dimension of space
4940  K - number of parameters being fitted
4941  CheapFG - boolean flag, which is:
4942  * True if both function and gradient calculation complexity
4943  are less than O(M^2). An improved algorithm can
4944  be used which corresponds to FGJ scheme from
4945  MINLM unit.
4946  * False otherwise.
4947  Standard Jacibian-bases Levenberg-Marquardt algo
4948  will be used (FJ scheme).
4949 
4950 OUTPUT PARAMETERS:
4951  State - structure which stores algorithm state
4952 
4953 See also:
4954  LSFitResults
4955  LSFitCreateFG (fitting without weights)
4956  LSFitCreateWFGH (fitting using Hessian)
4957  LSFitCreateFGH (fitting using Hessian, without weights)
4958 
4959  -- ALGLIB --
4960  Copyright 17.08.2009 by Bochkanov Sergey
4961 *************************************************************************/
4962 void lsfitcreatewfg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const bool cheapfg, lsfitstate &state);
4963 void lsfitcreatewfg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const bool cheapfg, lsfitstate &state);
4964 
4965 
4966 /*************************************************************************
4967 Nonlinear least squares fitting using gradient only, without individual
4968 weights.
4969 
4970 Nonlinear task min(F(c)) is solved, where
4971 
4972  F(c) = ((f(c,x[0])-y[0]))^2 + ... + ((f(c,x[n-1])-y[n-1]))^2,
4973 
4974  * N is a number of points,
4975  * M is a dimension of a space points belong to,
4976  * K is a dimension of a space of parameters being fitted,
4977  * x is a set of N points, each of them is an M-dimensional vector,
4978  * c is a K-dimensional vector of parameters being fitted
4979 
4980 This subroutine uses only f(c,x[i]) and its gradient.
4981 
4982 INPUT PARAMETERS:
4983  X - array[0..N-1,0..M-1], points (one row = one point)
4984  Y - array[0..N-1], function values.
4985  C - array[0..K-1], initial approximation to the solution,
4986  N - number of points, N>1
4987  M - dimension of space
4988  K - number of parameters being fitted
4989  CheapFG - boolean flag, which is:
4990  * True if both function and gradient calculation complexity
4991  are less than O(M^2). An improved algorithm can
4992  be used which corresponds to FGJ scheme from
4993  MINLM unit.
4994  * False otherwise.
4995  Standard Jacibian-bases Levenberg-Marquardt algo
4996  will be used (FJ scheme).
4997 
4998 OUTPUT PARAMETERS:
4999  State - structure which stores algorithm state
5000 
5001  -- ALGLIB --
5002  Copyright 17.08.2009 by Bochkanov Sergey
5003 *************************************************************************/
5004 void lsfitcreatefg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const bool cheapfg, lsfitstate &state);
5005 void lsfitcreatefg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const bool cheapfg, lsfitstate &state);
5006 
5007 
5008 /*************************************************************************
5009 Weighted nonlinear least squares fitting using gradient/Hessian.
5010 
5011 Nonlinear task min(F(c)) is solved, where
5012 
5013  F(c) = (w[0]*(f(c,x[0])-y[0]))^2 + ... + (w[n-1]*(f(c,x[n-1])-y[n-1]))^2,
5014 
5015  * N is a number of points,
5016  * M is a dimension of a space points belong to,
5017  * K is a dimension of a space of parameters being fitted,
5018  * w is an N-dimensional vector of weight coefficients,
5019  * x is a set of N points, each of them is an M-dimensional vector,
5020  * c is a K-dimensional vector of parameters being fitted
5021 
5022 This subroutine uses f(c,x[i]), its gradient and its Hessian.
5023 
5024 INPUT PARAMETERS:
5025  X - array[0..N-1,0..M-1], points (one row = one point)
5026  Y - array[0..N-1], function values.
5027  W - weights, array[0..N-1]
5028  C - array[0..K-1], initial approximation to the solution,
5029  N - number of points, N>1
5030  M - dimension of space
5031  K - number of parameters being fitted
5032 
5033 OUTPUT PARAMETERS:
5034  State - structure which stores algorithm state
5035 
5036  -- ALGLIB --
5037  Copyright 17.08.2009 by Bochkanov Sergey
5038 *************************************************************************/
5039 void lsfitcreatewfgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, lsfitstate &state);
5040 void lsfitcreatewfgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, lsfitstate &state);
5041 
5042 
5043 /*************************************************************************
5044 Nonlinear least squares fitting using gradient/Hessian, without individial
5045 weights.
5046 
5047 Nonlinear task min(F(c)) is solved, where
5048 
5049  F(c) = ((f(c,x[0])-y[0]))^2 + ... + ((f(c,x[n-1])-y[n-1]))^2,
5050 
5051  * N is a number of points,
5052  * M is a dimension of a space points belong to,
5053  * K is a dimension of a space of parameters being fitted,
5054  * x is a set of N points, each of them is an M-dimensional vector,
5055  * c is a K-dimensional vector of parameters being fitted
5056 
5057 This subroutine uses f(c,x[i]), its gradient and its Hessian.
5058 
5059 INPUT PARAMETERS:
5060  X - array[0..N-1,0..M-1], points (one row = one point)
5061  Y - array[0..N-1], function values.
5062  C - array[0..K-1], initial approximation to the solution,
5063  N - number of points, N>1
5064  M - dimension of space
5065  K - number of parameters being fitted
5066 
5067 OUTPUT PARAMETERS:
5068  State - structure which stores algorithm state
5069 
5070 
5071  -- ALGLIB --
5072  Copyright 17.08.2009 by Bochkanov Sergey
5073 *************************************************************************/
5074 void lsfitcreatefgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, lsfitstate &state);
5075 void lsfitcreatefgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, lsfitstate &state);
5076 
5077 
5078 /*************************************************************************
5079 Stopping conditions for nonlinear least squares fitting.
5080 
5081 INPUT PARAMETERS:
5082  State - structure which stores algorithm state
5083  EpsX - >=0
5084  The subroutine finishes its work if on k+1-th iteration
5085  the condition |v|<=EpsX is fulfilled, where:
5086  * |.| means Euclidian norm
5087  * v - scaled step vector, v[i]=dx[i]/s[i]
5088  * dx - ste pvector, dx=X(k+1)-X(k)
5089  * s - scaling coefficients set by LSFitSetScale()
5090  MaxIts - maximum number of iterations. If MaxIts=0, the number of
5091  iterations is unlimited. Only Levenberg-Marquardt
5092  iterations are counted (L-BFGS/CG iterations are NOT
5093  counted because their cost is very low compared to that of
5094  LM).
5095 
5096 NOTE
5097 
5098 Passing EpsX=0 and MaxIts=0 (simultaneously) will lead to automatic
5099 stopping criterion selection (according to the scheme used by MINLM unit).
5100 
5101 
5102  -- ALGLIB --
5103  Copyright 17.08.2009 by Bochkanov Sergey
5104 *************************************************************************/
5105 void lsfitsetcond(const lsfitstate &state, const double epsx, const ae_int_t maxits);
5106 
5107 
5108 /*************************************************************************
5109 This function sets maximum step length
5110 
5111 INPUT PARAMETERS:
5112  State - structure which stores algorithm state
5113  StpMax - maximum step length, >=0. Set StpMax to 0.0, if you don't
5114  want to limit step length.
5115 
5116 Use this subroutine when you optimize target function which contains exp()
5117 or other fast growing functions, and optimization algorithm makes too
5118 large steps which leads to overflow. This function allows us to reject
5119 steps that are too large (and therefore expose us to the possible
5120 overflow) without actually calculating function value at the x+stp*d.
5121 
5122 NOTE: non-zero StpMax leads to moderate performance degradation because
5123 intermediate step of preconditioned L-BFGS optimization is incompatible
5124 with limits on step size.
5125 
5126  -- ALGLIB --
5127  Copyright 02.04.2010 by Bochkanov Sergey
5128 *************************************************************************/
5129 void lsfitsetstpmax(const lsfitstate &state, const double stpmax);
5130 
5131 
5132 /*************************************************************************
5133 This function turns on/off reporting.
5134 
5135 INPUT PARAMETERS:
5136  State - structure which stores algorithm state
5137  NeedXRep- whether iteration reports are needed or not
5138 
5139 When reports are needed, State.C (current parameters) and State.F (current
5140 value of fitting function) are reported.
5141 
5142 
5143  -- ALGLIB --
5144  Copyright 15.08.2010 by Bochkanov Sergey
5145 *************************************************************************/
5146 void lsfitsetxrep(const lsfitstate &state, const bool needxrep);
5147 
5148 
5149 /*************************************************************************
5150 This function sets scaling coefficients for underlying optimizer.
5151 
5152 ALGLIB optimizers use scaling matrices to test stopping conditions (step
5153 size and gradient are scaled before comparison with tolerances). Scale of
5154 the I-th variable is a translation invariant measure of:
5155 a) "how large" the variable is
5156 b) how large the step should be to make significant changes in the function
5157 
5158 Generally, scale is NOT considered to be a form of preconditioner. But LM
5159 optimizer is unique in that it uses scaling matrix both in the stopping
5160 condition tests and as Marquardt damping factor.
5161 
5162 Proper scaling is very important for the algorithm performance. It is less
5163 important for the quality of results, but still has some influence (it is
5164 easier to converge when variables are properly scaled, so premature
5165 stopping is possible when very badly scalled variables are combined with
5166 relaxed stopping conditions).
5167 
5168 INPUT PARAMETERS:
5169  State - structure stores algorithm state
5170  S - array[N], non-zero scaling coefficients
5171  S[i] may be negative, sign doesn't matter.
5172 
5173  -- ALGLIB --
5174  Copyright 14.01.2011 by Bochkanov Sergey
5175 *************************************************************************/
5176 void lsfitsetscale(const lsfitstate &state, const real_1d_array &s);
5177 
5178 
5179 /*************************************************************************
5180 This function sets boundary constraints for underlying optimizer
5181 
5182 Boundary constraints are inactive by default (after initial creation).
5183 They are preserved until explicitly turned off with another SetBC() call.
5184 
5185 INPUT PARAMETERS:
5186  State - structure stores algorithm state
5187  BndL - lower bounds, array[K].
5188  If some (all) variables are unbounded, you may specify
5189  very small number or -INF (latter is recommended because
5190  it will allow solver to use better algorithm).
5191  BndU - upper bounds, array[K].
5192  If some (all) variables are unbounded, you may specify
5193  very large number or +INF (latter is recommended because
5194  it will allow solver to use better algorithm).
5195 
5196 NOTE 1: it is possible to specify BndL[i]=BndU[i]. In this case I-th
5197 variable will be "frozen" at X[i]=BndL[i]=BndU[i].
5198 
5199 NOTE 2: unlike other constrained optimization algorithms, this solver has
5200 following useful properties:
5201 * bound constraints are always satisfied exactly
5202 * function is evaluated only INSIDE area specified by bound constraints
5203 
5204  -- ALGLIB --
5205  Copyright 14.01.2011 by Bochkanov Sergey
5206 *************************************************************************/
5207 void lsfitsetbc(const lsfitstate &state, const real_1d_array &bndl, const real_1d_array &bndu);
5208 
5209 
5210 /*************************************************************************
5211 This function sets linear constraints for underlying optimizer
5212 
5213 Linear constraints are inactive by default (after initial creation).
5214 They are preserved until explicitly turned off with another SetLC() call.
5215 
5216 INPUT PARAMETERS:
5217  State - structure stores algorithm state
5218  C - linear constraints, array[K,N+1].
5219  Each row of C represents one constraint, either equality
5220  or inequality (see below):
5221  * first N elements correspond to coefficients,
5222  * last element corresponds to the right part.
5223  All elements of C (including right part) must be finite.
5224  CT - type of constraints, array[K]:
5225  * if CT[i]>0, then I-th constraint is C[i,*]*x >= C[i,n+1]
5226  * if CT[i]=0, then I-th constraint is C[i,*]*x = C[i,n+1]
5227  * if CT[i]<0, then I-th constraint is C[i,*]*x <= C[i,n+1]
5228  K - number of equality/inequality constraints, K>=0:
5229  * if given, only leading K elements of C/CT are used
5230  * if not given, automatically determined from sizes of C/CT
5231 
5232 IMPORTANT: if you have linear constraints, it is strongly recommended to
5233  set scale of variables with lsfitsetscale(). QP solver which is
5234  used to calculate linearly constrained steps heavily relies on
5235  good scaling of input problems.
5236 
5237 NOTE: linear (non-box) constraints are satisfied only approximately -
5238  there always exists some violation due to numerical errors and
5239  algorithmic limitations.
5240 
5241 NOTE: general linear constraints add significant overhead to solution
5242  process. Although solver performs roughly same amount of iterations
5243  (when compared with similar box-only constrained problem), each
5244  iteration now involves solution of linearly constrained QP
5245  subproblem, which requires ~3-5 times more Cholesky decompositions.
5246  Thus, if you can reformulate your problem in such way this it has
5247  only box constraints, it may be beneficial to do so.
5248 
5249  -- ALGLIB --
5250  Copyright 29.04.2017 by Bochkanov Sergey
5251 *************************************************************************/
5252 void lsfitsetlc(const lsfitstate &state, const real_2d_array &c, const integer_1d_array &ct, const ae_int_t k);
5253 void lsfitsetlc(const lsfitstate &state, const real_2d_array &c, const integer_1d_array &ct);
5254 
5255 
5256 /*************************************************************************
5257 This function provides reverse communication interface
5258 Reverse communication interface is not documented or recommended to use.
5259 See below for functions which provide better documented API
5260 *************************************************************************/
5261 bool lsfititeration(const lsfitstate &state);
5262 
5263 
5264 /*************************************************************************
5265 This family of functions is used to launcn iterations of nonlinear fitter
5266 
5267 These functions accept following parameters:
5268  state - algorithm state
5269  func - callback which calculates function (or merit function)
5270  value func at given point x
5271  grad - callback which calculates function (or merit function)
5272  value func and gradient grad at given point x
5273  hess - callback which calculates function (or merit function)
5274  value func, gradient grad and Hessian hess at given point x
5275  rep - optional callback which is called after each iteration
5276  can be NULL
5277  ptr - optional pointer which is passed to func/grad/hess/jac/rep
5278  can be NULL
5279 
5280 NOTES:
5281 
5282 1. this algorithm is somewhat unusual because it works with parameterized
5283  function f(C,X), where X is a function argument (we have many points
5284  which are characterized by different argument values), and C is a
5285  parameter to fit.
5286 
5287  For example, if we want to do linear fit by f(c0,c1,x) = c0*x+c1, then
5288  x will be argument, and {c0,c1} will be parameters.
5289 
5290  It is important to understand that this algorithm finds minimum in the
5291  space of function PARAMETERS (not arguments), so it needs derivatives
5292  of f() with respect to C, not X.
5293 
5294  In the example above it will need f=c0*x+c1 and {df/dc0,df/dc1} = {x,1}
5295  instead of {df/dx} = {c0}.
5296 
5297 2. Callback functions accept C as the first parameter, and X as the second
5298 
5299 3. If state was created with LSFitCreateFG(), algorithm needs just
5300  function and its gradient, but if state was created with
5301  LSFitCreateFGH(), algorithm will need function, gradient and Hessian.
5302 
5303  According to the said above, there ase several versions of this
5304  function, which accept different sets of callbacks.
5305 
5306  This flexibility opens way to subtle errors - you may create state with
5307  LSFitCreateFGH() (optimization using Hessian), but call function which
5308  does not accept Hessian. So when algorithm will request Hessian, there
5309  will be no callback to call. In this case exception will be thrown.
5310 
5311  Be careful to avoid such errors because there is no way to find them at
5312  compile time - you can see them at runtime only.
5313 
5314  -- ALGLIB --
5315  Copyright 17.08.2009 by Bochkanov Sergey
5316 
5317 *************************************************************************/
5318 void lsfitfit(lsfitstate &state,
5319  void (*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr),
5320  void (*rep)(const real_1d_array &c, double func, void *ptr) = NULL,
5321  void *ptr = NULL);
5322 void lsfitfit(lsfitstate &state,
5323  void (*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr),
5324  void (*grad)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, void *ptr),
5325  void (*rep)(const real_1d_array &c, double func, void *ptr) = NULL,
5326  void *ptr = NULL);
5327 void lsfitfit(lsfitstate &state,
5328  void (*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr),
5329  void (*grad)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, void *ptr),
5330  void (*hess)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, real_2d_array &hess, void *ptr),
5331  void (*rep)(const real_1d_array &c, double func, void *ptr) = NULL,
5332  void *ptr = NULL);
5333 
5334 
5335 /*************************************************************************
5336 Nonlinear least squares fitting results.
5337 
5338 Called after return from LSFitFit().
5339 
5340 INPUT PARAMETERS:
5341  State - algorithm state
5342 
5343 OUTPUT PARAMETERS:
5344  Info - completion code:
5345  * -7 gradient verification failed.
5346  See LSFitSetGradientCheck() for more information.
5347  * 2 relative step is no more than EpsX.
5348  * 5 MaxIts steps was taken
5349  * 7 stopping conditions are too stringent,
5350  further improvement is impossible
5351  C - array[0..K-1], solution
5352  Rep - optimization report. On success following fields are set:
5353  * R2 non-adjusted coefficient of determination
5354  (non-weighted)
5355  * RMSError rms error on the (X,Y).
5356  * AvgError average error on the (X,Y).
5357  * AvgRelError average relative error on the non-zero Y
5358  * MaxError maximum error
5359  NON-WEIGHTED ERRORS ARE CALCULATED
5360  * WRMSError weighted rms error on the (X,Y).
5361 
5362 ERRORS IN PARAMETERS
5363 
5364 This solver also calculates different kinds of errors in parameters and
5365 fills corresponding fields of report:
5366 * Rep.CovPar covariance matrix for parameters, array[K,K].
5367 * Rep.ErrPar errors in parameters, array[K],
5368  errpar = sqrt(diag(CovPar))
5369 * Rep.ErrCurve vector of fit errors - standard deviations of empirical
5370  best-fit curve from "ideal" best-fit curve built with
5371  infinite number of samples, array[N].
5372  errcurve = sqrt(diag(J*CovPar*J')),
5373  where J is Jacobian matrix.
5374 * Rep.Noise vector of per-point estimates of noise, array[N]
5375 
5376 IMPORTANT: errors in parameters are calculated without taking into
5377  account boundary/linear constraints! Presence of constraints
5378  changes distribution of errors, but there is no easy way to
5379  account for constraints when you calculate covariance matrix.
5380 
5381 NOTE: noise in the data is estimated as follows:
5382  * for fitting without user-supplied weights all points are
5383  assumed to have same level of noise, which is estimated from
5384  the data
5385  * for fitting with user-supplied weights we assume that noise
5386  level in I-th point is inversely proportional to Ith weight.
5387  Coefficient of proportionality is estimated from the data.
5388 
5389 NOTE: we apply small amount of regularization when we invert squared
5390  Jacobian and calculate covariance matrix. It guarantees that
5391  algorithm won't divide by zero during inversion, but skews
5392  error estimates a bit (fractional error is about 10^-9).
5393 
5394  However, we believe that this difference is insignificant for
5395  all practical purposes except for the situation when you want
5396  to compare ALGLIB results with "reference" implementation up
5397  to the last significant digit.
5398 
5399 NOTE: covariance matrix is estimated using correction for degrees
5400  of freedom (covariances are divided by N-M instead of dividing
5401  by N).
5402 
5403  -- ALGLIB --
5404  Copyright 17.08.2009 by Bochkanov Sergey
5405 *************************************************************************/
5406 void lsfitresults(const lsfitstate &state, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
5407 
5408 
5409 /*************************************************************************
5410 This subroutine turns on verification of the user-supplied analytic
5411 gradient:
5412 * user calls this subroutine before fitting begins
5413 * LSFitFit() is called
5414 * prior to actual fitting, for each point in data set X_i and each
5415  component of parameters being fited C_j algorithm performs following
5416  steps:
5417  * two trial steps are made to C_j-TestStep*S[j] and C_j+TestStep*S[j],
5418  where C_j is j-th parameter and S[j] is a scale of j-th parameter
5419  * if needed, steps are bounded with respect to constraints on C[]
5420  * F(X_i|C) is evaluated at these trial points
5421  * we perform one more evaluation in the middle point of the interval
5422  * we build cubic model using function values and derivatives at trial
5423  points and we compare its prediction with actual value in the middle
5424  point
5425  * in case difference between prediction and actual value is higher than
5426  some predetermined threshold, algorithm stops with completion code -7;
5427  Rep.VarIdx is set to index of the parameter with incorrect derivative.
5428 * after verification is over, algorithm proceeds to the actual optimization.
5429 
5430 NOTE 1: verification needs N*K (points count * parameters count) gradient
5431  evaluations. It is very costly and you should use it only for low
5432  dimensional problems, when you want to be sure that you've
5433  correctly calculated analytic derivatives. You should not use it
5434  in the production code (unless you want to check derivatives
5435  provided by some third party).
5436 
5437 NOTE 2: you should carefully choose TestStep. Value which is too large
5438  (so large that function behaviour is significantly non-cubic) will
5439  lead to false alarms. You may use different step for different
5440  parameters by means of setting scale with LSFitSetScale().
5441 
5442 NOTE 3: this function may lead to false positives. In case it reports that
5443  I-th derivative was calculated incorrectly, you may decrease test
5444  step and try one more time - maybe your function changes too
5445  sharply and your step is too large for such rapidly chanding
5446  function.
5447 
5448 NOTE 4: this function works only for optimizers created with LSFitCreateWFG()
5449  or LSFitCreateFG() constructors.
5450 
5451 INPUT PARAMETERS:
5452  State - structure used to store algorithm state
5453  TestStep - verification step:
5454  * TestStep=0 turns verification off
5455  * TestStep>0 activates verification
5456 
5457  -- ALGLIB --
5458  Copyright 15.06.2012 by Bochkanov Sergey
5459 *************************************************************************/
5460 void lsfitsetgradientcheck(const lsfitstate &state, const double teststep);
5461 
5462 
5463 
5464 /*************************************************************************
5465 Fits minimum circumscribed (MCC) circle (or NX-dimensional sphere) to data
5466 (a set of points in NX-dimensional space).
5467 
5468 INPUT PARAMETERS:
5469  XY - array[NPoints,NX] (or larger), contains dataset.
5470  One row = one point in NX-dimensional space.
5471  NPoints - dataset size, NPoints>0
5472  NX - space dimensionality, NX>0 (1, 2, 3, 4, 5 and so on)
5473 
5474 OUTPUT PARAMETERS:
5475  CX - central point for a sphere
5476  RHi - radius
5477 
5478 NOTE: this function is an easy-to-use wrapper around more powerful "expert"
5479  function nsfitspherex().
5480 
5481  This wrapper is optimized for ease of use and stability - at the
5482  cost of somewhat lower performance (we have to use very tight
5483  stopping criteria for inner optimizer because we want to make sure
5484  that it will converge on any dataset).
5485 
5486  If you are ready to experiment with settings of "expert" function,
5487  you can achieve ~2-4x speedup over standard "bulletproof" settings.
5488 
5489 
5490  -- ALGLIB --
5491  Copyright 14.04.2017 by Bochkanov Sergey
5492 *************************************************************************/
5493 void nsfitspheremcc(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rhi);
5494 
5495 
5496 /*************************************************************************
5497 Fits maximum inscribed circle (or NX-dimensional sphere) to data (a set of
5498 points in NX-dimensional space).
5499 
5500 INPUT PARAMETERS:
5501  XY - array[NPoints,NX] (or larger), contains dataset.
5502  One row = one point in NX-dimensional space.
5503  NPoints - dataset size, NPoints>0
5504  NX - space dimensionality, NX>0 (1, 2, 3, 4, 5 and so on)
5505 
5506 OUTPUT PARAMETERS:
5507  CX - central point for a sphere
5508  RLo - radius
5509 
5510 NOTE: this function is an easy-to-use wrapper around more powerful "expert"
5511  function nsfitspherex().
5512 
5513  This wrapper is optimized for ease of use and stability - at the
5514  cost of somewhat lower performance (we have to use very tight
5515  stopping criteria for inner optimizer because we want to make sure
5516  that it will converge on any dataset).
5517 
5518  If you are ready to experiment with settings of "expert" function,
5519  you can achieve ~2-4x speedup over standard "bulletproof" settings.
5520 
5521 
5522  -- ALGLIB --
5523  Copyright 14.04.2017 by Bochkanov Sergey
5524 *************************************************************************/
5525 void nsfitspheremic(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rlo);
5526 
5527 
5528 /*************************************************************************
5529 Fits minimum zone circle (or NX-dimensional sphere) to data (a set of
5530 points in NX-dimensional space).
5531 
5532 INPUT PARAMETERS:
5533  XY - array[NPoints,NX] (or larger), contains dataset.
5534  One row = one point in NX-dimensional space.
5535  NPoints - dataset size, NPoints>0
5536  NX - space dimensionality, NX>0 (1, 2, 3, 4, 5 and so on)
5537 
5538 OUTPUT PARAMETERS:
5539  CX - central point for a sphere
5540  RLo - radius of inscribed circle
5541  RHo - radius of circumscribed circle
5542 
5543 NOTE: this function is an easy-to-use wrapper around more powerful "expert"
5544  function nsfitspherex().
5545 
5546  This wrapper is optimized for ease of use and stability - at the
5547  cost of somewhat lower performance (we have to use very tight
5548  stopping criteria for inner optimizer because we want to make sure
5549  that it will converge on any dataset).
5550 
5551  If you are ready to experiment with settings of "expert" function,
5552  you can achieve ~2-4x speedup over standard "bulletproof" settings.
5553 
5554 
5555  -- ALGLIB --
5556  Copyright 14.04.2017 by Bochkanov Sergey
5557 *************************************************************************/
5558 void nsfitspheremzc(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rlo, double &rhi);
5559 
5560 
5561 /*************************************************************************
5562 Fitting minimum circumscribed, maximum inscribed or minimum zone circles
5563 (or NX-dimensional spheres) to data (a set of points in NX-dimensional
5564 space).
5565 
5566 This is expert function which allows to tweak many parameters of
5567 underlying nonlinear solver:
5568 * stopping criteria for inner iterations
5569 * number of outer iterations
5570 * penalty coefficient used to handle nonlinear constraints (we convert
5571  unconstrained nonsmooth optimization problem ivolving max() and/or min()
5572  operations to quadratically constrained smooth one).
5573 
5574 You may tweak all these parameters or only some of them, leaving other
5575 ones at their default state - just specify zero value, and solver will
5576 fill it with appropriate default one.
5577 
5578 These comments also include some discussion of approach used to handle
5579 such unusual fitting problem, its stability, drawbacks of alternative
5580 methods, and convergence properties.
5581 
5582 INPUT PARAMETERS:
5583  XY - array[NPoints,NX] (or larger), contains dataset.
5584  One row = one point in NX-dimensional space.
5585  NPoints - dataset size, NPoints>0
5586  NX - space dimensionality, NX>0 (1, 2, 3, 4, 5 and so on)
5587  ProblemType-used to encode problem type:
5588  * 1 for minimum circumscribed circle/sphere fitting (MCC)
5589  * 2 for maximum inscribed circle/sphere fitting (MIC)
5590  * 3 for minimum zone circle fitting (difference between
5591  Rhi and Rlo is minimized), denoted as MZC
5592  EpsX - stopping condition for NLC optimizer:
5593  * must be non-negative
5594  * use 0 to choose default value (1.0E-12 is used by default)
5595  * you may specify larger values, up to 1.0E-6, if you want
5596  to speed-up solver; NLC solver performs several
5597  preconditioned outer iterations, so final result
5598  typically has precision much better than EpsX.
5599  AULIts - number of outer iterations performed by NLC optimizer:
5600  * must be non-negative
5601  * use 0 to choose default value (20 is used by default)
5602  * you may specify values smaller than 20 if you want to
5603  speed up solver; 10 often results in good combination of
5604  precision and speed; sometimes you may get good results
5605  with just 6 outer iterations.
5606  Penalty - penalty coefficient for NLC optimizer:
5607  * must be non-negative
5608  * use 0 to choose default value (1.0E6 in current version)
5609  * it should be really large, 1.0E6...1.0E7 is a good value
5610  to start from;
5611  * generally, default value is good enough
5612 
5613 OUTPUT PARAMETERS:
5614  CX - central point for a sphere
5615  RLo - radius:
5616  * for ProblemType=2,3, radius of the inscribed sphere
5617  * for ProblemType=1 - zero
5618  RHo - radius:
5619  * for ProblemType=1,3, radius of the circumscribed sphere
5620  * for ProblemType=2 - zero
5621 
5622 NOTE: ON THE UNIQUENESS OF SOLUTIONS
5623 
5624 ALGLIB provides solution to several related circle fitting problems: MCC
5625 (minimum circumscribed), MIC (maximum inscribed) and MZC (minimum zone)
5626 fitting.
5627 
5628 It is important to note that among these problems only MCC is convex and
5629 has unique solution independently from starting point.
5630 
5631 As for MIC, it may (or may not, depending on dataset properties) have
5632 multiple solutions, and it always has one degenerate solution C=infinity
5633 which corresponds to infinitely large radius. Thus, there are no guarantees
5634 that solution to MIC returned by this solver will be the best one (and no
5635 one can provide you with such guarantee because problem is NP-hard). The
5636 only guarantee you have is that this solution is locally optimal, i.e. it
5637 can not be improved by infinitesimally small tweaks in the parameters.
5638 
5639 It is also possible to "run away" to infinity when started from bad
5640 initial point located outside of point cloud (or when point cloud does not
5641 span entire circumference/surface of the sphere).
5642 
5643 Finally, MZC (minimum zone circle) stands somewhere between MCC and MIC in
5644 stability. It is somewhat regularized by "circumscribed" term of the merit
5645 function; however, solutions to MZC may be non-unique, and in some unlucky
5646 cases it is also possible to "run away to infinity".
5647 
5648 
5649 NOTE: ON THE NONLINEARLY CONSTRAINED PROGRAMMING APPROACH
5650 
5651 The problem formulation for MCC (minimum circumscribed circle; for the
5652 sake of simplicity we omit MZC and MIC here) is:
5653 
5654  [ [ ]2 ]
5655  min [ max [ XY[i]-C ] ]
5656  C [ i [ ] ]
5657 
5658 i.e. it is unconstrained nonsmooth optimization problem of finding "best"
5659 central point, with radius R being unambiguously determined from C. In
5660 order to move away from non-smoothness we use following reformulation:
5661 
5662  [ ] [ ]2
5663  min [ R ] subject to R>=0, [ XY[i]-C ] <= R^2
5664  C,R [ ] [ ]
5665 
5666 i.e. it becomes smooth quadratically constrained optimization problem with
5667 linear target function. Such problem statement is 100% equivalent to the
5668 original nonsmooth one, but much easier to approach. We solve it with
5669 MinNLC solver provided by ALGLIB.
5670 
5671 
5672 NOTE: ON INSTABILITY OF SEQUENTIAL LINEAR PROGRAMMING APPROACJ
5673 
5674 ALGLIB has nonlinearly constrained solver which proved to be stable on
5675 such problems. However, some authors proposed to linearize constraints in
5676 the vicinity of current approximation (Ci,Ri) and to get next approximate
5677 solution (Ci+1,Ri+1) as solution to linear programming problem. Obviously,
5678 LP problems are easier than nonlinearly constrained ones.
5679 
5680 Indeed, SLP approach to MCC/MIC/MZC resulted in ~10-20x increase in
5681 performance (when compared with NLC solver). However, it turned out that
5682 in some cases linearized model fails to predict correct direction for next
5683 step and tells us that we converged to solution even when we are still 2-4
5684 digits of precision away from it.
5685 
5686 It is important that it is not failure of LP solver - it is failure of the
5687 linear model; even when solved exactly, it fails to handle subtle
5688 nonlinearities which arise near the solution. We validated it by comparing
5689 results returned by ALGLIB linear solver with that of MATLAB.
5690 
5691 In our experiments with SLP solver:
5692 * MCC failed most often, at both realistic and synthetic datasets
5693 * MIC sometimes failed, but sometimes succeeded
5694 * MZC often succeeded; our guess is that presence of two independent sets
5695  of constraints (one set for Rlo and another one for Rhi) and two terms
5696  in the target function (Rlo and Rhi) regularizes task, so when linear
5697  model fails to handle nonlinearities from Rlo, it uses Rhi as a hint
5698  (and vice versa).
5699 
5700 Because SLP approach failed to achieve stable results, we do not include
5701 it in ALGLIB.
5702 
5703 
5704  -- ALGLIB --
5705  Copyright 14.04.2017 by Bochkanov Sergey
5706 *************************************************************************/
5707 void nsfitspherex(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, const ae_int_t problemtype, const double epsx, const ae_int_t aulits, const double penalty, real_1d_array &cx, double &rlo, double &rhi);
5708 
5709 /*************************************************************************
5710 This subroutine calculates the value of the bilinear or bicubic spline at
5711 the given point X.
5712 
5713 Input parameters:
5714  C - coefficients table.
5715  Built by BuildBilinearSpline or BuildBicubicSpline.
5716  X, Y- point
5717 
5718 Result:
5719  S(x,y)
5720 
5721  -- ALGLIB PROJECT --
5722  Copyright 05.07.2007 by Bochkanov Sergey
5723 *************************************************************************/
5724 double spline2dcalc(const spline2dinterpolant &c, const double x, const double y);
5725 
5726 
5727 /*************************************************************************
5728 This subroutine calculates the value of the bilinear or bicubic spline at
5729 the given point X and its derivatives.
5730 
5731 Input parameters:
5732  C - spline interpolant.
5733  X, Y- point
5734 
5735 Output parameters:
5736  F - S(x,y)
5737  FX - dS(x,y)/dX
5738  FY - dS(x,y)/dY
5739  FXY - d2S(x,y)/dXdY
5740 
5741  -- ALGLIB PROJECT --
5742  Copyright 05.07.2007 by Bochkanov Sergey
5743 *************************************************************************/
5744 void spline2ddiff(const spline2dinterpolant &c, const double x, const double y, double &f, double &fx, double &fy, double &fxy);
5745 
5746 
5747 /*************************************************************************
5748 This subroutine performs linear transformation of the spline argument.
5749 
5750 Input parameters:
5751  C - spline interpolant
5752  AX, BX - transformation coefficients: x = A*t + B
5753  AY, BY - transformation coefficients: y = A*u + B
5754 Result:
5755  C - transformed spline
5756 
5757  -- ALGLIB PROJECT --
5758  Copyright 30.06.2007 by Bochkanov Sergey
5759 *************************************************************************/
5760 void spline2dlintransxy(const spline2dinterpolant &c, const double ax, const double bx, const double ay, const double by);
5761 
5762 
5763 /*************************************************************************
5764 This subroutine performs linear transformation of the spline.
5765 
5766 Input parameters:
5767  C - spline interpolant.
5768  A, B- transformation coefficients: S2(x,y) = A*S(x,y) + B
5769 
5770 Output parameters:
5771  C - transformed spline
5772 
5773  -- ALGLIB PROJECT --
5774  Copyright 30.06.2007 by Bochkanov Sergey
5775 *************************************************************************/
5776 void spline2dlintransf(const spline2dinterpolant &c, const double a, const double b);
5777 
5778 
5779 /*************************************************************************
5780 This subroutine makes the copy of the spline model.
5781 
5782 Input parameters:
5783  C - spline interpolant
5784 
5785 Output parameters:
5786  CC - spline copy
5787 
5788  -- ALGLIB PROJECT --
5789  Copyright 29.06.2007 by Bochkanov Sergey
5790 *************************************************************************/
5792 
5793 
5794 /*************************************************************************
5795 Bicubic spline resampling
5796 
5797 Input parameters:
5798  A - function values at the old grid,
5799  array[0..OldHeight-1, 0..OldWidth-1]
5800  OldHeight - old grid height, OldHeight>1
5801  OldWidth - old grid width, OldWidth>1
5802  NewHeight - new grid height, NewHeight>1
5803  NewWidth - new grid width, NewWidth>1
5804 
5805 Output parameters:
5806  B - function values at the new grid,
5807  array[0..NewHeight-1, 0..NewWidth-1]
5808 
5809  -- ALGLIB routine --
5810  15 May, 2007
5811  Copyright by Bochkanov Sergey
5812 *************************************************************************/
5813 void spline2dresamplebicubic(const real_2d_array &a, const ae_int_t oldheight, const ae_int_t oldwidth, real_2d_array &b, const ae_int_t newheight, const ae_int_t newwidth);
5814 
5815 
5816 /*************************************************************************
5817 Bilinear spline resampling
5818 
5819 Input parameters:
5820  A - function values at the old grid,
5821  array[0..OldHeight-1, 0..OldWidth-1]
5822  OldHeight - old grid height, OldHeight>1
5823  OldWidth - old grid width, OldWidth>1
5824  NewHeight - new grid height, NewHeight>1
5825  NewWidth - new grid width, NewWidth>1
5826 
5827 Output parameters:
5828  B - function values at the new grid,
5829  array[0..NewHeight-1, 0..NewWidth-1]
5830 
5831  -- ALGLIB routine --
5832  09.07.2007
5833  Copyright by Bochkanov Sergey
5834 *************************************************************************/
5835 void spline2dresamplebilinear(const real_2d_array &a, const ae_int_t oldheight, const ae_int_t oldwidth, real_2d_array &b, const ae_int_t newheight, const ae_int_t newwidth);
5836 
5837 
5838 /*************************************************************************
5839 This subroutine builds bilinear vector-valued spline.
5840 
5841 Input parameters:
5842  X - spline abscissas, array[0..N-1]
5843  Y - spline ordinates, array[0..M-1]
5844  F - function values, array[0..M*N*D-1]:
5845  * first D elements store D values at (X[0],Y[0])
5846  * next D elements store D values at (X[1],Y[0])
5847  * general form - D function values at (X[i],Y[j]) are stored
5848  at F[D*(J*N+I)...D*(J*N+I)+D-1].
5849  M,N - grid size, M>=2, N>=2
5850  D - vector dimension, D>=1
5851 
5852 Output parameters:
5853  C - spline interpolant
5854 
5855  -- ALGLIB PROJECT --
5856  Copyright 16.04.2012 by Bochkanov Sergey
5857 *************************************************************************/
5858 void spline2dbuildbilinearv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &f, const ae_int_t d, spline2dinterpolant &c);
5859 
5860 
5861 /*************************************************************************
5862 This subroutine builds bicubic vector-valued spline.
5863 
5864 Input parameters:
5865  X - spline abscissas, array[0..N-1]
5866  Y - spline ordinates, array[0..M-1]
5867  F - function values, array[0..M*N*D-1]:
5868  * first D elements store D values at (X[0],Y[0])
5869  * next D elements store D values at (X[1],Y[0])
5870  * general form - D function values at (X[i],Y[j]) are stored
5871  at F[D*(J*N+I)...D*(J*N+I)+D-1].
5872  M,N - grid size, M>=2, N>=2
5873  D - vector dimension, D>=1
5874 
5875 Output parameters:
5876  C - spline interpolant
5877 
5878  -- ALGLIB PROJECT --
5879  Copyright 16.04.2012 by Bochkanov Sergey
5880 *************************************************************************/
5881 void spline2dbuildbicubicv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &f, const ae_int_t d, spline2dinterpolant &c);
5882 
5883 
5884 /*************************************************************************
5885 This subroutine calculates bilinear or bicubic vector-valued spline at the
5886 given point (X,Y).
5887 
5888 INPUT PARAMETERS:
5889  C - spline interpolant.
5890  X, Y- point
5891  F - output buffer, possibly preallocated array. In case array size
5892  is large enough to store result, it is not reallocated. Array
5893  which is too short will be reallocated
5894 
5895 OUTPUT PARAMETERS:
5896  F - array[D] (or larger) which stores function values
5897 
5898  -- ALGLIB PROJECT --
5899  Copyright 16.04.2012 by Bochkanov Sergey
5900 *************************************************************************/
5901 void spline2dcalcvbuf(const spline2dinterpolant &c, const double x, const double y, real_1d_array &f);
5902 
5903 
5904 /*************************************************************************
5905 This subroutine calculates bilinear or bicubic vector-valued spline at the
5906 given point (X,Y).
5907 
5908 INPUT PARAMETERS:
5909  C - spline interpolant.
5910  X, Y- point
5911 
5912 OUTPUT PARAMETERS:
5913  F - array[D] which stores function values. F is out-parameter and
5914  it is reallocated after call to this function. In case you
5915  want to reuse previously allocated F, you may use
5916  Spline2DCalcVBuf(), which reallocates F only when it is too
5917  small.
5918 
5919  -- ALGLIB PROJECT --
5920  Copyright 16.04.2012 by Bochkanov Sergey
5921 *************************************************************************/
5922 void spline2dcalcv(const spline2dinterpolant &c, const double x, const double y, real_1d_array &f);
5923 
5924 
5925 /*************************************************************************
5926 This subroutine unpacks two-dimensional spline into the coefficients table
5927 
5928 Input parameters:
5929  C - spline interpolant.
5930 
5931 Result:
5932  M, N- grid size (x-axis and y-axis)
5933  D - number of components
5934  Tbl - coefficients table, unpacked format,
5935  D - components: [0..(N-1)*(M-1)*D-1, 0..19].
5936  For T=0..D-1 (component index), I = 0...N-2 (x index),
5937  J=0..M-2 (y index):
5938  K := T + I*D + J*D*(N-1)
5939 
5940  K-th row stores decomposition for T-th component of the
5941  vector-valued function
5942 
5943  Tbl[K,0] = X[i]
5944  Tbl[K,1] = X[i+1]
5945  Tbl[K,2] = Y[j]
5946  Tbl[K,3] = Y[j+1]
5947  Tbl[K,4] = C00
5948  Tbl[K,5] = C01
5949  Tbl[K,6] = C02
5950  Tbl[K,7] = C03
5951  Tbl[K,8] = C10
5952  Tbl[K,9] = C11
5953  ...
5954  Tbl[K,19] = C33
5955  On each grid square spline is equals to:
5956  S(x) = SUM(c[i,j]*(t^i)*(u^j), i=0..3, j=0..3)
5957  t = x-x[j]
5958  u = y-y[i]
5959 
5960  -- ALGLIB PROJECT --
5961  Copyright 16.04.2012 by Bochkanov Sergey
5962 *************************************************************************/
5964 
5965 
5966 /*************************************************************************
5967 This subroutine was deprecated in ALGLIB 3.6.0
5968 
5969 We recommend you to switch to Spline2DBuildBilinearV(), which is more
5970 flexible and accepts its arguments in more convenient order.
5971 
5972  -- ALGLIB PROJECT --
5973  Copyright 05.07.2007 by Bochkanov Sergey
5974 *************************************************************************/
5976 
5977 
5978 /*************************************************************************
5979 This subroutine was deprecated in ALGLIB 3.6.0
5980 
5981 We recommend you to switch to Spline2DBuildBicubicV(), which is more
5982 flexible and accepts its arguments in more convenient order.
5983 
5984  -- ALGLIB PROJECT --
5985  Copyright 05.07.2007 by Bochkanov Sergey
5986 *************************************************************************/
5987 void spline2dbuildbicubic(const real_1d_array &x, const real_1d_array &y, const real_2d_array &f, const ae_int_t m, const ae_int_t n, spline2dinterpolant &c);
5988 
5989 
5990 /*************************************************************************
5991 This subroutine was deprecated in ALGLIB 3.6.0
5992 
5993 We recommend you to switch to Spline2DUnpackV(), which is more flexible
5994 and accepts its arguments in more convenient order.
5995 
5996  -- ALGLIB PROJECT --
5997  Copyright 29.06.2007 by Bochkanov Sergey
5998 *************************************************************************/
6000 
6001 
6002 
6003 /*************************************************************************
6004 This function serializes data structure to string.
6005 
6006 Important properties of s_out:
6007 * it contains alphanumeric characters, dots, underscores, minus signs
6008 * these symbols are grouped into words, which are separated by spaces
6009  and Windows-style (CR+LF) newlines
6010 * although serializer uses spaces and CR+LF as separators, you can
6011  replace any separator character by arbitrary combination of spaces,
6012  tabs, Windows or Unix newlines. It allows flexible reformatting of
6013  the string in case you want to include it into text or XML file.
6014  But you should not insert separators into the middle of the "words"
6015  nor you should change case of letters.
6016 * s_out can be freely moved between 32-bit and 64-bit systems, little
6017  and big endian machines, and so on. You can serialize structure on
6018  32-bit machine and unserialize it on 64-bit one (or vice versa), or
6019  serialize it on SPARC and unserialize on x86. You can also
6020  serialize it in C++ version of ALGLIB and unserialize in C# one,
6021  and vice versa.
6022 *************************************************************************/
6023 void rbfserialize(rbfmodel &obj, std::string &s_out);
6024 
6025 
6026 /*************************************************************************
6027 This function unserializes data structure from string.
6028 *************************************************************************/
6029 void rbfunserialize(const std::string &s_in, rbfmodel &obj);
6030 
6031 
6032 
6033 
6034 /*************************************************************************
6035 This function serializes data structure to C++ stream.
6036 
6037 Data stream generated by this function is same as string representation
6038 generated by string version of serializer - alphanumeric characters,
6039 dots, underscores, minus signs, which are grouped into words separated by
6040 spaces and CR+LF.
6041 
6042 We recommend you to read comments on string version of serializer to find
6043 out more about serialization of AlGLIB objects.
6044 *************************************************************************/
6045 void rbfserialize(rbfmodel &obj, std::ostream &s_out);
6046 
6047 
6048 /*************************************************************************
6049 This function unserializes data structure from stream.
6050 *************************************************************************/
6051 void rbfunserialize(const std::istream &s_in, rbfmodel &obj);
6052 
6053 
6054 /*************************************************************************
6055 This function creates RBF model for a scalar (NY=1) or vector (NY>1)
6056 function in a NX-dimensional space (NX>=1).
6057 
6058 Newly created model is empty. It can be used for interpolation right after
6059 creation, but it just returns zeros. You have to add points to the model,
6060 tune interpolation settings, and then call model construction function
6061 rbfbuildmodel() which will update model according to your specification.
6062 
6063 USAGE:
6064 1. User creates model with rbfcreate()
6065 2. User adds dataset with rbfsetpoints() (points do NOT have to be on a
6066  regular grid) or rbfsetpointsandscales().
6067 3. (OPTIONAL) User chooses polynomial term by calling:
6068  * rbflinterm() to set linear term
6069  * rbfconstterm() to set constant term
6070  * rbfzeroterm() to set zero term
6071  By default, linear term is used.
6072 4. User tweaks algorithm properties with rbfsetalgohierarchical() method
6073  (or chooses one of the legacy algorithms - QNN (rbfsetalgoqnn) or ML
6074  (rbfsetalgomultilayer)).
6075 5. User calls rbfbuildmodel() function which rebuilds model according to
6076  the specification
6077 6. User may call rbfcalc() to calculate model value at the specified point,
6078  rbfgridcalc() to calculate model values at the points of the regular
6079  grid. User may extract model coefficients with rbfunpack() call.
6080 
6081 IMPORTANT: we recommend you to use latest model construction algorithm -
6082  hierarchical RBFs, which is activated by rbfsetalgohierarchical()
6083  function. This algorithm is the fastest one, and most memory-
6084  efficient.
6085  However, it is incompatible with older versions of ALGLIB
6086  (pre-3.11). So, if you serialize hierarchical model, you will
6087  be unable to load it in pre-3.11 ALGLIB. Other model types (QNN
6088  and RBF-ML) are still backward-compatible.
6089 
6090 INPUT PARAMETERS:
6091  NX - dimension of the space, NX>=1
6092  NY - function dimension, NY>=1
6093 
6094 OUTPUT PARAMETERS:
6095  S - RBF model (initially equals to zero)
6096 
6097 NOTE 1: memory requirements. RBF models require amount of memory which is
6098  proportional to the number of data points. Some additional memory
6099  is allocated during model construction, but most of this memory is
6100  freed after model coefficients are calculated. Amount of this
6101  additional memory depends on model construction algorithm being
6102  used.
6103 
6104 NOTE 2: prior to ALGLIB version 3.11, RBF models supported only NX=2 or
6105  NX=3. Any attempt to create single-dimensional or more than
6106  3-dimensional RBF model resulted in exception.
6107 
6108  ALGLIB 3.11 supports any NX>0, but models created with NX!=2 and
6109  NX!=3 are incompatible with (a) older versions of ALGLIB, (b) old
6110  model construction algorithms (QNN or RBF-ML).
6111 
6112  So, if you create a model with NX=2 or NX=3, then, depending on
6113  specific model construction algorithm being chosen, you will (QNN
6114  and RBF-ML) or will not (HierarchicalRBF) get backward compatibility
6115  with older versions of ALGLIB. You have a choice here.
6116 
6117  However, if you create a model with NX neither 2 nor 3, you have
6118  no backward compatibility from the start, and you are forced to
6119  use hierarchical RBFs and ALGLIB 3.11 or later.
6120 
6121  -- ALGLIB --
6122  Copyright 13.12.2011, 20.06.2016 by Bochkanov Sergey
6123 *************************************************************************/
6124 void rbfcreate(const ae_int_t nx, const ae_int_t ny, rbfmodel &s);
6125 
6126 
6127 /*************************************************************************
6128 This function creates buffer structure which can be used to perform
6129 parallel RBF model evaluations (with one RBF model instance being
6130 used from multiple threads, as long as different threads use different
6131 instances of buffer).
6132 
6133 This buffer object can be used with rbftscalcbuf() function (here "ts"
6134 stands for "thread-safe", "buf" is a suffix which denotes function which
6135 reuses previously allocated output space).
6136 
6137 How to use it:
6138 * create RBF model structure with rbfcreate()
6139 * load data, tune parameters
6140 * call rbfbuildmodel()
6141 * call rbfcreatecalcbuffer(), once per thread working with RBF model (you
6142  should call this function only AFTER call to rbfbuildmodel(), see below
6143  for more information)
6144 * call rbftscalcbuf() from different threads, with each thread working
6145  with its own copy of buffer object.
6146 
6147 INPUT PARAMETERS
6148  S - RBF model
6149 
6150 OUTPUT PARAMETERS
6151  Buf - external buffer.
6152 
6153 
6154 IMPORTANT: buffer object should be used only with RBF model object which
6155  was used to initialize buffer. Any attempt to use buffer with
6156  different object is dangerous - you may get memory violation
6157  error because sizes of internal arrays do not fit to dimensions
6158  of RBF structure.
6159 
6160 IMPORTANT: you should call this function only for model which was built
6161  with rbfbuildmodel() function, after successful invocation of
6162  rbfbuildmodel(). Sizes of some internal structures are
6163  determined only after model is built, so buffer object created
6164  before model construction stage will be useless (and any
6165  attempt to use it will result in exception).
6166 
6167  -- ALGLIB --
6168  Copyright 02.04.2016 by Sergey Bochkanov
6169 *************************************************************************/
6171 
6172 
6173 /*************************************************************************
6174 This function adds dataset.
6175 
6176 This function overrides results of the previous calls, i.e. multiple calls
6177 of this function will result in only the last set being added.
6178 
6179 IMPORTANT: ALGLIB version 3.11 and later allows you to specify a set of
6180  per-dimension scales. Interpolation radii are multiplied by the
6181  scale vector. It may be useful if you have mixed spatio-temporal
6182  data (say, a set of 3D slices recorded at different times).
6183  You should call rbfsetpointsandscales() function to use this
6184  feature.
6185 
6186 INPUT PARAMETERS:
6187  S - RBF model, initialized by rbfcreate() call.
6188  XY - points, array[N,NX+NY]. One row corresponds to one point
6189  in the dataset. First NX elements are coordinates, next
6190  NY elements are function values. Array may be larger than
6191  specified, in this case only leading [N,NX+NY] elements
6192  will be used.
6193  N - number of points in the dataset
6194 
6195 After you've added dataset and (optionally) tuned algorithm settings you
6196 should call rbfbuildmodel() in order to build a model for you.
6197 
6198 NOTE: dataset added by this function is not saved during model serialization.
6199  MODEL ITSELF is serialized, but data used to build it are not.
6200 
6201  So, if you 1) add dataset to empty RBF model, 2) serialize and
6202  unserialize it, then you will get an empty RBF model with no dataset
6203  being attached.
6204 
6205  From the other side, if you call rbfbuildmodel() between (1) and (2),
6206  then after (2) you will get your fully constructed RBF model - but
6207  again with no dataset attached, so subsequent calls to rbfbuildmodel()
6208  will produce empty model.
6209 
6210 
6211  -- ALGLIB --
6212  Copyright 13.12.2011 by Bochkanov Sergey
6213 *************************************************************************/
6214 void rbfsetpoints(const rbfmodel &s, const real_2d_array &xy, const ae_int_t n);
6215 void rbfsetpoints(const rbfmodel &s, const real_2d_array &xy);
6216 
6217 
6218 /*************************************************************************
6219 This function adds dataset and a vector of per-dimension scales.
6220 
6221 It may be useful if you have mixed spatio-temporal data - say, a set of 3D
6222 slices recorded at different times. Such data typically require different
6223 RBF radii for spatial and temporal dimensions. ALGLIB solves this problem
6224 by specifying single RBF radius, which is (optionally) multiplied by the
6225 scale vector.
6226 
6227 This function overrides results of the previous calls, i.e. multiple calls
6228 of this function will result in only the last set being added.
6229 
6230 IMPORTANT: only HierarchicalRBF algorithm can work with scaled points. So,
6231  using this function results in RBF models which can be used in
6232  ALGLIB 3.11 or later. Previous versions of the library will be
6233  unable to unserialize models produced by HierarchicalRBF algo.
6234 
6235  Any attempt to use this function with RBF-ML or QNN algorithms
6236  will result in -3 error code being returned (incorrect
6237  algorithm).
6238 
6239 INPUT PARAMETERS:
6240  R - RBF model, initialized by rbfcreate() call.
6241  XY - points, array[N,NX+NY]. One row corresponds to one point
6242  in the dataset. First NX elements are coordinates, next
6243  NY elements are function values. Array may be larger than
6244  specified, in this case only leading [N,NX+NY] elements
6245  will be used.
6246  N - number of points in the dataset
6247  S - array[NX], scale vector, S[i]>0.
6248 
6249 After you've added dataset and (optionally) tuned algorithm settings you
6250 should call rbfbuildmodel() in order to build a model for you.
6251 
6252 NOTE: dataset added by this function is not saved during model serialization.
6253  MODEL ITSELF is serialized, but data used to build it are not.
6254 
6255  So, if you 1) add dataset to empty RBF model, 2) serialize and
6256  unserialize it, then you will get an empty RBF model with no dataset
6257  being attached.
6258 
6259  From the other side, if you call rbfbuildmodel() between (1) and (2),
6260  then after (2) you will get your fully constructed RBF model - but
6261  again with no dataset attached, so subsequent calls to rbfbuildmodel()
6262  will produce empty model.
6263 
6264 
6265  -- ALGLIB --
6266  Copyright 20.06.2016 by Bochkanov Sergey
6267 *************************************************************************/
6268 void rbfsetpointsandscales(const rbfmodel &r, const real_2d_array &xy, const ae_int_t n, const real_1d_array &s);
6269 void rbfsetpointsandscales(const rbfmodel &r, const real_2d_array &xy, const real_1d_array &s);
6270 
6271 
6272 /*************************************************************************
6273 DEPRECATED:since version 3.11 ALGLIB includes new RBF model construction
6274  algorithm, Hierarchical RBF. This algorithm is faster and
6275  requires less memory than QNN and RBF-ML. It is especially good
6276  for large-scale interpolation problems. So, we recommend you to
6277  consider Hierarchical RBF as default option.
6278 
6279 ==========================================================================
6280 
6281 This function sets RBF interpolation algorithm. ALGLIB supports several
6282 RBF algorithms with different properties.
6283 
6284 This algorithm is called RBF-QNN and it is good for point sets with
6285 following properties:
6286 a) all points are distinct
6287 b) all points are well separated.
6288 c) points distribution is approximately uniform. There is no "contour
6289  lines", clusters of points, or other small-scale structures.
6290 
6291 Algorithm description:
6292 1) interpolation centers are allocated to data points
6293 2) interpolation radii are calculated as distances to the nearest centers
6294  times Q coefficient (where Q is a value from [0.75,1.50]).
6295 3) after performing (2) radii are transformed in order to avoid situation
6296  when single outlier has very large radius and influences many points
6297  across all dataset. Transformation has following form:
6298  new_r[i] = min(r[i],Z*median(r[]))
6299  where r[i] is I-th radius, median() is a median radius across entire
6300  dataset, Z is user-specified value which controls amount of deviation
6301  from median radius.
6302 
6303 When (a) is violated, we will be unable to build RBF model. When (b) or
6304 (c) are violated, model will be built, but interpolation quality will be
6305 low. See http://www.alglib.net/interpolation/ for more information on this
6306 subject.
6307 
6308 This algorithm is used by default.
6309 
6310 Additional Q parameter controls smoothness properties of the RBF basis:
6311 * Q<0.75 will give perfectly conditioned basis, but terrible smoothness
6312  properties (RBF interpolant will have sharp peaks around function values)
6313 * Q around 1.0 gives good balance between smoothness and condition number
6314 * Q>1.5 will lead to badly conditioned systems and slow convergence of the
6315  underlying linear solver (although smoothness will be very good)
6316 * Q>2.0 will effectively make optimizer useless because it won't converge
6317  within reasonable amount of iterations. It is possible to set such large
6318  Q, but it is advised not to do so.
6319 
6320 INPUT PARAMETERS:
6321  S - RBF model, initialized by RBFCreate() call
6322  Q - Q parameter, Q>0, recommended value - 1.0
6323  Z - Z parameter, Z>0, recommended value - 5.0
6324 
6325 NOTE: this function has some serialization-related subtleties. We
6326  recommend you to study serialization examples from ALGLIB Reference
6327  Manual if you want to perform serialization of your models.
6328 
6329 
6330  -- ALGLIB --
6331  Copyright 13.12.2011 by Bochkanov Sergey
6332 *************************************************************************/
6333 void rbfsetalgoqnn(const rbfmodel &s, const double q, const double z);
6334 void rbfsetalgoqnn(const rbfmodel &s);
6335 
6336 
6337 /*************************************************************************
6338 DEPRECATED:since version 3.11 ALGLIB includes new RBF model construction
6339  algorithm, Hierarchical RBF. This algorithm is faster and
6340  requires less memory than QNN and RBF-ML. It is especially good
6341  for large-scale interpolation problems. So, we recommend you to
6342  consider Hierarchical RBF as default option.
6343 
6344 ==========================================================================
6345 
6346 This function sets RBF interpolation algorithm. ALGLIB supports several
6347 RBF algorithms with different properties.
6348 
6349 This algorithm is called RBF-ML. It builds multilayer RBF model, i.e.
6350 model with subsequently decreasing radii, which allows us to combine
6351 smoothness (due to large radii of the first layers) with exactness (due
6352 to small radii of the last layers) and fast convergence.
6353 
6354 Internally RBF-ML uses many different means of acceleration, from sparse
6355 matrices to KD-trees, which results in algorithm whose working time is
6356 roughly proportional to N*log(N)*Density*RBase^2*NLayers, where N is a
6357 number of points, Density is an average density if points per unit of the
6358 interpolation space, RBase is an initial radius, NLayers is a number of
6359 layers.
6360 
6361 RBF-ML is good for following kinds of interpolation problems:
6362 1. "exact" problems (perfect fit) with well separated points
6363 2. least squares problems with arbitrary distribution of points (algorithm
6364  gives perfect fit where it is possible, and resorts to least squares
6365  fit in the hard areas).
6366 3. noisy problems where we want to apply some controlled amount of
6367  smoothing.
6368 
6369 INPUT PARAMETERS:
6370  S - RBF model, initialized by RBFCreate() call
6371  RBase - RBase parameter, RBase>0
6372  NLayers - NLayers parameter, NLayers>0, recommended value to start
6373  with - about 5.
6374  LambdaV - regularization value, can be useful when solving problem
6375  in the least squares sense. Optimal lambda is problem-
6376  dependent and require trial and error. In our experience,
6377  good lambda can be as large as 0.1, and you can use 0.001
6378  as initial guess.
6379  Default value - 0.01, which is used when LambdaV is not
6380  given. You can specify zero value, but it is not
6381  recommended to do so.
6382 
6383 TUNING ALGORITHM
6384 
6385 In order to use this algorithm you have to choose three parameters:
6386 * initial radius RBase
6387 * number of layers in the model NLayers
6388 * regularization coefficient LambdaV
6389 
6390 Initial radius is easy to choose - you can pick any number several times
6391 larger than the average distance between points. Algorithm won't break
6392 down if you choose radius which is too large (model construction time will
6393 increase, but model will be built correctly).
6394 
6395 Choose such number of layers that RLast=RBase/2^(NLayers-1) (radius used
6396 by the last layer) will be smaller than the typical distance between
6397 points. In case model error is too large, you can increase number of
6398 layers. Having more layers will make model construction and evaluation
6399 proportionally slower, but it will allow you to have model which precisely
6400 fits your data. From the other side, if you want to suppress noise, you
6401 can DECREASE number of layers to make your model less flexible.
6402 
6403 Regularization coefficient LambdaV controls smoothness of the individual
6404 models built for each layer. We recommend you to use default value in case
6405 you don't want to tune this parameter, because having non-zero LambdaV
6406 accelerates and stabilizes internal iterative algorithm. In case you want
6407 to suppress noise you can use LambdaV as additional parameter (larger
6408 value = more smoothness) to tune.
6409 
6410 TYPICAL ERRORS
6411 
6412 1. Using initial radius which is too large. Memory requirements of the
6413  RBF-ML are roughly proportional to N*Density*RBase^2 (where Density is
6414  an average density of points per unit of the interpolation space). In
6415  the extreme case of the very large RBase we will need O(N^2) units of
6416  memory - and many layers in order to decrease radius to some reasonably
6417  small value.
6418 
6419 2. Using too small number of layers - RBF models with large radius are not
6420  flexible enough to reproduce small variations in the target function.
6421  You need many layers with different radii, from large to small, in
6422  order to have good model.
6423 
6424 3. Using initial radius which is too small. You will get model with
6425  "holes" in the areas which are too far away from interpolation centers.
6426  However, algorithm will work correctly (and quickly) in this case.
6427 
6428 4. Using too many layers - you will get too large and too slow model. This
6429  model will perfectly reproduce your function, but maybe you will be
6430  able to achieve similar results with less layers (and less memory).
6431 
6432  -- ALGLIB --
6433  Copyright 02.03.2012 by Bochkanov Sergey
6434 *************************************************************************/
6435 void rbfsetalgomultilayer(const rbfmodel &s, const double rbase, const ae_int_t nlayers, const double lambdav);
6436 void rbfsetalgomultilayer(const rbfmodel &s, const double rbase, const ae_int_t nlayers);
6437 
6438 
6439 /*************************************************************************
6440 This function sets RBF interpolation algorithm. ALGLIB supports several
6441 RBF algorithms with different properties.
6442 
6443 This algorithm is called Hierarchical RBF. It similar to its previous
6444 incarnation, RBF-ML, i.e. it also builds a sequence of models with
6445 decreasing radii. However, it uses more economical way of building upper
6446 layers (ones with large radii), which results in faster model construction
6447 and evaluation, as well as smaller memory footprint during construction.
6448 
6449 This algorithm has following important features:
6450 * ability to handle millions of points
6451 * controllable smoothing via nonlinearity penalization
6452 * support for NX-dimensional models with NX=1 or NX>3 (unlike QNN or RBF-ML)
6453 * support for specification of per-dimensional radii via scale vector,
6454  which is set by means of rbfsetpointsandscales() function. This feature
6455  is useful if you solve spatio-temporal interpolation problems, where
6456  different radii are required for spatial and temporal dimensions.
6457 
6458 Running times are roughly proportional to:
6459 * N*log(N)*NLayers - for model construction
6460 * N*NLayers - for model evaluation
6461 You may see that running time does not depend on search radius or points
6462 density, just on number of layers in the hierarchy.
6463 
6464 IMPORTANT: this model construction algorithm was introduced in ALGLIB 3.11
6465  and produces models which are INCOMPATIBLE with previous
6466  versions of ALGLIB. You can not unserialize models produced
6467  with this function in ALGLIB 3.10 or earlier.
6468 
6469 INPUT PARAMETERS:
6470  S - RBF model, initialized by rbfcreate() call
6471  RBase - RBase parameter, RBase>0
6472  NLayers - NLayers parameter, NLayers>0, recommended value to start
6473  with - about 5.
6474  LambdaNS- >=0, nonlinearity penalty coefficient, negative values are
6475  not allowed. This parameter adds controllable smoothing to
6476  the problem, which may reduce noise. Specification of non-
6477  zero lambda means that in addition to fitting error solver
6478  will also minimize LambdaNS*|S''(x)|^2 (appropriately
6479  generalized to multiple dimensions.
6480 
6481  Specification of exactly zero value means that no penalty
6482  is added (we do not even evaluate matrix of second
6483  derivatives which is necessary for smoothing).
6484 
6485  Calculation of nonlinearity penalty is costly - it results
6486  in several-fold increase of model construction time.
6487  Evaluation time remains the same.
6488 
6489  Optimal lambda is problem-dependent and requires trial
6490  and error. Good value to start from is 1e-5...1e-6,
6491  which corresponds to slightly noticeable smoothing of the
6492  function. Value 1e-2 usually means that quite heavy
6493  smoothing is applied.
6494 
6495 TUNING ALGORITHM
6496 
6497 In order to use this algorithm you have to choose three parameters:
6498 * initial radius RBase
6499 * number of layers in the model NLayers
6500 * penalty coefficient LambdaNS
6501 
6502 Initial radius is easy to choose - you can pick any number several times
6503 larger than the average distance between points. Algorithm won't break
6504 down if you choose radius which is too large (model construction time will
6505 increase, but model will be built correctly).
6506 
6507 Choose such number of layers that RLast=RBase/2^(NLayers-1) (radius used
6508 by the last layer) will be smaller than the typical distance between
6509 points. In case model error is too large, you can increase number of
6510 layers. Having more layers will make model construction and evaluation
6511 proportionally slower, but it will allow you to have model which precisely
6512 fits your data. From the other side, if you want to suppress noise, you
6513 can DECREASE number of layers to make your model less flexible (or specify
6514 non-zero LambdaNS).
6515 
6516 TYPICAL ERRORS
6517 
6518 1. Using too small number of layers - RBF models with large radius are not
6519  flexible enough to reproduce small variations in the target function.
6520  You need many layers with different radii, from large to small, in
6521  order to have good model.
6522 
6523 2. Using initial radius which is too small. You will get model with
6524  "holes" in the areas which are too far away from interpolation centers.
6525  However, algorithm will work correctly (and quickly) in this case.
6526 
6527  -- ALGLIB --
6528  Copyright 20.06.2016 by Bochkanov Sergey
6529 *************************************************************************/
6530 void rbfsetalgohierarchical(const rbfmodel &s, const double rbase, const ae_int_t nlayers, const double lambdans);
6531 
6532 
6533 /*************************************************************************
6534 This function sets linear term (model is a sum of radial basis functions
6535 plus linear polynomial). This function won't have effect until next call
6536 to RBFBuildModel().
6537 
6538 INPUT PARAMETERS:
6539  S - RBF model, initialized by RBFCreate() call
6540 
6541 NOTE: this function has some serialization-related subtleties. We
6542  recommend you to study serialization examples from ALGLIB Reference
6543  Manual if you want to perform serialization of your models.
6544 
6545  -- ALGLIB --
6546  Copyright 13.12.2011 by Bochkanov Sergey
6547 *************************************************************************/
6548 void rbfsetlinterm(const rbfmodel &s);
6549 
6550 
6551 /*************************************************************************
6552 This function sets constant term (model is a sum of radial basis functions
6553 plus constant). This function won't have effect until next call to
6554 RBFBuildModel().
6555 
6556 INPUT PARAMETERS:
6557  S - RBF model, initialized by RBFCreate() call
6558 
6559 NOTE: this function has some serialization-related subtleties. We
6560  recommend you to study serialization examples from ALGLIB Reference
6561  Manual if you want to perform serialization of your models.
6562 
6563  -- ALGLIB --
6564  Copyright 13.12.2011 by Bochkanov Sergey
6565 *************************************************************************/
6566 void rbfsetconstterm(const rbfmodel &s);
6567 
6568 
6569 /*************************************************************************
6570 This function sets zero term (model is a sum of radial basis functions
6571 without polynomial term). This function won't have effect until next call
6572 to RBFBuildModel().
6573 
6574 INPUT PARAMETERS:
6575  S - RBF model, initialized by RBFCreate() call
6576 
6577 NOTE: this function has some serialization-related subtleties. We
6578  recommend you to study serialization examples from ALGLIB Reference
6579  Manual if you want to perform serialization of your models.
6580 
6581  -- ALGLIB --
6582  Copyright 13.12.2011 by Bochkanov Sergey
6583 *************************************************************************/
6584 void rbfsetzeroterm(const rbfmodel &s);
6585 
6586 
6587 /*************************************************************************
6588 This function sets basis function type, which can be:
6589 * 0 for classic Gaussian
6590 * 1 for fast and compact bell-like basis function, which becomes exactly
6591  zero at distance equal to 3*R (default option).
6592 
6593 INPUT PARAMETERS:
6594  S - RBF model, initialized by RBFCreate() call
6595  BF - basis function type:
6596  * 0 - classic Gaussian
6597  * 1 - fast and compact one
6598 
6599  -- ALGLIB --
6600  Copyright 01.02.2017 by Bochkanov Sergey
6601 *************************************************************************/
6602 void rbfsetv2bf(const rbfmodel &s, const ae_int_t bf);
6603 
6604 
6605 /*************************************************************************
6606 This function sets stopping criteria of the underlying linear solver for
6607 hierarchical (version 2) RBF constructor.
6608 
6609 INPUT PARAMETERS:
6610  S - RBF model, initialized by RBFCreate() call
6611  MaxIts - this criterion will stop algorithm after MaxIts iterations.
6612  Typically a few hundreds iterations is required, with 400
6613  being a good default value to start experimentation.
6614  Zero value means that default value will be selected.
6615 
6616  -- ALGLIB --
6617  Copyright 01.02.2017 by Bochkanov Sergey
6618 *************************************************************************/
6619 void rbfsetv2its(const rbfmodel &s, const ae_int_t maxits);
6620 
6621 
6622 /*************************************************************************
6623 This function sets support radius parameter of hierarchical (version 2)
6624 RBF constructor.
6625 
6626 Hierarchical RBF model achieves great speed-up by removing from the model
6627 excessive (too dense) nodes. Say, if you have RBF radius equal to 1 meter,
6628 and two nodes are just 1 millimeter apart, you may remove one of them
6629 without reducing model quality.
6630 
6631 Support radius parameter is used to justify which points need removal, and
6632 which do not. If two points are less than SUPPORT_R*CUR_RADIUS units of
6633 distance apart, one of them is removed from the model. The larger support
6634 radius is, the faster model construction AND evaluation are. However,
6635 too large values result in "bumpy" models.
6636 
6637 INPUT PARAMETERS:
6638  S - RBF model, initialized by RBFCreate() call
6639  R - support radius coefficient, >=0.
6640  Recommended values are [0.1,0.4] range, with 0.1 being
6641  default value.
6642 
6643  -- ALGLIB --
6644  Copyright 01.02.2017 by Bochkanov Sergey
6645 *************************************************************************/
6646 void rbfsetv2supportr(const rbfmodel &s, const double r);
6647 
6648 
6649 /*************************************************************************
6650 This function builds RBF model and returns report (contains some
6651 information which can be used for evaluation of the algorithm properties).
6652 
6653 Call to this function modifies RBF model by calculating its centers/radii/
6654 weights and saving them into RBFModel structure. Initially RBFModel
6655 contain zero coefficients, but after call to this function we will have
6656 coefficients which were calculated in order to fit our dataset.
6657 
6658 After you called this function you can call RBFCalc(), RBFGridCalc() and
6659 other model calculation functions.
6660 
6661 INPUT PARAMETERS:
6662  S - RBF model, initialized by RBFCreate() call
6663  Rep - report:
6664  * Rep.TerminationType:
6665  * -5 - non-distinct basis function centers were detected,
6666  interpolation aborted; only QNN returns this
6667  error code, other algorithms can handle non-
6668  distinct nodes.
6669  * -4 - nonconvergence of the internal SVD solver
6670  * -3 incorrect model construction algorithm was chosen:
6671  QNN or RBF-ML, combined with one of the incompatible
6672  features - NX=1 or NX>3; points with per-dimension
6673  scales.
6674  * 1 - successful termination
6675 
6676  Fields which are set only by modern RBF solvers (hierarchical
6677  or nonnegative; older solvers like QNN and ML initialize these
6678  fields by NANs):
6679  * rep.rmserror - root-mean-square error at nodes
6680  * rep.maxerror - maximum error at nodes
6681 
6682  Fields are used for debugging purposes:
6683  * Rep.IterationsCount - iterations count of the LSQR solver
6684  * Rep.NMV - number of matrix-vector products
6685  * Rep.ARows - rows count for the system matrix
6686  * Rep.ACols - columns count for the system matrix
6687  * Rep.ANNZ - number of significantly non-zero elements
6688  (elements above some algorithm-determined threshold)
6689 
6690 NOTE: failure to build model will leave current state of the structure
6691 unchanged.
6692 
6693  -- ALGLIB --
6694  Copyright 13.12.2011 by Bochkanov Sergey
6695 *************************************************************************/
6696 void rbfbuildmodel(const rbfmodel &s, rbfreport &rep);
6697 
6698 
6699 /*************************************************************************
6700 This function calculates values of the RBF model in the given point.
6701 
6702 IMPORTANT: this function works only with modern (hierarchical) RBFs. It
6703  can not be used with legacy (version 1) RBFs because older RBF
6704  code does not support 1-dimensional models.
6705 
6706 This function should be used when we have NY=1 (scalar function) and NX=1
6707 (1-dimensional space). If you have 3-dimensional space, use rbfcalc3(). If
6708 you have 2-dimensional space, use rbfcalc3(). If you have general
6709 situation (NX-dimensional space, NY-dimensional function) you should use
6710 generic rbfcalc().
6711 
6712 If you want to perform parallel model evaluation from multiple threads,
6713 use rbftscalcbuf() with per-thread buffer object.
6714 
6715 This function returns 0.0 when:
6716 * model is not initialized
6717 * NX<>1
6718 * NY<>1
6719 
6720 INPUT PARAMETERS:
6721  S - RBF model
6722  X0 - X-coordinate, finite number
6723 
6724 RESULT:
6725  value of the model or 0.0 (as defined above)
6726 
6727  -- ALGLIB --
6728  Copyright 13.12.2011 by Bochkanov Sergey
6729 *************************************************************************/
6730 double rbfcalc1(const rbfmodel &s, const double x0);
6731 
6732 
6733 /*************************************************************************
6734 This function calculates values of the RBF model in the given point.
6735 
6736 This function should be used when we have NY=1 (scalar function) and NX=2
6737 (2-dimensional space). If you have 3-dimensional space, use rbfcalc3(). If
6738 you have general situation (NX-dimensional space, NY-dimensional function)
6739 you should use generic rbfcalc().
6740 
6741 If you want to calculate function values many times, consider using
6742 rbfgridcalc2v(), which is far more efficient than many subsequent calls to
6743 rbfcalc2().
6744 
6745 If you want to perform parallel model evaluation from multiple threads,
6746 use rbftscalcbuf() with per-thread buffer object.
6747 
6748 This function returns 0.0 when:
6749 * model is not initialized
6750 * NX<>2
6751  *NY<>1
6752 
6753 INPUT PARAMETERS:
6754  S - RBF model
6755  X0 - first coordinate, finite number
6756  X1 - second coordinate, finite number
6757 
6758 RESULT:
6759  value of the model or 0.0 (as defined above)
6760 
6761  -- ALGLIB --
6762  Copyright 13.12.2011 by Bochkanov Sergey
6763 *************************************************************************/
6764 double rbfcalc2(const rbfmodel &s, const double x0, const double x1);
6765 
6766 
6767 /*************************************************************************
6768 This function calculates value of the RBF model in the given point.
6769 
6770 This function should be used when we have NY=1 (scalar function) and NX=3
6771 (3-dimensional space). If you have 2-dimensional space, use rbfcalc2(). If
6772 you have general situation (NX-dimensional space, NY-dimensional function)
6773 you should use generic rbfcalc().
6774 
6775 If you want to calculate function values many times, consider using
6776 rbfgridcalc3v(), which is far more efficient than many subsequent calls to
6777 rbfcalc3().
6778 
6779 If you want to perform parallel model evaluation from multiple threads,
6780 use rbftscalcbuf() with per-thread buffer object.
6781 
6782 This function returns 0.0 when:
6783 * model is not initialized
6784 * NX<>3
6785  *NY<>1
6786 
6787 INPUT PARAMETERS:
6788  S - RBF model
6789  X0 - first coordinate, finite number
6790  X1 - second coordinate, finite number
6791  X2 - third coordinate, finite number
6792 
6793 RESULT:
6794  value of the model or 0.0 (as defined above)
6795 
6796  -- ALGLIB --
6797  Copyright 13.12.2011 by Bochkanov Sergey
6798 *************************************************************************/
6799 double rbfcalc3(const rbfmodel &s, const double x0, const double x1, const double x2);
6800 
6801 
6802 /*************************************************************************
6803 This function calculates values of the RBF model at the given point.
6804 
6805 This is general function which can be used for arbitrary NX (dimension of
6806 the space of arguments) and NY (dimension of the function itself). However
6807 when you have NY=1 you may find more convenient to use rbfcalc2() or
6808 rbfcalc3().
6809 
6810 If you want to perform parallel model evaluation from multiple threads,
6811 use rbftscalcbuf() with per-thread buffer object.
6812 
6813 This function returns 0.0 when model is not initialized.
6814 
6815 INPUT PARAMETERS:
6816  S - RBF model
6817  X - coordinates, array[NX].
6818  X may have more than NX elements, in this case only
6819  leading NX will be used.
6820 
6821 OUTPUT PARAMETERS:
6822  Y - function value, array[NY]. Y is out-parameter and
6823  reallocated after call to this function. In case you want
6824  to reuse previously allocated Y, you may use RBFCalcBuf(),
6825  which reallocates Y only when it is too small.
6826 
6827  -- ALGLIB --
6828  Copyright 13.12.2011 by Bochkanov Sergey
6829 *************************************************************************/
6830 void rbfcalc(const rbfmodel &s, const real_1d_array &x, real_1d_array &y);
6831 
6832 
6833 /*************************************************************************
6834 This function calculates values of the RBF model at the given point.
6835 
6836 Same as rbfcalc(), but does not reallocate Y when in is large enough to
6837 store function values.
6838 
6839 If you want to perform parallel model evaluation from multiple threads,
6840 use rbftscalcbuf() with per-thread buffer object.
6841 
6842 INPUT PARAMETERS:
6843  S - RBF model
6844  X - coordinates, array[NX].
6845  X may have more than NX elements, in this case only
6846  leading NX will be used.
6847  Y - possibly preallocated array
6848 
6849 OUTPUT PARAMETERS:
6850  Y - function value, array[NY]. Y is not reallocated when it
6851  is larger than NY.
6852 
6853  -- ALGLIB --
6854  Copyright 13.12.2011 by Bochkanov Sergey
6855 *************************************************************************/
6856 void rbfcalcbuf(const rbfmodel &s, const real_1d_array &x, real_1d_array &y);
6857 
6858 
6859 /*************************************************************************
6860 This function calculates values of the RBF model at the given point, using
6861 external buffer object (internal temporaries of RBF model are not
6862 modified).
6863 
6864 This function allows to use same RBF model object in different threads,
6865 assuming that different threads use different instances of buffer
6866 structure.
6867 
6868 INPUT PARAMETERS:
6869  S - RBF model, may be shared between different threads
6870  Buf - buffer object created for this particular instance of RBF
6871  model with rbfcreatecalcbuffer().
6872  X - coordinates, array[NX].
6873  X may have more than NX elements, in this case only
6874  leading NX will be used.
6875  Y - possibly preallocated array
6876 
6877 OUTPUT PARAMETERS:
6878  Y - function value, array[NY]. Y is not reallocated when it
6879  is larger than NY.
6880 
6881  -- ALGLIB --
6882  Copyright 13.12.2011 by Bochkanov Sergey
6883 *************************************************************************/
6884 void rbftscalcbuf(const rbfmodel &s, const rbfcalcbuffer &buf, const real_1d_array &x, real_1d_array &y);
6885 
6886 
6887 /*************************************************************************
6888 This is legacy function for gridded calculation of RBF model.
6889 
6890 It is superseded by rbfgridcalc2v() and rbfgridcalc2vsubset() functions.
6891 
6892  -- ALGLIB --
6893  Copyright 13.12.2011 by Bochkanov Sergey
6894 *************************************************************************/
6895 void rbfgridcalc2(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, real_2d_array &y);
6896 
6897 
6898 /*************************************************************************
6899 This function calculates values of the RBF model at the regular grid,
6900 which has N0*N1 points, with Point[I,J] = (X0[I], X1[J]). Vector-valued
6901 RBF models are supported.
6902 
6903 This function returns 0.0 when:
6904 * model is not initialized
6905 * NX<>2
6906 
6907 FOR USERS OF COMMERCIAL EDITION:
6908 
6909  ! Commercial version of ALGLIB includes multicore support (C++ and C#
6910  ! computational cores) for this function.
6911  !
6912  ! Parallel processing gives close-to-linear speedup on multicore systems,
6913  ! assuming that problem is large enough to be divided between cores.
6914  ! You should solve at least 200x200 problem to get nearly-linear speed-
6915  ! up (high efficiency).
6916  !
6917  ! Parallel processing is implemented only for modern (hierarchical)
6918  ! RBFs. Legacy version 1 RBFs (created by QNN or RBF-ML) are still
6919  ! processed serially.
6920  !
6921  ! In order to use multicore features you have to:
6922  ! * use commercial version of ALGLIB
6923  ! * call this function with "smp_" prefix, which indicates that
6924  ! multicore code will be used (for multicore support)
6925  !
6926  ! This note is given for users of commercial edition; if you use GPL
6927  ! edition, you still will be able to call smp-version of this function,
6928  ! but all computations will be done serially.
6929  !
6930  ! We recommend you to carefully read ALGLIB Reference Manual, section
6931  ! called 'SMP support', before using parallel version of this function.
6932 
6933 INPUT PARAMETERS:
6934  S - RBF model, used in read-only mode, can be shared between
6935  multiple invocations of this function from multiple
6936  threads.
6937 
6938  X0 - array of grid nodes, first coordinates, array[N0].
6939  Must be ordered by ascending. Exception is generated
6940  if the array is not correctly ordered.
6941  N0 - grid size (number of nodes) in the first dimension
6942 
6943  X1 - array of grid nodes, second coordinates, array[N1]
6944  Must be ordered by ascending. Exception is generated
6945  if the array is not correctly ordered.
6946  N1 - grid size (number of nodes) in the second dimension
6947 
6948 OUTPUT PARAMETERS:
6949  Y - function values, array[NY*N0*N1], where NY is a number of
6950  "output" vector values (this function supports vector-
6951  valued RBF models). Y is out-variable and is reallocated
6952  by this function.
6953  Y[K+NY*(I0+I1*N0)]=F_k(X0[I0],X1[I1]), for:
6954  * K=0...NY-1
6955  * I0=0...N0-1
6956  * I1=0...N1-1
6957 
6958 NOTE: this function supports weakly ordered grid nodes, i.e. you may have
6959  X[i]=X[i+1] for some i. It does not provide you any performance
6960  benefits due to duplication of points, just convenience and
6961  flexibility.
6962 
6963 NOTE: this function is re-entrant, i.e. you may use same rbfmodel
6964  structure in multiple threads calling this function for different
6965  grids.
6966 
6967 NOTE: if you need function values on some subset of regular grid, which
6968  may be described as "several compact and dense islands", you may
6969  use rbfgridcalc2vsubset().
6970 
6971  -- ALGLIB --
6972  Copyright 27.01.2017 by Bochkanov Sergey
6973 *************************************************************************/
6974 void rbfgridcalc2v(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, real_1d_array &y);
6975 void smp_rbfgridcalc2v(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, real_1d_array &y);
6976 
6977 
6978 /*************************************************************************
6979 This function calculates values of the RBF model at some subset of regular
6980 grid:
6981 * grid has N0*N1 points, with Point[I,J] = (X0[I], X1[J])
6982 * only values at some subset of this grid are required
6983 Vector-valued RBF models are supported.
6984 
6985 This function returns 0.0 when:
6986 * model is not initialized
6987 * NX<>2
6988 
6989 FOR USERS OF COMMERCIAL EDITION:
6990 
6991  ! Commercial version of ALGLIB includes multicore support (C++ and C#
6992  ! computational cores) for this function.
6993  !
6994  ! Parallel processing gives close-to-linear speedup on multicore systems,
6995  ! assuming that problem is large enough to be divided between cores.
6996  ! You should solve at least 200x200 problem to get nearly-linear speed-
6997  ! up (high efficiency).
6998  !
6999  ! Parallel processing is implemented only for modern (hierarchical)
7000  ! RBFs. Legacy version 1 RBFs (created by QNN or RBF-ML) are still
7001  ! processed serially.
7002  !
7003  ! In order to use multicore features you have to:
7004  ! * use commercial version of ALGLIB
7005  ! * call this function with "smp_" prefix, which indicates that
7006  ! multicore code will be used (for multicore support)
7007  !
7008  ! This note is given for users of commercial edition; if you use GPL
7009  ! edition, you still will be able to call smp-version of this function,
7010  ! but all computations will be done serially.
7011  !
7012  ! We recommend you to carefully read ALGLIB Reference Manual, section
7013  ! called 'SMP support', before using parallel version of this function.
7014 
7015 INPUT PARAMETERS:
7016  S - RBF model, used in read-only mode, can be shared between
7017  multiple invocations of this function from multiple
7018  threads.
7019 
7020  X0 - array of grid nodes, first coordinates, array[N0].
7021  Must be ordered by ascending. Exception is generated
7022  if the array is not correctly ordered.
7023  N0 - grid size (number of nodes) in the first dimension
7024 
7025  X1 - array of grid nodes, second coordinates, array[N1]
7026  Must be ordered by ascending. Exception is generated
7027  if the array is not correctly ordered.
7028  N1 - grid size (number of nodes) in the second dimension
7029 
7030  FlagY - array[N0*N1]:
7031  * Y[I0+I1*N0] corresponds to node (X0[I0],X1[I1])
7032  * it is a "bitmap" array which contains False for nodes
7033  which are NOT calculated, and True for nodes which are
7034  required.
7035 
7036 OUTPUT PARAMETERS:
7037  Y - function values, array[NY*N0*N1*N2], where NY is a number
7038  of "output" vector values (this function supports vector-
7039  valued RBF models):
7040  * Y[K+NY*(I0+I1*N0)]=F_k(X0[I0],X1[I1]),
7041  for K=0...NY-1, I0=0...N0-1, I1=0...N1-1.
7042  * elements of Y[] which correspond to FlagY[]=True are
7043  loaded by model values (which may be exactly zero for
7044  some nodes).
7045  * elements of Y[] which correspond to FlagY[]=False MAY be
7046  initialized by zeros OR may be calculated. This function
7047  processes grid as a hierarchy of nested blocks and
7048  micro-rows. If just one element of micro-row is required,
7049  entire micro-row (up to 8 nodes in the current version,
7050  but no promises) is calculated.
7051 
7052 NOTE: this function supports weakly ordered grid nodes, i.e. you may have
7053  X[i]=X[i+1] for some i. It does not provide you any performance
7054  benefits due to duplication of points, just convenience and
7055  flexibility.
7056 
7057 NOTE: this function is re-entrant, i.e. you may use same rbfmodel
7058  structure in multiple threads calling this function for different
7059  grids.
7060 
7061  -- ALGLIB --
7062  Copyright 04.03.2016 by Bochkanov Sergey
7063 *************************************************************************/
7064 void rbfgridcalc2vsubset(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const boolean_1d_array &flagy, real_1d_array &y);
7065 void smp_rbfgridcalc2vsubset(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const boolean_1d_array &flagy, real_1d_array &y);
7066 
7067 
7068 /*************************************************************************
7069 This function calculates values of the RBF model at the regular grid,
7070 which has N0*N1*N2 points, with Point[I,J,K] = (X0[I], X1[J], X2[K]).
7071 Vector-valued RBF models are supported.
7072 
7073 This function returns 0.0 when:
7074 * model is not initialized
7075 * NX<>3
7076 
7077 FOR USERS OF COMMERCIAL EDITION:
7078 
7079  ! Commercial version of ALGLIB includes multicore support (C++ and C#
7080  ! computational cores) for this function.
7081  !
7082  ! Parallel processing gives close-to-linear speedup on multicore systems,
7083  ! assuming that problem is large enough to be divided between cores.
7084  ! You should solve at least 50x50x50 problem to get nearly-linear speed-
7085  ! up (high efficiency).
7086  !
7087  ! In order to use multicore features you have to:
7088  ! * use commercial version of ALGLIB
7089  ! * call this function with "smp_" prefix, which indicates that
7090  ! multicore code will be used (for multicore support)
7091  !
7092  ! This note is given for users of commercial edition; if you use GPL
7093  ! edition, you still will be able to call smp-version of this function,
7094  ! but all computations will be done serially.
7095  !
7096  ! We recommend you to carefully read ALGLIB Reference Manual, section
7097  ! called 'SMP support', before using parallel version of this function.
7098 
7099 INPUT PARAMETERS:
7100  S - RBF model, used in read-only mode, can be shared between
7101  multiple invocations of this function from multiple
7102  threads.
7103 
7104  X0 - array of grid nodes, first coordinates, array[N0].
7105  Must be ordered by ascending. Exception is generated
7106  if the array is not correctly ordered.
7107  N0 - grid size (number of nodes) in the first dimension
7108 
7109  X1 - array of grid nodes, second coordinates, array[N1]
7110  Must be ordered by ascending. Exception is generated
7111  if the array is not correctly ordered.
7112  N1 - grid size (number of nodes) in the second dimension
7113 
7114  X2 - array of grid nodes, third coordinates, array[N2]
7115  Must be ordered by ascending. Exception is generated
7116  if the array is not correctly ordered.
7117  N2 - grid size (number of nodes) in the third dimension
7118 
7119 OUTPUT PARAMETERS:
7120  Y - function values, array[NY*N0*N1*N2], where NY is a number
7121  of "output" vector values (this function supports vector-
7122  valued RBF models). Y is out-variable and is reallocated
7123  by this function.
7124  Y[K+NY*(I0+I1*N0+I2*N0*N1)]=F_k(X0[I0],X1[I1],X2[I2]), for:
7125  * K=0...NY-1
7126  * I0=0...N0-1
7127  * I1=0...N1-1
7128  * I2=0...N2-1
7129 
7130 NOTE: this function supports weakly ordered grid nodes, i.e. you may have
7131  X[i]=X[i+1] for some i. It does not provide you any performance
7132  benefits due to duplication of points, just convenience and
7133  flexibility.
7134 
7135 NOTE: this function is re-entrant, i.e. you may use same rbfmodel
7136  structure in multiple threads calling this function for different
7137  grids.
7138 
7139 NOTE: if you need function values on some subset of regular grid, which
7140  may be described as "several compact and dense islands", you may
7141  use rbfgridcalc3vsubset().
7142 
7143  -- ALGLIB --
7144  Copyright 04.03.2016 by Bochkanov Sergey
7145 *************************************************************************/
7146 void rbfgridcalc3v(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y);
7147 void smp_rbfgridcalc3v(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y);
7148 
7149 
7150 /*************************************************************************
7151 This function calculates values of the RBF model at some subset of regular
7152 grid:
7153 * grid has N0*N1*N2 points, with Point[I,J,K] = (X0[I], X1[J], X2[K])
7154 * only values at some subset of this grid are required
7155 Vector-valued RBF models are supported.
7156 
7157 This function returns 0.0 when:
7158 * model is not initialized
7159 * NX<>3
7160 
7161 FOR USERS OF COMMERCIAL EDITION:
7162 
7163  ! Commercial version of ALGLIB includes multicore support (C++ and C#
7164  ! computational cores) for this function.
7165  !
7166  ! Parallel processing gives close-to-linear speedup on multicore systems,
7167  ! assuming that problem is large enough to be divided between cores.
7168  ! You should solve at least 50x50x50 problem to get nearly-linear speed-
7169  ! up (high efficiency).
7170  !
7171  ! In order to use multicore features you have to:
7172  ! * use commercial version of ALGLIB
7173  ! * call this function with "smp_" prefix, which indicates that
7174  ! multicore code will be used (for multicore support)
7175  !
7176  ! This note is given for users of commercial edition; if you use GPL
7177  ! edition, you still will be able to call smp-version of this function,
7178  ! but all computations will be done serially.
7179  !
7180  ! We recommend you to carefully read ALGLIB Reference Manual, section
7181  ! called 'SMP support', before using parallel version of this function.
7182 
7183 INPUT PARAMETERS:
7184  S - RBF model, used in read-only mode, can be shared between
7185  multiple invocations of this function from multiple
7186  threads.
7187 
7188  X0 - array of grid nodes, first coordinates, array[N0].
7189  Must be ordered by ascending. Exception is generated
7190  if the array is not correctly ordered.
7191  N0 - grid size (number of nodes) in the first dimension
7192 
7193  X1 - array of grid nodes, second coordinates, array[N1]
7194  Must be ordered by ascending. Exception is generated
7195  if the array is not correctly ordered.
7196  N1 - grid size (number of nodes) in the second dimension
7197 
7198  X2 - array of grid nodes, third coordinates, array[N2]
7199  Must be ordered by ascending. Exception is generated
7200  if the array is not correctly ordered.
7201  N2 - grid size (number of nodes) in the third dimension
7202 
7203  FlagY - array[N0*N1*N2]:
7204  * Y[I0+I1*N0+I2*N0*N1] corresponds to node (X0[I0],X1[I1],X2[I2])
7205  * it is a "bitmap" array which contains False for nodes
7206  which are NOT calculated, and True for nodes which are
7207  required.
7208 
7209 OUTPUT PARAMETERS:
7210  Y - function values, array[NY*N0*N1*N2], where NY is a number
7211  of "output" vector values (this function supports vector-
7212  valued RBF models):
7213  * Y[K+NY*(I0+I1*N0+I2*N0*N1)]=F_k(X0[I0],X1[I1],X2[I2]),
7214  for K=0...NY-1, I0=0...N0-1, I1=0...N1-1, I2=0...N2-1.
7215  * elements of Y[] which correspond to FlagY[]=True are
7216  loaded by model values (which may be exactly zero for
7217  some nodes).
7218  * elements of Y[] which correspond to FlagY[]=False MAY be
7219  initialized by zeros OR may be calculated. This function
7220  processes grid as a hierarchy of nested blocks and
7221  micro-rows. If just one element of micro-row is required,
7222  entire micro-row (up to 8 nodes in the current version,
7223  but no promises) is calculated.
7224 
7225 NOTE: this function supports weakly ordered grid nodes, i.e. you may have
7226  X[i]=X[i+1] for some i. It does not provide you any performance
7227  benefits due to duplication of points, just convenience and
7228  flexibility.
7229 
7230 NOTE: this function is re-entrant, i.e. you may use same rbfmodel
7231  structure in multiple threads calling this function for different
7232  grids.
7233 
7234  -- ALGLIB --
7235  Copyright 04.03.2016 by Bochkanov Sergey
7236 *************************************************************************/
7237 void rbfgridcalc3vsubset(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const real_1d_array &x2, const ae_int_t n2, const boolean_1d_array &flagy, real_1d_array &y);
7238 void smp_rbfgridcalc3vsubset(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const real_1d_array &x2, const ae_int_t n2, const boolean_1d_array &flagy, real_1d_array &y);
7239 
7240 
7241 /*************************************************************************
7242 This function "unpacks" RBF model by extracting its coefficients.
7243 
7244 INPUT PARAMETERS:
7245  S - RBF model
7246 
7247 OUTPUT PARAMETERS:
7248  NX - dimensionality of argument
7249  NY - dimensionality of the target function
7250  XWR - model information, array[NC,NX+NY+1].
7251  One row of the array corresponds to one basis function:
7252  * first NX columns - coordinates of the center
7253  * next NY columns - weights, one per dimension of the
7254  function being modelled
7255  For ModelVersion=1:
7256  * last column - radius, same for all dimensions of
7257  the function being modelled
7258  For ModelVersion=2:
7259  * last NX columns - radii, one per dimension
7260  NC - number of the centers
7261  V - polynomial term , array[NY,NX+1]. One row per one
7262  dimension of the function being modelled. First NX
7263  elements are linear coefficients, V[NX] is equal to the
7264  constant part.
7265  ModelVersion-version of the RBF model:
7266  * 1 - for models created by QNN and RBF-ML algorithms,
7267  compatible with ALGLIB 3.10 or earlier.
7268  * 2 - for models created by HierarchicalRBF, requires
7269  ALGLIB 3.11 or later
7270 
7271  -- ALGLIB --
7272  Copyright 13.12.2011 by Bochkanov Sergey
7273 *************************************************************************/
7274 void rbfunpack(const rbfmodel &s, ae_int_t &nx, ae_int_t &ny, real_2d_array &xwr, ae_int_t &nc, real_2d_array &v, ae_int_t &modelversion);
7275 
7276 
7277 /*************************************************************************
7278 This function returns model version.
7279 
7280 INPUT PARAMETERS:
7281  S - RBF model
7282 
7283 RESULT:
7284  * 1 - for models created by QNN and RBF-ML algorithms,
7285  compatible with ALGLIB 3.10 or earlier.
7286  * 2 - for models created by HierarchicalRBF, requires
7287  ALGLIB 3.11 or later
7288 
7289  -- ALGLIB --
7290  Copyright 06.07.2016 by Bochkanov Sergey
7291 *************************************************************************/
7293 }
7294 
7296 //
7297 // THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (FUNCTIONS)
7298 //
7300 namespace alglib_impl
7301 {
7303  /* Real */ ae_vector* x,
7304  ae_state *_state);
7306  ae_int_t n,
7307  ae_int_t nx,
7308  ae_int_t d,
7309  ae_int_t nq,
7310  ae_int_t nw,
7311  idwinterpolant* z,
7312  ae_state *_state);
7314  ae_int_t n,
7315  ae_int_t nx,
7316  double r,
7317  idwinterpolant* z,
7318  ae_state *_state);
7319 void idwbuildnoisy(/* Real */ ae_matrix* xy,
7320  ae_int_t n,
7321  ae_int_t nx,
7322  ae_int_t d,
7323  ae_int_t nq,
7324  ae_int_t nw,
7325  idwinterpolant* z,
7326  ae_state *_state);
7327 void _idwinterpolant_init(void* _p, ae_state *_state);
7328 void _idwinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
7329 void _idwinterpolant_clear(void* _p);
7332  double t,
7333  ae_state *_state);
7335  double t,
7336  double* f,
7337  double* df,
7338  ae_state *_state);
7340  double t,
7341  double* f,
7342  double* df,
7343  double* d2f,
7344  ae_state *_state);
7346  double ca,
7347  double cb,
7348  ae_state *_state);
7350  double ca,
7351  double cb,
7352  ae_state *_state);
7354  ae_int_t* n,
7355  /* Real */ ae_vector* x,
7356  /* Real */ ae_vector* y,
7357  /* Real */ ae_vector* w,
7358  ae_state *_state);
7359 void barycentricbuildxyw(/* Real */ ae_vector* x,
7360  /* Real */ ae_vector* y,
7361  /* Real */ ae_vector* w,
7362  ae_int_t n,
7364  ae_state *_state);
7366  /* Real */ ae_vector* y,
7367  ae_int_t n,
7368  ae_int_t d,
7370  ae_state *_state);
7373  ae_state *_state);
7374 void _barycentricinterpolant_init(void* _p, ae_state *_state);
7375 void _barycentricinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
7378 void spline1dbuildlinear(/* Real */ ae_vector* x,
7379  /* Real */ ae_vector* y,
7380  ae_int_t n,
7382  ae_state *_state);
7383 void spline1dbuildcubic(/* Real */ ae_vector* x,
7384  /* Real */ ae_vector* y,
7385  ae_int_t n,
7386  ae_int_t boundltype,
7387  double boundl,
7388  ae_int_t boundrtype,
7389  double boundr,
7391  ae_state *_state);
7393  /* Real */ ae_vector* y,
7394  ae_int_t n,
7395  ae_int_t boundltype,
7396  double boundl,
7397  ae_int_t boundrtype,
7398  double boundr,
7399  /* Real */ ae_vector* d,
7400  ae_state *_state);
7402  /* Real */ ae_vector* y,
7403  ae_int_t n,
7404  ae_int_t boundltype,
7405  double boundl,
7406  ae_int_t boundrtype,
7407  double boundr,
7408  /* Real */ ae_vector* d1,
7409  /* Real */ ae_vector* d2,
7410  ae_state *_state);
7411 void spline1dconvcubic(/* Real */ ae_vector* x,
7412  /* Real */ ae_vector* y,
7413  ae_int_t n,
7414  ae_int_t boundltype,
7415  double boundl,
7416  ae_int_t boundrtype,
7417  double boundr,
7418  /* Real */ ae_vector* x2,
7419  ae_int_t n2,
7420  /* Real */ ae_vector* y2,
7421  ae_state *_state);
7423  /* Real */ ae_vector* y,
7424  ae_int_t n,
7425  ae_int_t boundltype,
7426  double boundl,
7427  ae_int_t boundrtype,
7428  double boundr,
7429  /* Real */ ae_vector* x2,
7430  ae_int_t n2,
7431  /* Real */ ae_vector* y2,
7432  /* Real */ ae_vector* d2,
7433  ae_state *_state);
7435  /* Real */ ae_vector* y,
7436  ae_int_t n,
7437  ae_int_t boundltype,
7438  double boundl,
7439  ae_int_t boundrtype,
7440  double boundr,
7441  /* Real */ ae_vector* x2,
7442  ae_int_t n2,
7443  /* Real */ ae_vector* y2,
7444  /* Real */ ae_vector* d2,
7445  /* Real */ ae_vector* dd2,
7446  ae_state *_state);
7448  /* Real */ ae_vector* y,
7449  ae_int_t n,
7450  ae_int_t boundtype,
7451  double tension,
7453  ae_state *_state);
7454 void spline1dbuildhermite(/* Real */ ae_vector* x,
7455  /* Real */ ae_vector* y,
7456  /* Real */ ae_vector* d,
7457  ae_int_t n,
7459  ae_state *_state);
7460 void spline1dbuildakima(/* Real */ ae_vector* x,
7461  /* Real */ ae_vector* y,
7462  ae_int_t n,
7464  ae_state *_state);
7465 double spline1dcalc(spline1dinterpolant* c, double x, ae_state *_state);
7467  double x,
7468  double* s,
7469  double* ds,
7470  double* d2s,
7471  ae_state *_state);
7473  spline1dinterpolant* cc,
7474  ae_state *_state);
7476  ae_int_t* n,
7477  /* Real */ ae_matrix* tbl,
7478  ae_state *_state);
7480  double a,
7481  double b,
7482  ae_state *_state);
7484  double a,
7485  double b,
7486  ae_state *_state);
7488  double x,
7489  ae_state *_state);
7490 void spline1dconvdiffinternal(/* Real */ ae_vector* xold,
7491  /* Real */ ae_vector* yold,
7492  /* Real */ ae_vector* dold,
7493  ae_int_t n,
7494  /* Real */ ae_vector* x2,
7495  ae_int_t n2,
7496  /* Real */ ae_vector* y,
7497  ae_bool needy,
7498  /* Real */ ae_vector* d1,
7499  ae_bool needd1,
7500  /* Real */ ae_vector* d2,
7501  ae_bool needd2,
7502  ae_state *_state);
7504  /* Real */ ae_vector* r,
7505  ae_int_t* nr,
7506  ae_bool* dr,
7507  /* Real */ ae_vector* e,
7508  /* Integer */ ae_vector* et,
7509  ae_int_t* ne,
7510  ae_bool* de,
7511  ae_state *_state);
7512 void heapsortdpoints(/* Real */ ae_vector* x,
7513  /* Real */ ae_vector* y,
7514  /* Real */ ae_vector* d,
7515  ae_int_t n,
7516  ae_state *_state);
7517 void solvepolinom2(double p0,
7518  double m0,
7519  double p1,
7520  double m1,
7521  double* x0,
7522  double* x1,
7523  ae_int_t* nr,
7524  ae_state *_state);
7525 void solvecubicpolinom(double pa,
7526  double ma,
7527  double pb,
7528  double mb,
7529  double a,
7530  double b,
7531  double* x0,
7532  double* x1,
7533  double* x2,
7534  double* ex0,
7535  double* ex1,
7536  ae_int_t* nr,
7537  ae_int_t* ne,
7538  /* Real */ ae_vector* tempdata,
7539  ae_state *_state);
7541  double ma,
7542  double pb,
7543  double mb,
7544  double a,
7545  double b,
7546  double* x,
7547  ae_state *_state);
7549  /* Real */ ae_vector* y,
7550  ae_int_t n,
7552  ae_state *_state);
7553 void _spline1dinterpolant_init(void* _p, ae_state *_state);
7554 void _spline1dinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
7557 void pspline2build(/* Real */ ae_matrix* xy,
7558  ae_int_t n,
7559  ae_int_t st,
7560  ae_int_t pt,
7562  ae_state *_state);
7563 void pspline3build(/* Real */ ae_matrix* xy,
7564  ae_int_t n,
7565  ae_int_t st,
7566  ae_int_t pt,
7568  ae_state *_state);
7569 void pspline2buildperiodic(/* Real */ ae_matrix* xy,
7570  ae_int_t n,
7571  ae_int_t st,
7572  ae_int_t pt,
7574  ae_state *_state);
7575 void pspline3buildperiodic(/* Real */ ae_matrix* xy,
7576  ae_int_t n,
7577  ae_int_t st,
7578  ae_int_t pt,
7580  ae_state *_state);
7582  ae_int_t* n,
7583  /* Real */ ae_vector* t,
7584  ae_state *_state);
7586  ae_int_t* n,
7587  /* Real */ ae_vector* t,
7588  ae_state *_state);
7590  double t,
7591  double* x,
7592  double* y,
7593  ae_state *_state);
7595  double t,
7596  double* x,
7597  double* y,
7598  double* z,
7599  ae_state *_state);
7601  double t,
7602  double* x,
7603  double* y,
7604  ae_state *_state);
7606  double t,
7607  double* x,
7608  double* y,
7609  double* z,
7610  ae_state *_state);
7612  double t,
7613  double* x,
7614  double* dx,
7615  double* y,
7616  double* dy,
7617  ae_state *_state);
7619  double t,
7620  double* x,
7621  double* dx,
7622  double* y,
7623  double* dy,
7624  double* z,
7625  double* dz,
7626  ae_state *_state);
7628  double t,
7629  double* x,
7630  double* dx,
7631  double* d2x,
7632  double* y,
7633  double* dy,
7634  double* d2y,
7635  ae_state *_state);
7637  double t,
7638  double* x,
7639  double* dx,
7640  double* d2x,
7641  double* y,
7642  double* dy,
7643  double* d2y,
7644  double* z,
7645  double* dz,
7646  double* d2z,
7647  ae_state *_state);
7649  double a,
7650  double b,
7651  ae_state *_state);
7653  double a,
7654  double b,
7655  ae_state *_state);
7656 void parametricrdpfixed(/* Real */ ae_matrix* x,
7657  ae_int_t n,
7658  ae_int_t d,
7659  ae_int_t stopm,
7660  double stopeps,
7661  /* Real */ ae_matrix* x2,
7662  /* Integer */ ae_vector* idx2,
7663  ae_int_t* nsections,
7664  ae_state *_state);
7665 void _pspline2interpolant_init(void* _p, ae_state *_state);
7666 void _pspline2interpolant_init_copy(void* _dst, void* _src, ae_state *_state);
7669 void _pspline3interpolant_init(void* _p, ae_state *_state);
7670 void _pspline3interpolant_init_copy(void* _dst, void* _src, ae_state *_state);
7674  double x,
7675  double y,
7676  double z,
7677  ae_state *_state);
7679  double ax,
7680  double bx,
7681  double ay,
7682  double by,
7683  double az,
7684  double bz,
7685  ae_state *_state);
7687  double a,
7688  double b,
7689  ae_state *_state);
7691  spline3dinterpolant* cc,
7692  ae_state *_state);
7694  ae_int_t oldzcount,
7695  ae_int_t oldycount,
7696  ae_int_t oldxcount,
7697  ae_int_t newzcount,
7698  ae_int_t newycount,
7699  ae_int_t newxcount,
7700  /* Real */ ae_vector* b,
7701  ae_state *_state);
7703  ae_int_t n,
7704  /* Real */ ae_vector* y,
7705  ae_int_t m,
7706  /* Real */ ae_vector* z,
7707  ae_int_t l,
7708  /* Real */ ae_vector* f,
7709  ae_int_t d,
7711  ae_state *_state);
7713  double x,
7714  double y,
7715  double z,
7716  /* Real */ ae_vector* f,
7717  ae_state *_state);
7719  double x,
7720  double y,
7721  double z,
7722  /* Real */ ae_vector* f,
7723  ae_state *_state);
7725  ae_int_t* n,
7726  ae_int_t* m,
7727  ae_int_t* l,
7728  ae_int_t* d,
7729  ae_int_t* stype,
7730  /* Real */ ae_matrix* tbl,
7731  ae_state *_state);
7732 void _spline3dinterpolant_init(void* _p, ae_state *_state);
7733 void _spline3dinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
7737  double a,
7738  double b,
7739  /* Real */ ae_vector* t,
7740  ae_state *_state);
7741 void polynomialcheb2bar(/* Real */ ae_vector* t,
7742  ae_int_t n,
7743  double a,
7744  double b,
7746  ae_state *_state);
7748  double c,
7749  double s,
7750  /* Real */ ae_vector* a,
7751  ae_state *_state);
7752 void polynomialpow2bar(/* Real */ ae_vector* a,
7753  ae_int_t n,
7754  double c,
7755  double s,
7757  ae_state *_state);
7758 void polynomialbuild(/* Real */ ae_vector* x,
7759  /* Real */ ae_vector* y,
7760  ae_int_t n,
7762  ae_state *_state);
7764  double b,
7765  /* Real */ ae_vector* y,
7766  ae_int_t n,
7768  ae_state *_state);
7769 void polynomialbuildcheb1(double a,
7770  double b,
7771  /* Real */ ae_vector* y,
7772  ae_int_t n,
7774  ae_state *_state);
7775 void polynomialbuildcheb2(double a,
7776  double b,
7777  /* Real */ ae_vector* y,
7778  ae_int_t n,
7780  ae_state *_state);
7781 double polynomialcalceqdist(double a,
7782  double b,
7783  /* Real */ ae_vector* f,
7784  ae_int_t n,
7785  double t,
7786  ae_state *_state);
7787 double polynomialcalccheb1(double a,
7788  double b,
7789  /* Real */ ae_vector* f,
7790  ae_int_t n,
7791  double t,
7792  ae_state *_state);
7793 double polynomialcalccheb2(double a,
7794  double b,
7795  /* Real */ ae_vector* f,
7796  ae_int_t n,
7797  double t,
7798  ae_state *_state);
7800  /* Real */ ae_vector* y,
7801  ae_int_t n,
7802  ae_int_t m,
7803  /* Real */ ae_vector* x2,
7804  /* Real */ ae_vector* y2,
7805  ae_int_t* nsections,
7806  ae_state *_state);
7808  /* Real */ ae_vector* y,
7809  ae_int_t n,
7810  double eps,
7811  /* Real */ ae_vector* x2,
7812  /* Real */ ae_vector* y2,
7813  ae_int_t* nsections,
7814  ae_state *_state);
7815 void polynomialfit(/* Real */ ae_vector* x,
7816  /* Real */ ae_vector* y,
7817  ae_int_t n,
7818  ae_int_t m,
7819  ae_int_t* info,
7821  polynomialfitreport* rep,
7822  ae_state *_state);
7823 void _pexec_polynomialfit(/* Real */ ae_vector* x,
7824  /* Real */ ae_vector* y,
7825  ae_int_t n,
7826  ae_int_t m,
7827  ae_int_t* info,
7829  polynomialfitreport* rep, ae_state *_state);
7830 void polynomialfitwc(/* Real */ ae_vector* x,
7831  /* Real */ ae_vector* y,
7832  /* Real */ ae_vector* w,
7833  ae_int_t n,
7834  /* Real */ ae_vector* xc,
7835  /* Real */ ae_vector* yc,
7836  /* Integer */ ae_vector* dc,
7837  ae_int_t k,
7838  ae_int_t m,
7839  ae_int_t* info,
7841  polynomialfitreport* rep,
7842  ae_state *_state);
7844  /* Real */ ae_vector* y,
7845  /* Real */ ae_vector* w,
7846  ae_int_t n,
7847  /* Real */ ae_vector* xc,
7848  /* Real */ ae_vector* yc,
7849  /* Integer */ ae_vector* dc,
7850  ae_int_t k,
7851  ae_int_t m,
7852  ae_int_t* info,
7854  polynomialfitreport* rep, ae_state *_state);
7855 double logisticcalc4(double x,
7856  double a,
7857  double b,
7858  double c,
7859  double d,
7860  ae_state *_state);
7861 double logisticcalc5(double x,
7862  double a,
7863  double b,
7864  double c,
7865  double d,
7866  double g,
7867  ae_state *_state);
7868 void logisticfit4(/* Real */ ae_vector* x,
7869  /* Real */ ae_vector* y,
7870  ae_int_t n,
7871  double* a,
7872  double* b,
7873  double* c,
7874  double* d,
7875  lsfitreport* rep,
7876  ae_state *_state);
7877 void logisticfit4ec(/* Real */ ae_vector* x,
7878  /* Real */ ae_vector* y,
7879  ae_int_t n,
7880  double cnstrleft,
7881  double cnstrright,
7882  double* a,
7883  double* b,
7884  double* c,
7885  double* d,
7886  lsfitreport* rep,
7887  ae_state *_state);
7888 void logisticfit5(/* Real */ ae_vector* x,
7889  /* Real */ ae_vector* y,
7890  ae_int_t n,
7891  double* a,
7892  double* b,
7893  double* c,
7894  double* d,
7895  double* g,
7896  lsfitreport* rep,
7897  ae_state *_state);
7898 void logisticfit5ec(/* Real */ ae_vector* x,
7899  /* Real */ ae_vector* y,
7900  ae_int_t n,
7901  double cnstrleft,
7902  double cnstrright,
7903  double* a,
7904  double* b,
7905  double* c,
7906  double* d,
7907  double* g,
7908  lsfitreport* rep,
7909  ae_state *_state);
7910 void logisticfit45x(/* Real */ ae_vector* x,
7911  /* Real */ ae_vector* y,
7912  ae_int_t n,
7913  double cnstrleft,
7914  double cnstrright,
7915  ae_bool is4pl,
7916  double lambdav,
7917  double epsx,
7918  ae_int_t rscnt,
7919  double* a,
7920  double* b,
7921  double* c,
7922  double* d,
7923  double* g,
7924  lsfitreport* rep,
7925  ae_state *_state);
7927  /* Real */ ae_vector* y,
7928  /* Real */ ae_vector* w,
7929  ae_int_t n,
7930  /* Real */ ae_vector* xc,
7931  /* Real */ ae_vector* yc,
7932  /* Integer */ ae_vector* dc,
7933  ae_int_t k,
7934  ae_int_t m,
7935  ae_int_t* info,
7937  barycentricfitreport* rep,
7938  ae_state *_state);
7940  /* Real */ ae_vector* y,
7941  /* Real */ ae_vector* w,
7942  ae_int_t n,
7943  /* Real */ ae_vector* xc,
7944  /* Real */ ae_vector* yc,
7945  /* Integer */ ae_vector* dc,
7946  ae_int_t k,
7947  ae_int_t m,
7948  ae_int_t* info,
7950  barycentricfitreport* rep, ae_state *_state);
7952  /* Real */ ae_vector* y,
7953  ae_int_t n,
7954  ae_int_t m,
7955  ae_int_t* info,
7957  barycentricfitreport* rep,
7958  ae_state *_state);
7960  /* Real */ ae_vector* y,
7961  ae_int_t n,
7962  ae_int_t m,
7963  ae_int_t* info,
7965  barycentricfitreport* rep, ae_state *_state);
7966 void spline1dfitpenalized(/* Real */ ae_vector* x,
7967  /* Real */ ae_vector* y,
7968  ae_int_t n,
7969  ae_int_t m,
7970  double rho,
7971  ae_int_t* info,
7973  spline1dfitreport* rep,
7974  ae_state *_state);
7976  /* Real */ ae_vector* y,
7977  ae_int_t n,
7978  ae_int_t m,
7979  double rho,
7980  ae_int_t* info,
7982  spline1dfitreport* rep, ae_state *_state);
7984  /* Real */ ae_vector* y,
7985  /* Real */ ae_vector* w,
7986  ae_int_t n,
7987  ae_int_t m,
7988  double rho,
7989  ae_int_t* info,
7991  spline1dfitreport* rep,
7992  ae_state *_state);
7994  /* Real */ ae_vector* y,
7995  /* Real */ ae_vector* w,
7996  ae_int_t n,
7997  ae_int_t m,
7998  double rho,
7999  ae_int_t* info,
8001  spline1dfitreport* rep, ae_state *_state);
8002 void spline1dfitcubicwc(/* Real */ ae_vector* x,
8003  /* Real */ ae_vector* y,
8004  /* Real */ ae_vector* w,
8005  ae_int_t n,
8006  /* Real */ ae_vector* xc,
8007  /* Real */ ae_vector* yc,
8008  /* Integer */ ae_vector* dc,
8009  ae_int_t k,
8010  ae_int_t m,
8011  ae_int_t* info,
8013  spline1dfitreport* rep,
8014  ae_state *_state);
8016  /* Real */ ae_vector* y,
8017  /* Real */ ae_vector* w,
8018  ae_int_t n,
8019  /* Real */ ae_vector* xc,
8020  /* Real */ ae_vector* yc,
8021  /* Integer */ ae_vector* dc,
8022  ae_int_t k,
8023  ae_int_t m,
8024  ae_int_t* info,
8026  spline1dfitreport* rep, ae_state *_state);
8027 void spline1dfithermitewc(/* Real */ ae_vector* x,
8028  /* Real */ ae_vector* y,
8029  /* Real */ ae_vector* w,
8030  ae_int_t n,
8031  /* Real */ ae_vector* xc,
8032  /* Real */ ae_vector* yc,
8033  /* Integer */ ae_vector* dc,
8034  ae_int_t k,
8035  ae_int_t m,
8036  ae_int_t* info,
8038  spline1dfitreport* rep,
8039  ae_state *_state);
8041  /* Real */ ae_vector* y,
8042  /* Real */ ae_vector* w,
8043  ae_int_t n,
8044  /* Real */ ae_vector* xc,
8045  /* Real */ ae_vector* yc,
8046  /* Integer */ ae_vector* dc,
8047  ae_int_t k,
8048  ae_int_t m,
8049  ae_int_t* info,
8051  spline1dfitreport* rep, ae_state *_state);
8052 void spline1dfitcubic(/* Real */ ae_vector* x,
8053  /* Real */ ae_vector* y,
8054  ae_int_t n,
8055  ae_int_t m,
8056  ae_int_t* info,
8058  spline1dfitreport* rep,
8059  ae_state *_state);
8061  /* Real */ ae_vector* y,
8062  ae_int_t n,
8063  ae_int_t m,
8064  ae_int_t* info,
8066  spline1dfitreport* rep, ae_state *_state);
8067 void spline1dfithermite(/* Real */ ae_vector* x,
8068  /* Real */ ae_vector* y,
8069  ae_int_t n,
8070  ae_int_t m,
8071  ae_int_t* info,
8073  spline1dfitreport* rep,
8074  ae_state *_state);
8076  /* Real */ ae_vector* y,
8077  ae_int_t n,
8078  ae_int_t m,
8079  ae_int_t* info,
8081  spline1dfitreport* rep, ae_state *_state);
8082 void lsfitlinearw(/* Real */ ae_vector* y,
8083  /* Real */ ae_vector* w,
8084  /* Real */ ae_matrix* fmatrix,
8085  ae_int_t n,
8086  ae_int_t m,
8087  ae_int_t* info,
8088  /* Real */ ae_vector* c,
8089  lsfitreport* rep,
8090  ae_state *_state);
8091 void _pexec_lsfitlinearw(/* Real */ ae_vector* y,
8092  /* Real */ ae_vector* w,
8093  /* Real */ ae_matrix* fmatrix,
8094  ae_int_t n,
8095  ae_int_t m,
8096  ae_int_t* info,
8097  /* Real */ ae_vector* c,
8098  lsfitreport* rep, ae_state *_state);
8099 void lsfitlinearwc(/* Real */ ae_vector* y,
8100  /* Real */ ae_vector* w,
8101  /* Real */ ae_matrix* fmatrix,
8102  /* Real */ ae_matrix* cmatrix,
8103  ae_int_t n,
8104  ae_int_t m,
8105  ae_int_t k,
8106  ae_int_t* info,
8107  /* Real */ ae_vector* c,
8108  lsfitreport* rep,
8109  ae_state *_state);
8110 void _pexec_lsfitlinearwc(/* Real */ ae_vector* y,
8111  /* Real */ ae_vector* w,
8112  /* Real */ ae_matrix* fmatrix,
8113  /* Real */ ae_matrix* cmatrix,
8114  ae_int_t n,
8115  ae_int_t m,
8116  ae_int_t k,
8117  ae_int_t* info,
8118  /* Real */ ae_vector* c,
8119  lsfitreport* rep, ae_state *_state);
8120 void lsfitlinear(/* Real */ ae_vector* y,
8121  /* Real */ ae_matrix* fmatrix,
8122  ae_int_t n,
8123  ae_int_t m,
8124  ae_int_t* info,
8125  /* Real */ ae_vector* c,
8126  lsfitreport* rep,
8127  ae_state *_state);
8128 void _pexec_lsfitlinear(/* Real */ ae_vector* y,
8129  /* Real */ ae_matrix* fmatrix,
8130  ae_int_t n,
8131  ae_int_t m,
8132  ae_int_t* info,
8133  /* Real */ ae_vector* c,
8134  lsfitreport* rep, ae_state *_state);
8135 void lsfitlinearc(/* Real */ ae_vector* y,
8136  /* Real */ ae_matrix* fmatrix,
8137  /* Real */ ae_matrix* cmatrix,
8138  ae_int_t n,
8139  ae_int_t m,
8140  ae_int_t k,
8141  ae_int_t* info,
8142  /* Real */ ae_vector* c,
8143  lsfitreport* rep,
8144  ae_state *_state);
8145 void _pexec_lsfitlinearc(/* Real */ ae_vector* y,
8146  /* Real */ ae_matrix* fmatrix,
8147  /* Real */ ae_matrix* cmatrix,
8148  ae_int_t n,
8149  ae_int_t m,
8150  ae_int_t k,
8151  ae_int_t* info,
8152  /* Real */ ae_vector* c,
8153  lsfitreport* rep, ae_state *_state);
8154 void lsfitcreatewf(/* Real */ ae_matrix* x,
8155  /* Real */ ae_vector* y,
8156  /* Real */ ae_vector* w,
8157  /* Real */ ae_vector* c,
8158  ae_int_t n,
8159  ae_int_t m,
8160  ae_int_t k,
8161  double diffstep,
8162  lsfitstate* state,
8163  ae_state *_state);
8164 void lsfitcreatef(/* Real */ ae_matrix* x,
8165  /* Real */ ae_vector* y,
8166  /* Real */ ae_vector* c,
8167  ae_int_t n,
8168  ae_int_t m,
8169  ae_int_t k,
8170  double diffstep,
8171  lsfitstate* state,
8172  ae_state *_state);
8173 void lsfitcreatewfg(/* Real */ ae_matrix* x,
8174  /* Real */ ae_vector* y,
8175  /* Real */ ae_vector* w,
8176  /* Real */ ae_vector* c,
8177  ae_int_t n,
8178  ae_int_t m,
8179  ae_int_t k,
8180  ae_bool cheapfg,
8181  lsfitstate* state,
8182  ae_state *_state);
8183 void lsfitcreatefg(/* Real */ ae_matrix* x,
8184  /* Real */ ae_vector* y,
8185  /* Real */ ae_vector* c,
8186  ae_int_t n,
8187  ae_int_t m,
8188  ae_int_t k,
8189  ae_bool cheapfg,
8190  lsfitstate* state,
8191  ae_state *_state);
8192 void lsfitcreatewfgh(/* Real */ ae_matrix* x,
8193  /* Real */ ae_vector* y,
8194  /* Real */ ae_vector* w,
8195  /* Real */ ae_vector* c,
8196  ae_int_t n,
8197  ae_int_t m,
8198  ae_int_t k,
8199  lsfitstate* state,
8200  ae_state *_state);
8201 void lsfitcreatefgh(/* Real */ ae_matrix* x,
8202  /* Real */ ae_vector* y,
8203  /* Real */ ae_vector* c,
8204  ae_int_t n,
8205  ae_int_t m,
8206  ae_int_t k,
8207  lsfitstate* state,
8208  ae_state *_state);
8210  double epsx,
8211  ae_int_t maxits,
8212  ae_state *_state);
8213 void lsfitsetstpmax(lsfitstate* state, double stpmax, ae_state *_state);
8214 void lsfitsetxrep(lsfitstate* state, ae_bool needxrep, ae_state *_state);
8216  /* Real */ ae_vector* s,
8217  ae_state *_state);
8219  /* Real */ ae_vector* bndl,
8220  /* Real */ ae_vector* bndu,
8221  ae_state *_state);
8223  /* Real */ ae_matrix* c,
8224  /* Integer */ ae_vector* ct,
8225  ae_int_t k,
8226  ae_state *_state);
8229  ae_int_t* info,
8230  /* Real */ ae_vector* c,
8231  lsfitreport* rep,
8232  ae_state *_state);
8234  double teststep,
8235  ae_state *_state);
8236 void lsfitscalexy(/* Real */ ae_vector* x,
8237  /* Real */ ae_vector* y,
8238  /* Real */ ae_vector* w,
8239  ae_int_t n,
8240  /* Real */ ae_vector* xc,
8241  /* Real */ ae_vector* yc,
8242  /* Integer */ ae_vector* dc,
8243  ae_int_t k,
8244  double* xa,
8245  double* xb,
8246  double* sa,
8247  double* sb,
8248  /* Real */ ae_vector* xoriginal,
8249  /* Real */ ae_vector* yoriginal,
8250  ae_state *_state);
8251 void _polynomialfitreport_init(void* _p, ae_state *_state);
8252 void _polynomialfitreport_init_copy(void* _dst, void* _src, ae_state *_state);
8255 void _barycentricfitreport_init(void* _p, ae_state *_state);
8256 void _barycentricfitreport_init_copy(void* _dst, void* _src, ae_state *_state);
8259 void _spline1dfitreport_init(void* _p, ae_state *_state);
8260 void _spline1dfitreport_init_copy(void* _dst, void* _src, ae_state *_state);
8263 void _lsfitreport_init(void* _p, ae_state *_state);
8264 void _lsfitreport_init_copy(void* _dst, void* _src, ae_state *_state);
8265 void _lsfitreport_clear(void* _p);
8266 void _lsfitreport_destroy(void* _p);
8267 void _lsfitstate_init(void* _p, ae_state *_state);
8268 void _lsfitstate_init_copy(void* _dst, void* _src, ae_state *_state);
8269 void _lsfitstate_clear(void* _p);
8270 void _lsfitstate_destroy(void* _p);
8272  ae_int_t ny,
8273  rbfv2model* s,
8274  ae_state *_state);
8276  rbfv2calcbuffer* buf,
8277  ae_state *_state);
8279  /* Real */ ae_matrix* y,
8280  ae_int_t n,
8281  /* Real */ ae_vector* scalevec,
8282  ae_int_t aterm,
8283  ae_int_t nh,
8284  double rbase,
8285  double lambdans,
8286  ae_bool nonnegative,
8287  ae_int_t nnmaxits,
8288  rbfv2model* s,
8289  rbfv2report* rep,
8290  ae_state *_state);
8291 void rbfv2alloc(ae_serializer* s, rbfv2model* model, ae_state *_state);
8294  rbfv2model* model,
8295  ae_state *_state);
8296 double rbfv2farradius(ae_int_t bf, ae_state *_state);
8297 double rbfv2nearradius(ae_int_t bf, ae_state *_state);
8298 double rbfv2basisfunc(ae_int_t bf, double d2, ae_state *_state);
8300  double d2,
8301  double* f,
8302  double* df,
8303  double* d2f,
8304  ae_state *_state);
8305 double rbfv2calc1(rbfv2model* s, double x0, ae_state *_state);
8306 double rbfv2calc2(rbfv2model* s, double x0, double x1, ae_state *_state);
8308  double x0,
8309  double x1,
8310  double x2,
8311  ae_state *_state);
8313  /* Real */ ae_vector* x,
8314  /* Real */ ae_vector* y,
8315  ae_state *_state);
8317  rbfv2calcbuffer* buf,
8318  /* Real */ ae_vector* x,
8319  /* Real */ ae_vector* y,
8320  ae_state *_state);
8322  /* Real */ ae_vector* x0,
8323  ae_int_t n0,
8324  /* Real */ ae_vector* x1,
8325  ae_int_t n1,
8326  /* Real */ ae_matrix* y,
8327  ae_state *_state);
8329  /* Real */ ae_vector* x0,
8330  ae_int_t n0,
8331  /* Real */ ae_vector* x1,
8332  ae_int_t n1,
8333  /* Real */ ae_vector* x2,
8334  ae_int_t n2,
8335  /* Real */ ae_vector* x3,
8336  ae_int_t n3,
8337  /* Boolean */ ae_vector* flagy,
8338  ae_bool sparsey,
8339  /* Real */ ae_vector* y,
8340  ae_state *_state);
8342  /* Real */ ae_vector* x0,
8343  ae_int_t n0,
8344  /* Real */ ae_vector* x1,
8345  ae_int_t n1,
8346  /* Real */ ae_vector* x2,
8347  ae_int_t n2,
8348  /* Real */ ae_vector* x3,
8349  ae_int_t n3,
8350  /* Integer */ ae_vector* blocks0,
8351  ae_int_t block0a,
8352  ae_int_t block0b,
8353  /* Integer */ ae_vector* blocks1,
8354  ae_int_t block1a,
8355  ae_int_t block1b,
8356  /* Integer */ ae_vector* blocks2,
8357  ae_int_t block2a,
8358  ae_int_t block2b,
8359  /* Integer */ ae_vector* blocks3,
8360  ae_int_t block3a,
8361  ae_int_t block3b,
8362  /* Boolean */ ae_vector* flagy,
8363  ae_bool sparsey,
8364  ae_int_t levelidx,
8365  double avgfuncpernode,
8366  ae_shared_pool* bufpool,
8367  /* Real */ ae_vector* y,
8368  ae_state *_state);
8370  ae_int_t* nx,
8371  ae_int_t* ny,
8372  /* Real */ ae_matrix* xwr,
8373  ae_int_t* nc,
8374  /* Real */ ae_matrix* v,
8375  ae_state *_state);
8376 void _rbfv2calcbuffer_init(void* _p, ae_state *_state);
8377 void _rbfv2calcbuffer_init_copy(void* _dst, void* _src, ae_state *_state);
8378 void _rbfv2calcbuffer_clear(void* _p);
8380 void _rbfv2model_init(void* _p, ae_state *_state);
8381 void _rbfv2model_init_copy(void* _dst, void* _src, ae_state *_state);
8382 void _rbfv2model_clear(void* _p);
8383 void _rbfv2model_destroy(void* _p);
8384 void _rbfv2gridcalcbuffer_init(void* _p, ae_state *_state);
8385 void _rbfv2gridcalcbuffer_init_copy(void* _dst, void* _src, ae_state *_state);
8388 void _rbfv2report_init(void* _p, ae_state *_state);
8389 void _rbfv2report_init_copy(void* _dst, void* _src, ae_state *_state);
8390 void _rbfv2report_clear(void* _p);
8391 void _rbfv2report_destroy(void* _p);
8392 void nsfitspheremcc(/* Real */ ae_matrix* xy,
8393  ae_int_t npoints,
8394  ae_int_t nx,
8395  /* Real */ ae_vector* cx,
8396  double* rhi,
8397  ae_state *_state);
8398 void nsfitspheremic(/* Real */ ae_matrix* xy,
8399  ae_int_t npoints,
8400  ae_int_t nx,
8401  /* Real */ ae_vector* cx,
8402  double* rlo,
8403  ae_state *_state);
8404 void nsfitspheremzc(/* Real */ ae_matrix* xy,
8405  ae_int_t npoints,
8406  ae_int_t nx,
8407  /* Real */ ae_vector* cx,
8408  double* rlo,
8409  double* rhi,
8410  ae_state *_state);
8411 void nsfitspherex(/* Real */ ae_matrix* xy,
8412  ae_int_t npoints,
8413  ae_int_t nx,
8414  ae_int_t problemtype,
8415  double epsx,
8416  ae_int_t aulits,
8417  double penalty,
8418  /* Real */ ae_vector* cx,
8419  double* rlo,
8420  double* rhi,
8421  ae_state *_state);
8422 void nsfitsphereinternal(/* Real */ ae_matrix* xy,
8423  ae_int_t npoints,
8424  ae_int_t nx,
8425  ae_int_t problemtype,
8426  ae_int_t solvertype,
8427  double epsx,
8428  ae_int_t aulits,
8429  double penalty,
8430  /* Real */ ae_vector* cx,
8431  double* rlo,
8432  double* rhi,
8433  nsfitinternalreport* rep,
8434  ae_state *_state);
8435 void _nsfitinternalreport_init(void* _p, ae_state *_state);
8436 void _nsfitinternalreport_init_copy(void* _dst, void* _src, ae_state *_state);
8440  double x,
8441  double y,
8442  ae_state *_state);
8444  double x,
8445  double y,
8446  double* f,
8447  double* fx,
8448  double* fy,
8449  double* fxy,
8450  ae_state *_state);
8452  double ax,
8453  double bx,
8454  double ay,
8455  double by,
8456  ae_state *_state);
8458  double a,
8459  double b,
8460  ae_state *_state);
8462  spline2dinterpolant* cc,
8463  ae_state *_state);
8465  ae_int_t oldheight,
8466  ae_int_t oldwidth,
8467  /* Real */ ae_matrix* b,
8468  ae_int_t newheight,
8469  ae_int_t newwidth,
8470  ae_state *_state);
8472  ae_int_t oldheight,
8473  ae_int_t oldwidth,
8474  /* Real */ ae_matrix* b,
8475  ae_int_t newheight,
8476  ae_int_t newwidth,
8477  ae_state *_state);
8479  ae_int_t n,
8480  /* Real */ ae_vector* y,
8481  ae_int_t m,
8482  /* Real */ ae_vector* f,
8483  ae_int_t d,
8485  ae_state *_state);
8487  ae_int_t n,
8488  /* Real */ ae_vector* y,
8489  ae_int_t m,
8490  /* Real */ ae_vector* f,
8491  ae_int_t d,
8493  ae_state *_state);
8495  double x,
8496  double y,
8497  /* Real */ ae_vector* f,
8498  ae_state *_state);
8500  double x,
8501  double y,
8502  /* Real */ ae_vector* f,
8503  ae_state *_state);
8505  ae_int_t* m,
8506  ae_int_t* n,
8507  ae_int_t* d,
8508  /* Real */ ae_matrix* tbl,
8509  ae_state *_state);
8511  /* Real */ ae_vector* y,
8512  /* Real */ ae_matrix* f,
8513  ae_int_t m,
8514  ae_int_t n,
8516  ae_state *_state);
8517 void spline2dbuildbicubic(/* Real */ ae_vector* x,
8518  /* Real */ ae_vector* y,
8519  /* Real */ ae_matrix* f,
8520  ae_int_t m,
8521  ae_int_t n,
8523  ae_state *_state);
8525  ae_int_t* m,
8526  ae_int_t* n,
8527  /* Real */ ae_matrix* tbl,
8528  ae_state *_state);
8529 void _spline2dinterpolant_init(void* _p, ae_state *_state);
8530 void _spline2dinterpolant_init_copy(void* _dst, void* _src, ae_state *_state);
8534  ae_int_t ny,
8535  rbfv1model* s,
8536  ae_state *_state);
8538  rbfv1calcbuffer* buf,
8539  ae_state *_state);
8540 void rbfv1buildmodel(/* Real */ ae_matrix* x,
8541  /* Real */ ae_matrix* y,
8542  ae_int_t n,
8543  ae_int_t aterm,
8544  ae_int_t algorithmtype,
8545  ae_int_t nlayers,
8546  double radvalue,
8547  double radzvalue,
8548  double lambdav,
8549  double epsort,
8550  double epserr,
8551  ae_int_t maxits,
8552  rbfv1model* s,
8553  rbfv1report* rep,
8554  ae_state *_state);
8555 void rbfv1alloc(ae_serializer* s, rbfv1model* model, ae_state *_state);
8558  rbfv1model* model,
8559  ae_state *_state);
8560 double rbfv1calc2(rbfv1model* s, double x0, double x1, ae_state *_state);
8562  double x0,
8563  double x1,
8564  double x2,
8565  ae_state *_state);
8567  /* Real */ ae_vector* x,
8568  /* Real */ ae_vector* y,
8569  ae_state *_state);
8571  rbfv1calcbuffer* buf,
8572  /* Real */ ae_vector* x,
8573  /* Real */ ae_vector* y,
8574  ae_state *_state);
8576  /* Real */ ae_vector* x0,
8577  ae_int_t n0,
8578  /* Real */ ae_vector* x1,
8579  ae_int_t n1,
8580  /* Real */ ae_matrix* y,
8581  ae_state *_state);
8583  /* Real */ ae_vector* x0,
8584  ae_int_t n0,
8585  /* Real */ ae_vector* x1,
8586  ae_int_t n1,
8587  /* Real */ ae_vector* x2,
8588  ae_int_t n2,
8589  /* Integer */ ae_vector* blocks0,
8590  ae_int_t block0a,
8591  ae_int_t block0b,
8592  /* Integer */ ae_vector* blocks1,
8593  ae_int_t block1a,
8594  ae_int_t block1b,
8595  /* Integer */ ae_vector* blocks2,
8596  ae_int_t block2a,
8597  ae_int_t block2b,
8598  /* Boolean */ ae_vector* flagy,
8599  ae_bool sparsey,
8600  double searchradius,
8601  double avgfuncpernode,
8602  ae_shared_pool* bufpool,
8603  /* Real */ ae_vector* y,
8604  ae_state *_state);
8606  ae_int_t* nx,
8607  ae_int_t* ny,
8608  /* Real */ ae_matrix* xwr,
8609  ae_int_t* nc,
8610  /* Real */ ae_matrix* v,
8611  ae_state *_state);
8612 void _rbfv1calcbuffer_init(void* _p, ae_state *_state);
8613 void _rbfv1calcbuffer_init_copy(void* _dst, void* _src, ae_state *_state);
8614 void _rbfv1calcbuffer_clear(void* _p);
8616 void _rbfv1model_init(void* _p, ae_state *_state);
8617 void _rbfv1model_init_copy(void* _dst, void* _src, ae_state *_state);
8618 void _rbfv1model_clear(void* _p);
8619 void _rbfv1model_destroy(void* _p);
8620 void _gridcalc3v1buf_init(void* _p, ae_state *_state);
8621 void _gridcalc3v1buf_init_copy(void* _dst, void* _src, ae_state *_state);
8622 void _gridcalc3v1buf_clear(void* _p);
8624 void _rbfv1report_init(void* _p, ae_state *_state);
8625 void _rbfv1report_init_copy(void* _dst, void* _src, ae_state *_state);
8626 void _rbfv1report_clear(void* _p);
8627 void _rbfv1report_destroy(void* _p);
8628 void rbfcreate(ae_int_t nx, ae_int_t ny, rbfmodel* s, ae_state *_state);
8630  rbfcalcbuffer* buf,
8631  ae_state *_state);
8633  /* Real */ ae_matrix* xy,
8634  ae_int_t n,
8635  ae_state *_state);
8637  /* Real */ ae_matrix* xy,
8638  ae_int_t n,
8639  /* Real */ ae_vector* s,
8640  ae_state *_state);
8641 void rbfsetalgoqnn(rbfmodel* s, double q, double z, ae_state *_state);
8643  double rbase,
8644  ae_int_t nlayers,
8645  double lambdav,
8646  ae_state *_state);
8648  double rbase,
8649  ae_int_t nlayers,
8650  double lambdans,
8651  ae_state *_state);
8652 void rbfsetlinterm(rbfmodel* s, ae_state *_state);
8655 void rbfsetv2bf(rbfmodel* s, ae_int_t bf, ae_state *_state);
8656 void rbfsetv2its(rbfmodel* s, ae_int_t maxits, ae_state *_state);
8657 void rbfsetv2supportr(rbfmodel* s, double r, ae_state *_state);
8659  double epsort,
8660  double epserr,
8661  ae_int_t maxits,
8662  ae_state *_state);
8663 void rbfbuildmodel(rbfmodel* s, rbfreport* rep, ae_state *_state);
8664 double rbfcalc1(rbfmodel* s, double x0, ae_state *_state);
8665 double rbfcalc2(rbfmodel* s, double x0, double x1, ae_state *_state);
8666 double rbfcalc3(rbfmodel* s,
8667  double x0,
8668  double x1,
8669  double x2,
8670  ae_state *_state);
8672  /* Real */ ae_vector* x,
8673  /* Real */ ae_vector* y,
8674  ae_state *_state);
8676  /* Real */ ae_vector* x,
8677  /* Real */ ae_vector* y,
8678  ae_state *_state);
8680  rbfcalcbuffer* buf,
8681  /* Real */ ae_vector* x,
8682  /* Real */ ae_vector* y,
8683  ae_state *_state);
8685  /* Real */ ae_vector* x0,
8686  ae_int_t n0,
8687  /* Real */ ae_vector* x1,
8688  ae_int_t n1,
8689  /* Real */ ae_matrix* y,
8690  ae_state *_state);
8692  /* Real */ ae_vector* x0,
8693  ae_int_t n0,
8694  /* Real */ ae_vector* x1,
8695  ae_int_t n1,
8696  /* Real */ ae_vector* y,
8697  ae_state *_state);
8699  /* Real */ ae_vector* x0,
8700  ae_int_t n0,
8701  /* Real */ ae_vector* x1,
8702  ae_int_t n1,
8703  /* Real */ ae_vector* y, ae_state *_state);
8705  /* Real */ ae_vector* x0,
8706  ae_int_t n0,
8707  /* Real */ ae_vector* x1,
8708  ae_int_t n1,
8709  /* Boolean */ ae_vector* flagy,
8710  /* Real */ ae_vector* y,
8711  ae_state *_state);
8713  /* Real */ ae_vector* x0,
8714  ae_int_t n0,
8715  /* Real */ ae_vector* x1,
8716  ae_int_t n1,
8717  /* Boolean */ ae_vector* flagy,
8718  /* Real */ ae_vector* y, ae_state *_state);
8720  /* Real */ ae_vector* x0,
8721  ae_int_t n0,
8722  /* Real */ ae_vector* x1,
8723  ae_int_t n1,
8724  /* Real */ ae_vector* x2,
8725  ae_int_t n2,
8726  /* Real */ ae_vector* y,
8727  ae_state *_state);
8729  /* Real */ ae_vector* x0,
8730  ae_int_t n0,
8731  /* Real */ ae_vector* x1,
8732  ae_int_t n1,
8733  /* Real */ ae_vector* x2,
8734  ae_int_t n2,
8735  /* Real */ ae_vector* y, ae_state *_state);
8737  /* Real */ ae_vector* x0,
8738  ae_int_t n0,
8739  /* Real */ ae_vector* x1,
8740  ae_int_t n1,
8741  /* Real */ ae_vector* x2,
8742  ae_int_t n2,
8743  /* Boolean */ ae_vector* flagy,
8744  /* Real */ ae_vector* y,
8745  ae_state *_state);
8747  /* Real */ ae_vector* x0,
8748  ae_int_t n0,
8749  /* Real */ ae_vector* x1,
8750  ae_int_t n1,
8751  /* Real */ ae_vector* x2,
8752  ae_int_t n2,
8753  /* Boolean */ ae_vector* flagy,
8754  /* Real */ ae_vector* y, ae_state *_state);
8756  /* Real */ ae_vector* x0,
8757  ae_int_t n0,
8758  /* Real */ ae_vector* x1,
8759  ae_int_t n1,
8760  /* Boolean */ ae_vector* flagy,
8761  ae_bool sparsey,
8762  /* Real */ ae_vector* y,
8763  ae_state *_state);
8765  /* Real */ ae_vector* x0,
8766  ae_int_t n0,
8767  /* Real */ ae_vector* x1,
8768  ae_int_t n1,
8769  /* Real */ ae_vector* x2,
8770  ae_int_t n2,
8771  /* Boolean */ ae_vector* flagy,
8772  ae_bool sparsey,
8773  /* Real */ ae_vector* y,
8774  ae_state *_state);
8776  ae_int_t* nx,
8777  ae_int_t* ny,
8778  /* Real */ ae_matrix* xwr,
8779  ae_int_t* nc,
8780  /* Real */ ae_matrix* v,
8781  ae_int_t* modelversion,
8782  ae_state *_state);
8784 void rbfalloc(ae_serializer* s, rbfmodel* model, ae_state *_state);
8785 void rbfserialize(ae_serializer* s, rbfmodel* model, ae_state *_state);
8786 void rbfunserialize(ae_serializer* s, rbfmodel* model, ae_state *_state);
8787 void _rbfcalcbuffer_init(void* _p, ae_state *_state);
8788 void _rbfcalcbuffer_init_copy(void* _dst, void* _src, ae_state *_state);
8789 void _rbfcalcbuffer_clear(void* _p);
8790 void _rbfcalcbuffer_destroy(void* _p);
8791 void _rbfmodel_init(void* _p, ae_state *_state);
8792 void _rbfmodel_init_copy(void* _dst, void* _src, ae_state *_state);
8793 void _rbfmodel_clear(void* _p);
8794 void _rbfmodel_destroy(void* _p);
8795 void _rbfreport_init(void* _p, ae_state *_state);
8796 void _rbfreport_init_copy(void* _dst, void* _src, ae_state *_state);
8797 void _rbfreport_clear(void* _p);
8798 void _rbfreport_destroy(void* _p);
8799 
8800 }
8801 #endif
8802 
void polynomialbuild(ae_vector *x, ae_vector *y, ae_int_t n, barycentricinterpolant *p, ae_state *_state)
void spline1dconvdiffcubic(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, ae_vector *x2, ae_int_t n2, ae_vector *y2, ae_vector *d2, ae_state *_state)
void _rbfv2model_init(void *_p, ae_state *_state)
void _nsfitinternalreport_init(void *_p, ae_state *_state)
spline1dinterpolant & operator=(const spline1dinterpolant &rhs)
void rbfv1serialize(ae_serializer *s, rbfv1model *model, ae_state *_state)
pspline3interpolant & operator=(const pspline3interpolant &rhs)
void spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void spline2dlintransf(const spline2dinterpolant &c, const double a, const double b)
void spline2dbuildbilinearv(ae_vector *x, ae_int_t n, ae_vector *y, ae_int_t m, ae_vector *f, ae_int_t d, spline2dinterpolant *c, ae_state *_state)
void lsfitfit(lsfitstate &state, void(*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr), void(*rep)(const real_1d_array &c, double func, void *ptr)=NULL, void *ptr=NULL)
void rbfsetalgomultilayer(const rbfmodel &s, const double rbase, const ae_int_t nlayers, const double lambdav)
double rbfcalc3(rbfmodel *s, double x0, double x1, double x2, ae_state *_state)
alglib_impl::pspline2interpolant * p_struct
void lsfitcreatewfgh(ae_matrix *x, ae_vector *y, ae_vector *w, ae_vector *c, ae_int_t n, ae_int_t m, ae_int_t k, lsfitstate *state, ae_state *_state)
spline2dinterpolant & operator=(const spline2dinterpolant &rhs)
alglib_impl::rbfmodel * c_ptr()
void _lsfitstate_init(void *_p, ae_state *_state)
double pspline2arclength(const pspline2interpolant &p, const double a, const double b)
void _rbfv2report_clear(void *_p)
void nsfitspheremic(ae_matrix *xy, ae_int_t npoints, ae_int_t nx, ae_vector *cx, double *rlo, ae_state *_state)
barycentricfitreport(const barycentricfitreport &rhs)
_spline2dinterpolant_owner & operator=(const _spline2dinterpolant_owner &rhs)
void barycentriclintransx(barycentricinterpolant *b, double ca, double cb, ae_state *_state)
void logisticfit45x(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, const bool is4pl, const double lambdav, const double epsx, const ae_int_t rscnt, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep)
void spline1dconvdiffcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2, real_1d_array &d2)
void _rbfv2model_init_copy(void *_dst, void *_src, ae_state *_state)
void spline3dresampletrilinear(const real_1d_array &a, const ae_int_t oldzcount, const ae_int_t oldycount, const ae_int_t oldxcount, const ae_int_t newzcount, const ae_int_t newycount, const ae_int_t newxcount, real_1d_array &b)
void barycentricdiff1(barycentricinterpolant *b, double t, double *f, double *df, ae_state *_state)
void spline2dresamplebilinear(ae_matrix *a, ae_int_t oldheight, ae_int_t oldwidth, ae_matrix *b, ae_int_t newheight, ae_int_t newwidth, ae_state *_state)
void _rbfv2calcbuffer_init(void *_p, ae_state *_state)
double idwcalc(const idwinterpolant &z, const real_1d_array &x)
void rbfcalc(const rbfmodel &s, const real_1d_array &x, real_1d_array &y)
void _spline1dinterpolant_clear(void *_p)
void pspline2build(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline2interpolant &p)
double spline1dcalc(const spline1dinterpolant &c, const double x)
double spline3dcalc(spline3dinterpolant *c, double x, double y, double z, ae_state *_state)
double pspline3arclength(pspline3interpolant *p, double a, double b, ae_state *_state)
void spline2dcopy(const spline2dinterpolant &c, spline2dinterpolant &cc)
void logisticfit4ec(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, double &a, double &b, double &c, double &d, lsfitreport &rep)
void rbfsetconstterm(rbfmodel *s, ae_state *_state)
void spline2dbuildbicubicv(ae_vector *x, ae_int_t n, ae_vector *y, ae_int_t m, ae_vector *f, ae_int_t d, spline2dinterpolant *c, ae_state *_state)
barycentricfitreport & operator=(const barycentricfitreport &rhs)
void spline2ddiff(const spline2dinterpolant &c, const double x, const double y, double &f, double &fx, double &fy, double &fxy)
double spline2dcalc(spline2dinterpolant *c, double x, double y, ae_state *_state)
alglib_impl::pspline2interpolant * c_ptr()
virtual ~lsfitstate()
void spline1dgriddiffcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, real_1d_array &d)
void spline2dbuildbicubic(const real_1d_array &x, const real_1d_array &y, const real_2d_array &f, const ae_int_t m, const ae_int_t n, spline2dinterpolant &c)
void rbfv1gridcalc3vrec(rbfv1model *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *x2, ae_int_t n2, ae_vector *blocks0, ae_int_t block0a, ae_int_t block0b, ae_vector *blocks1, ae_int_t block1a, ae_int_t block1b, ae_vector *blocks2, ae_int_t block2a, ae_int_t block2b, ae_vector *flagy, ae_bool sparsey, double searchradius, double avgfuncpernode, ae_shared_pool *bufpool, ae_vector *y, ae_state *_state)
void barycentricbuildxyw(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, barycentricinterpolant *b, ae_state *_state)
void lstfitpiecewiselinearrdp(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double eps, real_1d_array &x2, real_1d_array &y2, ae_int_t &nsections)
void _rbfv1report_clear(void *_p)
void rbfsetpointsandscales(const rbfmodel &r, const real_2d_array &xy, const ae_int_t n, const real_1d_array &s)
void pspline3calc(const pspline3interpolant &p, const double t, double &x, double &y, double &z)
spline3dinterpolant(const spline3dinterpolant &rhs)
ae_int_t rbfgetmodelversion(const rbfmodel &s)
void lsfitsetlc(lsfitstate *state, ae_matrix *c, ae_vector *ct, ae_int_t k, ae_state *_state)
void _spline1dinterpolant_init(void *_p, ae_state *_state)
alglib_impl::idwinterpolant * p_struct
void smp_rbfgridcalc3vsubset(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const real_1d_array &x2, const ae_int_t n2, const boolean_1d_array &flagy, real_1d_array &y)
void spline2dbuildbilinear(const real_1d_array &x, const real_1d_array &y, const real_2d_array &f, const ae_int_t m, const ae_int_t n, spline2dinterpolant &c)
void rbfcreate(ae_int_t nx, ae_int_t ny, rbfmodel *s, ae_state *_state)
void smp_spline1dfitcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void heapsortdpoints(ae_vector *x, ae_vector *y, ae_vector *d, ae_int_t n, ae_state *_state)
alglib_impl::polynomialfitreport * c_ptr()
double rbfv2calc3(rbfv2model *s, double x0, double x1, double x2, ae_state *_state)
void _pexec_rbfgridcalc3v(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *x2, ae_int_t n2, ae_vector *y, ae_state *_state)
void rbfv1gridcalc2(rbfv1model *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_matrix *y, ae_state *_state)
void smp_lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
void spline3dlintransxyz(spline3dinterpolant *c, double ax, double bx, double ay, double by, double az, double bz, ae_state *_state)
alglib_impl::barycentricinterpolant * p_struct
void _barycentricfitreport_clear(void *_p)
void _barycentricinterpolant_init_copy(void *_dst, void *_src, ae_state *_state)
void _idwinterpolant_init_copy(void *_dst, void *_src, ae_state *_state)
void lsfitlinearw(ae_vector *y, ae_vector *w, ae_matrix *fmatrix, ae_int_t n, ae_int_t m, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
double spline3dcalc(const spline3dinterpolant &c, const double x, const double y, const double z)
void smp_lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
void rbfgridcalc3vsubset(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const real_1d_array &x2, const ae_int_t n2, const boolean_1d_array &flagy, real_1d_array &y)
void _rbfv1calcbuffer_init(void *_p, ae_state *_state)
void _barycentricinterpolant_destroy(void *_p)
lsfitreport & operator=(const lsfitreport &rhs)
double rbfv1calc3(rbfv1model *s, double x0, double x1, double x2, ae_state *_state)
void lsfitsetlc(const lsfitstate &state, const real_2d_array &c, const integer_1d_array &ct, const ae_int_t k)
void logisticfit5ec(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const double cnstrleft, const double cnstrright, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep)
void _rbfcalcbuffer_clear(void *_p)
double pspline2arclength(pspline2interpolant *p, double a, double b, ae_state *_state)
void spline1dfitpenalized(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, double rho, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void smp_barycentricfitfloaterhormann(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep)
void rbfgridcalc2(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, real_2d_array &y)
void lsfitresults(lsfitstate *state, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
void lsfitsetbc(lsfitstate *state, ae_vector *bndl, ae_vector *bndu, ae_state *_state)
void _spline1dinterpolant_destroy(void *_p)
real_1d_array noise
void lsfitcreatefg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const bool cheapfg, lsfitstate &state)
void barycentricbuildfloaterhormann(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t d, barycentricinterpolant *b, ae_state *_state)
void rbfsetv2bf(rbfmodel *s, ae_int_t bf, ae_state *_state)
double rbfv2calc2(rbfv2model *s, double x0, double x1, ae_state *_state)
void _pexec_spline1dfitcubic(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void idwbuildmodifiedshepard(ae_matrix *xy, ae_int_t n, ae_int_t nx, ae_int_t d, ae_int_t nq, ae_int_t nw, idwinterpolant *z, ae_state *_state)
void spline1ddiff(const spline1dinterpolant &c, const double x, double &s, double &ds, double &d2s)
void _nsfitinternalreport_clear(void *_p)
void nsfitspheremcc(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rhi)
void pspline3parametervalues(const pspline3interpolant &p, ae_int_t &n, real_1d_array &t)
void _pspline3interpolant_init(void *_p, ae_state *_state)
double polynomialcalceqdist(double a, double b, ae_vector *f, ae_int_t n, double t, ae_state *_state)
void _spline1dfitreport_destroy(void *_p)
void _rbfv2report_init_copy(void *_dst, void *_src, ae_state *_state)
void spline3dbuildtrilinearv(ae_vector *x, ae_int_t n, ae_vector *y, ae_int_t m, ae_vector *z, ae_int_t l, ae_vector *f, ae_int_t d, spline3dinterpolant *c, ae_state *_state)
bool lsfititeration(const lsfitstate &state)
void rbfsetpoints(const rbfmodel &s, const real_2d_array &xy, const ae_int_t n)
void lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
double polynomialcalccheb1(double a, double b, ae_vector *f, ae_int_t n, double t, ae_state *_state)
double barycentriccalc(const barycentricinterpolant &b, const double t)
void _rbfv1model_init(void *_p, ae_state *_state)
real_2d_array h
void barycentricbuildxyw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, barycentricinterpolant &b)
void spline2dcalcvbuf(spline2dinterpolant *c, double x, double y, ae_vector *f, ae_state *_state)
void spline1dlintransx(spline1dinterpolant *c, double a, double b, ae_state *_state)
void spline2dbuildbilinear(ae_vector *x, ae_vector *y, ae_matrix *f, ae_int_t m, ae_int_t n, spline2dinterpolant *c, ae_state *_state)
pspline3interpolant(const pspline3interpolant &rhs)
void _pexec_lsfitlinearw(ae_vector *y, ae_vector *w, ae_matrix *fmatrix, ae_int_t n, ae_int_t m, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
void polynomialfit(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_int_t *info, barycentricinterpolant *p, polynomialfitreport *rep, ae_state *_state)
double rbfcalc3(const rbfmodel &s, const double x0, const double x1, const double x2)
double polynomialcalceqdist(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t)
void spline2dunpackv(const spline2dinterpolant &c, ae_int_t &m, ae_int_t &n, ae_int_t &d, real_2d_array &tbl)
void spline1ddiff(spline1dinterpolant *c, double x, double *s, double *ds, double *d2s, ae_state *_state)
void parametricrdpfixed(ae_matrix *x, ae_int_t n, ae_int_t d, ae_int_t stopm, double stopeps, ae_matrix *x2, ae_vector *idx2, ae_int_t *nsections, ae_state *_state)
void _pexec_lsfitlinearwc(ae_vector *y, ae_vector *w, ae_matrix *fmatrix, ae_matrix *cmatrix, ae_int_t n, ae_int_t m, ae_int_t k, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
void lsfitcreatefg(ae_matrix *x, ae_vector *y, ae_vector *c, ae_int_t n, ae_int_t m, ae_int_t k, ae_bool cheapfg, lsfitstate *state, ae_state *_state)
void _rbfv1model_clear(void *_p)
void lstfitpiecewiselinearrdpfixed(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, real_1d_array &x2, real_1d_array &y2, ae_int_t &nsections)
void rbfv2serialize(ae_serializer *s, rbfv2model *model, ae_state *_state)
void spline2dlintransf(spline2dinterpolant *c, double a, double b, ae_state *_state)
void spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void rbfgridcalc3v(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y)
void spline1dbuildmonotone(ae_vector *x, ae_vector *y, ae_int_t n, spline1dinterpolant *c, ae_state *_state)
void rbfv2alloc(ae_serializer *s, rbfv2model *model, ae_state *_state)
void rbfsetzeroterm(rbfmodel *s, ae_state *_state)
void rbfsetalgohierarchical(const rbfmodel &s, const double rbase, const ae_int_t nlayers, const double lambdans)
void _spline1dfitreport_init(void *_p, ae_state *_state)
void _lsfitreport_init(void *_p, ae_state *_state)
void _pexec_spline1dfitcubicwc(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void polynomialpow2bar(const real_1d_array &a, const ae_int_t n, const double c, const double s, barycentricinterpolant &p)
void pspline2diff2(pspline2interpolant *p, double t, double *x, double *dx, double *d2x, double *y, double *dy, double *d2y, ae_state *_state)
real_1d_array errcurve
double logisticcalc5(double x, double a, double b, double c, double d, double g, ae_state *_state)
double rbfv2farradius(ae_int_t bf, ae_state *_state)
void lsfitlinearwc(ae_vector *y, ae_vector *w, ae_matrix *fmatrix, ae_matrix *cmatrix, ae_int_t n, ae_int_t m, ae_int_t k, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
void rbfsetlinterm(const rbfmodel &s)
void smp_spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void logisticfit4(ae_vector *x, ae_vector *y, ae_int_t n, double *a, double *b, double *c, double *d, lsfitreport *rep, ae_state *_state)
void polynomialpow2bar(ae_vector *a, ae_int_t n, double c, double s, barycentricinterpolant *p, ae_state *_state)
void _polynomialfitreport_clear(void *_p)
real_1d_array errpar
alglib_impl::polynomialfitreport * p_struct
void spline1dbuildakima(ae_vector *x, ae_vector *y, ae_int_t n, spline1dinterpolant *c, ae_state *_state)
ae_int_t rbfgetmodelversion(rbfmodel *s, ae_state *_state)
double rbfcalc2(rbfmodel *s, double x0, double x1, ae_state *_state)
alglib_impl::spline1dfitreport * p_struct
void spline1dbuildmonotone(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c)
spline2dinterpolant(const spline2dinterpolant &rhs)
void lsfitlinearc(const real_1d_array &y, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
void _rbfcalcbuffer_destroy(void *_p)
void rbfgridcalc2vx(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *flagy, ae_bool sparsey, ae_vector *y, ae_state *_state)
void _idwinterpolant_clear(void *_p)
alglib_impl::pspline3interpolant * c_ptr()
_barycentricfitreport_owner & operator=(const _barycentricfitreport_owner &rhs)
_barycentricinterpolant_owner & operator=(const _barycentricinterpolant_owner &rhs)
void idwbuildnoisy(ae_matrix *xy, ae_int_t n, ae_int_t nx, ae_int_t d, ae_int_t nq, ae_int_t nw, idwinterpolant *z, ae_state *_state)
void rbfunserialize(const std::string &s_in, rbfmodel &obj)
void _lsfitstate_init_copy(void *_dst, void *_src, ae_state *_state)
void rbfv2create(ae_int_t nx, ae_int_t ny, rbfv2model *s, ae_state *_state)
void barycentricunpack(barycentricinterpolant *b, ae_int_t *n, ae_vector *x, ae_vector *y, ae_vector *w, ae_state *_state)
void barycentricdiff2(barycentricinterpolant *b, double t, double *f, double *df, double *d2f, ae_state *_state)
void smp_lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
double spline1dintegrate(const spline1dinterpolant &c, const double x)
void _rbfcalcbuffer_init(void *_p, ae_state *_state)
void _rbfreport_init_copy(void *_dst, void *_src, ae_state *_state)
double polynomialcalccheb2(double a, double b, ae_vector *f, ae_int_t n, double t, ae_state *_state)
void rbfgridcalc2(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_matrix *y, ae_state *_state)
void rbfsetzeroterm(const rbfmodel &s)
void rbfv2basisfuncdiff2(ae_int_t bf, double d2, double *f, double *df, double *d2f, ae_state *_state)
void rbfsetconstterm(const rbfmodel &s)
void _pexec_rbfgridcalc2vsubset(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *flagy, ae_vector *y, ae_state *_state)
void _rbfmodel_destroy(void *_p)
polynomialfitreport(const polynomialfitreport &rhs)
void _spline1dfitreport_clear(void *_p)
void lstfitpiecewiselinearrdpfixed(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_vector *x2, ae_vector *y2, ae_int_t *nsections, ae_state *_state)
ae_int_t bisectmethod(double pa, double ma, double pb, double mb, double a, double b, double *x, ae_state *_state)
void polynomialbar2pow(const barycentricinterpolant &p, const double c, const double s, real_1d_array &a)
void _idwinterpolant_init(void *_p, ae_state *_state)
void pspline3calc(pspline3interpolant *p, double t, double *x, double *y, double *z, ae_state *_state)
alglib_impl::lsfitstate * c_ptr()
void polynomialfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep)
void spline2dresamplebicubic(const real_2d_array &a, const ae_int_t oldheight, const ae_int_t oldwidth, real_2d_array &b, const ae_int_t newheight, const ae_int_t newwidth)
void _pexec_rbfgridcalc3vsubset(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *x2, ae_int_t n2, ae_vector *flagy, ae_vector *y, ae_state *_state)
void barycentriccopy(barycentricinterpolant *b, barycentricinterpolant *b2, ae_state *_state)
void lsfitlinearc(ae_vector *y, ae_matrix *fmatrix, ae_matrix *cmatrix, ae_int_t n, ae_int_t m, ae_int_t k, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
void smp_lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
void polynomialbar2cheb(const barycentricinterpolant &p, const double a, const double b, real_1d_array &t)
void polynomialcheb2bar(const real_1d_array &t, const ae_int_t n, const double a, const double b, barycentricinterpolant &p)
alglib_impl::spline2dinterpolant * p_struct
void _rbfv2gridcalcbuffer_destroy(void *_p)
void _rbfv2report_destroy(void *_p)
real_2d_array covpar
void spline2ddiff(spline2dinterpolant *c, double x, double y, double *f, double *fx, double *fy, double *fxy, ae_state *_state)
double pspline3arclength(const pspline3interpolant &p, const double a, const double b)
void spline1dfitcubic(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void _pspline2interpolant_destroy(void *_p)
void rbfgridcalc2v(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *y, ae_state *_state)
double rbfcalc2(const rbfmodel &s, const double x0, const double x1)
_pspline2interpolant_owner & operator=(const _pspline2interpolant_owner &rhs)
void pspline3tangent(const pspline3interpolant &p, const double t, double &x, double &y, double &z)
void barycentricunpack(const barycentricinterpolant &b, ae_int_t &n, real_1d_array &x, real_1d_array &y, real_1d_array &w)
void spline1dbuildhermite(const real_1d_array &x, const real_1d_array &y, const real_1d_array &d, const ae_int_t n, spline1dinterpolant &c)
#define ae_bool
Definition: ap.h:193
polynomialfitreport & operator=(const polynomialfitreport &rhs)
ae_int_t & iterationscount
void smp_spline1dfitcubicwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void smp_spline1dfithermite(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void logisticfit5ec(ae_vector *x, ae_vector *y, ae_int_t n, double cnstrleft, double cnstrright, double *a, double *b, double *c, double *d, double *g, lsfitreport *rep, ae_state *_state)
void logisticfit5(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, double &a, double &b, double &c, double &d, double &g, lsfitreport &rep)
void spline2dunpack(spline2dinterpolant *c, ae_int_t *m, ae_int_t *n, ae_matrix *tbl, ae_state *_state)
void spline3dbuildtrilinearv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &z, const ae_int_t l, const real_1d_array &f, const ae_int_t d, spline3dinterpolant &c)
alglib_impl::barycentricfitreport * c_ptr()
void spline1dfithermite(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void _rbfmodel_clear(void *_p)
lsfitreport(const lsfitreport &rhs)
void spline2dcalcv(const spline2dinterpolant &c, const double x, const double y, real_1d_array &f)
void _spline2dinterpolant_init_copy(void *_dst, void *_src, ae_state *_state)
void polynomialbuildeqdist(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p)
void rbfv2unserialize(ae_serializer *s, rbfv2model *model, ae_state *_state)
void rbfv2gridcalc2(rbfv2model *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_matrix *y, ae_state *_state)
alglib_impl::rbfcalcbuffer * p_struct
void spline1dconvdiffinternal(ae_vector *xold, ae_vector *yold, ae_vector *dold, ae_int_t n, ae_vector *x2, ae_int_t n2, ae_vector *y, ae_bool needy, ae_vector *d1, ae_bool needd1, ae_vector *d2, ae_bool needd2, ae_state *_state)
void _idwinterpolant_destroy(void *_p)
_pspline3interpolant_owner & operator=(const _pspline3interpolant_owner &rhs)
void spline1dconvcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2)
void rbfcalcbuf(rbfmodel *s, ae_vector *x, ae_vector *y, ae_state *_state)
void spline1dgriddiff2cubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, real_1d_array &d1, real_1d_array &d2)
rbfcalcbuffer & operator=(const rbfcalcbuffer &rhs)
void _rbfv2gridcalcbuffer_clear(void *_p)
void spline2dresamplebilinear(const real_2d_array &a, const ae_int_t oldheight, const ae_int_t oldwidth, real_2d_array &b, const ae_int_t newheight, const ae_int_t newwidth)
void _pexec_spline1dfitpenalized(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, double rho, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void pspline3diff2(pspline3interpolant *p, double t, double *x, double *dx, double *d2x, double *y, double *dy, double *d2y, double *z, double *dz, double *d2z, ae_state *_state)
void barycentricbuildfloaterhormann(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t d, barycentricinterpolant &b)
void polynomialbuildcheb2(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p)
void _spline1dinterpolant_init_copy(void *_dst, void *_src, ae_state *_state)
void rbfv1buildmodel(ae_matrix *x, ae_matrix *y, ae_int_t n, ae_int_t aterm, ae_int_t algorithmtype, ae_int_t nlayers, double radvalue, double radzvalue, double lambdav, double epsort, double epserr, ae_int_t maxits, rbfv1model *s, rbfv1report *rep, ae_state *_state)
void spline2dunpack(const spline2dinterpolant &c, ae_int_t &m, ae_int_t &n, real_2d_array &tbl)
void _nsfitinternalreport_init_copy(void *_dst, void *_src, ae_state *_state)
void polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep)
void rbfv1unserialize(ae_serializer *s, rbfv1model *model, ae_state *_state)
virtual ~rbfmodel()
void lsfitcreatefgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, lsfitstate &state)
void smp_barycentricfitfloaterhormannwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep)
double idwcalc(idwinterpolant *z, ae_vector *x, ae_state *_state)
void polynomialbuildeqdist(double a, double b, ae_vector *y, ae_int_t n, barycentricinterpolant *p, ae_state *_state)
rbfcalcbuffer(const rbfcalcbuffer &rhs)
void rbftscalcbuf(const rbfmodel &s, const rbfcalcbuffer &buf, const real_1d_array &x, real_1d_array &y)
void spline2dunpackv(spline2dinterpolant *c, ae_int_t *m, ae_int_t *n, ae_int_t *d, ae_matrix *tbl, ae_state *_state)
void logisticfit4(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, double &a, double &b, double &c, double &d, lsfitreport &rep)
rbfmodel(const rbfmodel &rhs)
void lstfitpiecewiselinearrdp(ae_vector *x, ae_vector *y, ae_int_t n, double eps, ae_vector *x2, ae_vector *y2, ae_int_t *nsections, ae_state *_state)
double rbfv2calc1(rbfv2model *s, double x0, ae_state *_state)
void _rbfv2calcbuffer_destroy(void *_p)
void nsfitspheremic(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rlo)
void pspline3diff2(const pspline3interpolant &p, const double t, double &x, double &dx, double &d2x, double &y, double &dy, double &d2y, double &z, double &dz, double &d2z)
alglib_impl::rbfreport * p_struct
void rbfcalcbuf(const rbfmodel &s, const real_1d_array &x, real_1d_array &y)
void polynomialbar2cheb(barycentricinterpolant *p, double a, double b, ae_vector *t, ae_state *_state)
alglib_impl::spline1dinterpolant * p_struct
void _pspline3interpolant_init_copy(void *_dst, void *_src, ae_state *_state)
void rbfgridcalc3vx(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *x2, ae_int_t n2, ae_vector *flagy, ae_bool sparsey, ae_vector *y, ae_state *_state)
_rbfreport_owner & operator=(const _rbfreport_owner &rhs)
void _pspline2interpolant_init(void *_p, ae_state *_state)
void rbfunpack(const rbfmodel &s, ae_int_t &nx, ae_int_t &ny, real_2d_array &xwr, ae_int_t &nc, real_2d_array &v, ae_int_t &modelversion)
void solvecubicpolinom(double pa, double ma, double pb, double mb, double a, double b, double *x0, double *x1, double *x2, double *ex0, double *ex1, ae_int_t *nr, ae_int_t *ne, ae_vector *tempdata, ae_state *_state)
void rbfsetv2its(rbfmodel *s, ae_int_t maxits, ae_state *_state)
void lsfitsetgradientcheck(const lsfitstate &state, const double teststep)
void spline3dcalcvbuf(spline3dinterpolant *c, double x, double y, double z, ae_vector *f, ae_state *_state)
alglib_impl::spline3dinterpolant * p_struct
_spline1dinterpolant_owner & operator=(const _spline1dinterpolant_owner &rhs)
void _spline1dfitreport_init_copy(void *_dst, void *_src, ae_state *_state)
_spline1dfitreport_owner & operator=(const _spline1dfitreport_owner &rhs)
void rbfcalc(rbfmodel *s, ae_vector *x, ae_vector *y, ae_state *_state)
void pspline2buildperiodic(ae_matrix *xy, ae_int_t n, ae_int_t st, ae_int_t pt, pspline2interpolant *p, ae_state *_state)
void spline1dfithermitewc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void _rbfreport_init(void *_p, ae_state *_state)
void lsfitsetstpmax(const lsfitstate &state, const double stpmax)
void spline2dbuildbicubic(ae_vector *x, ae_vector *y, ae_matrix *f, ae_int_t m, ae_int_t n, spline2dinterpolant *c, ae_state *_state)
void spline1dconvdiff2cubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y2, real_1d_array &d2, real_1d_array &dd2)
void rbfgridcalc3v(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *x2, ae_int_t n2, ae_vector *y, ae_state *_state)
alglib_impl::idwinterpolant * c_ptr()
double rbfv2nearradius(ae_int_t bf, ae_state *_state)
rbfreport & operator=(const rbfreport &rhs)
void solvepolinom2(double p0, double m0, double p1, double m1, double *x0, double *x1, ae_int_t *nr, ae_state *_state)
void spline3dlintransf(spline3dinterpolant *c, double a, double b, ae_state *_state)
void rbfgridcalc2v(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, real_1d_array &y)
void pspline2tangent(const pspline2interpolant &p, const double t, double &x, double &y)
void rbfv2gridcalcvx(rbfv2model *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *x2, ae_int_t n2, ae_vector *x3, ae_int_t n3, ae_vector *flagy, ae_bool sparsey, ae_vector *y, ae_state *_state)
void _pexec_spline1dfithermitewc(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void spline1drootsandextrema(spline1dinterpolant *c, ae_vector *r, ae_int_t *nr, ae_bool *dr, ae_vector *e, ae_vector *et, ae_int_t *ne, ae_bool *de, ae_state *_state)
struct alglib_impl::ae_vector ae_vector
pspline2interpolant(const pspline2interpolant &rhs)
void barycentriclintransy(const barycentricinterpolant &b, const double ca, const double cb)
void _lsfitreport_init_copy(void *_dst, void *_src, ae_state *_state)
_lsfitreport_owner & operator=(const _lsfitreport_owner &rhs)
void lsfitcreatewfg(ae_matrix *x, ae_vector *y, ae_vector *w, ae_vector *c, ae_int_t n, ae_int_t m, ae_int_t k, ae_bool cheapfg, lsfitstate *state, ae_state *_state)
double barycentriccalc(barycentricinterpolant *b, double t, ae_state *_state)
void lsfitresults(const lsfitstate &state, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
void rbfsetlinterm(rbfmodel *s, ae_state *_state)
spline1dinterpolant(const spline1dinterpolant &rhs)
void pspline2diff(pspline2interpolant *p, double t, double *x, double *dx, double *y, double *dy, ae_state *_state)
alglib_impl::spline1dfitreport * c_ptr()
void spline1dfitcubicwc(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void _pexec_barycentricfitfloaterhormannwc(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, barycentricinterpolant *b, barycentricfitreport *rep, ae_state *_state)
void idwbuildnoisy(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const ae_int_t d, const ae_int_t nq, const ae_int_t nw, idwinterpolant &z)
void rbfalloc(ae_serializer *s, rbfmodel *model, ae_state *_state)
ae_int_t & terminationtype
rbfreport(const rbfreport &rhs)
spline1dfitreport & operator=(const spline1dfitreport &rhs)
void _rbfreport_destroy(void *_p)
void lsfitsetbc(const lsfitstate &state, const real_1d_array &bndl, const real_1d_array &bndu)
void spline2dcopy(spline2dinterpolant *c, spline2dinterpolant *cc, ae_state *_state)
barycentricinterpolant & operator=(const barycentricinterpolant &rhs)
void _pexec_lsfitlinear(ae_vector *y, ae_matrix *fmatrix, ae_int_t n, ae_int_t m, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
void _rbfmodel_init(void *_p, ae_state *_state)
void logisticfit45x(ae_vector *x, ae_vector *y, ae_int_t n, double cnstrleft, double cnstrright, ae_bool is4pl, double lambdav, double epsx, ae_int_t rscnt, double *a, double *b, double *c, double *d, double *g, lsfitreport *rep, ae_state *_state)
void nsfitspherex(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, const ae_int_t problemtype, const double epsx, const ae_int_t aulits, const double penalty, real_1d_array &cx, double &rlo, double &rhi)
double polynomialcalccheb1(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t)
void pspline3buildperiodic(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline3interpolant &p)
void rbfcreatecalcbuffer(rbfmodel *s, rbfcalcbuffer *buf, ae_state *_state)
ae_bool lsfititeration(lsfitstate *state, ae_state *_state)
double logisticcalc5(const double x, const double a, const double b, const double c, const double d, const double g)
void barycentriclintransy(barycentricinterpolant *b, double ca, double cb, ae_state *_state)
_lsfitstate_owner & operator=(const _lsfitstate_owner &rhs)
void _pexec_lsfitlinearc(ae_vector *y, ae_matrix *fmatrix, ae_matrix *cmatrix, ae_int_t n, ae_int_t m, ae_int_t k, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
void rbfv1alloc(ae_serializer *s, rbfv1model *model, ae_state *_state)
double spline1dintegrate(spline1dinterpolant *c, double x, ae_state *_state)
void spline1dbuildcubic(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, spline1dinterpolant *c, ae_state *_state)
void pspline3build(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline3interpolant &p)
alglib_impl::pspline3interpolant * p_struct
void _rbfv2model_clear(void *_p)
void idwbuildmodifiedshepard(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const ae_int_t d, const ae_int_t nq, const ae_int_t nw, idwinterpolant &z)
void _polynomialfitreport_destroy(void *_p)
void _gridcalc3v1buf_clear(void *_p)
void _pexec_polynomialfit(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_int_t *info, barycentricinterpolant *p, polynomialfitreport *rep, ae_state *_state)
double rbfcalc1(const rbfmodel &s, const double x0)
double rbfcalc1(rbfmodel *s, double x0, ae_state *_state)
lsfitstate(const lsfitstate &rhs)
void spline1dbuildcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundltype, const double boundl, const ae_int_t boundrtype, const double boundr, spline1dinterpolant &c)
void pspline2parametervalues(const pspline2interpolant &p, ae_int_t &n, real_1d_array &t)
void barycentricdiff2(const barycentricinterpolant &b, const double t, double &f, double &df, double &d2f)
void polynomialfitwc(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, barycentricinterpolant *p, polynomialfitreport *rep, ae_state *_state)
void _rbfv1calcbuffer_init_copy(void *_dst, void *_src, ae_state *_state)
alglib_impl::lsfitreport * c_ptr()
void spline1dgriddiff2cubic(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, ae_vector *d1, ae_vector *d2, ae_state *_state)
void _rbfmodel_init_copy(void *_dst, void *_src, ae_state *_state)
void polynomialcheb2bar(ae_vector *t, ae_int_t n, double a, double b, barycentricinterpolant *p, ae_state *_state)
void smp_rbfgridcalc2v(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, real_1d_array &y)
double spline2dcalc(const spline2dinterpolant &c, const double x, const double y)
void rbfsetcond(rbfmodel *s, double epsort, double epserr, ae_int_t maxits, ae_state *_state)
void _rbfreport_clear(void *_p)
void lsfitsetxrep(const lsfitstate &state, const bool needxrep)
void lsfitlinearw(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const ae_int_t n, const ae_int_t m, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
double spline1dcalc(spline1dinterpolant *c, double x, ae_state *_state)
void rbfv2buildhierarchical(ae_matrix *x, ae_matrix *y, ae_int_t n, ae_vector *scalevec, ae_int_t aterm, ae_int_t nh, double rbase, double lambdans, ae_bool nonnegative, ae_int_t nnmaxits, rbfv2model *s, rbfv2report *rep, ae_state *_state)
void lsfitlinearwc(const real_1d_array &y, const real_1d_array &w, const real_2d_array &fmatrix, const real_2d_array &cmatrix, const ae_int_t n, const ae_int_t m, const ae_int_t k, ae_int_t &info, real_1d_array &c, lsfitreport &rep)
void nsfitspheremzc(ae_matrix *xy, ae_int_t npoints, ae_int_t nx, ae_vector *cx, double *rlo, double *rhi, ae_state *_state)
void rbfbuildmodel(rbfmodel *s, rbfreport *rep, ae_state *_state)
void pspline3diff(const pspline3interpolant &p, const double t, double &x, double &dx, double &y, double &dy, double &z, double &dz)
void idwbuildmodifiedshepardr(ae_matrix *xy, ae_int_t n, ae_int_t nx, double r, idwinterpolant *z, ae_state *_state)
void lsfitsetscale(const lsfitstate &state, const real_1d_array &s)
void polynomialbuildcheb1(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p)
virtual ~rbfreport()
void spline3dunpackv(spline3dinterpolant *c, ae_int_t *n, ae_int_t *m, ae_int_t *l, ae_int_t *d, ae_int_t *stype, ae_matrix *tbl, ae_state *_state)
void barycentricfitfloaterhormannwc(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, barycentricinterpolant *b, barycentricfitreport *rep, ae_state *_state)
void spline3dcopy(spline3dinterpolant *c, spline3dinterpolant *cc, ae_state *_state)
void _rbfv1report_init_copy(void *_dst, void *_src, ae_state *_state)
alglib_impl::ae_int_t ae_int_t
Definition: ap.h:965
void _spline2dinterpolant_init(void *_p, ae_state *_state)
void barycentriclintransx(const barycentricinterpolant &b, const double ca, const double cb)
void polynomialbuildcheb2(double a, double b, ae_vector *y, ae_int_t n, barycentricinterpolant *p, ae_state *_state)
void spline1dbuildhermite(ae_vector *x, ae_vector *y, ae_vector *d, ae_int_t n, spline1dinterpolant *c, ae_state *_state)
void spline1dunpack(const spline1dinterpolant &c, ae_int_t &n, real_2d_array &tbl)
void spline3dcalcv(const spline3dinterpolant &c, const double x, const double y, const double z, real_1d_array &f)
void logisticfit5(ae_vector *x, ae_vector *y, ae_int_t n, double *a, double *b, double *c, double *d, double *g, lsfitreport *rep, ae_state *_state)
void rbfsetpointsandscales(rbfmodel *r, ae_matrix *xy, ae_int_t n, ae_vector *s, ae_state *_state)
alglib_impl::barycentricfitreport * p_struct
idwinterpolant & operator=(const idwinterpolant &rhs)
void rbfunpack(rbfmodel *s, ae_int_t *nx, ae_int_t *ny, ae_matrix *xwr, ae_int_t *nc, ae_matrix *v, ae_int_t *modelversion, ae_state *_state)
void pspline2tangent(pspline2interpolant *p, double t, double *x, double *y, ae_state *_state)
_rbfcalcbuffer_owner & operator=(const _rbfcalcbuffer_owner &rhs)
lsfitstate & operator=(const lsfitstate &rhs)
void _rbfv1model_init_copy(void *_dst, void *_src, ae_state *_state)
void _lsfitreport_clear(void *_p)
void spline1dfithermitewc(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void rbfbuildmodel(const rbfmodel &s, rbfreport &rep)
void _rbfv1model_destroy(void *_p)
void _polynomialfitreport_init(void *_p, ae_state *_state)
rbfmodel & operator=(const rbfmodel &rhs)
void spline1dcopy(spline1dinterpolant *c, spline1dinterpolant *cc, ae_state *_state)
void _rbfv1report_destroy(void *_p)
void _pspline2interpolant_init_copy(void *_dst, void *_src, ae_state *_state)
void _spline3dinterpolant_destroy(void *_p)
void spline1dlintransy(const spline1dinterpolant &c, const double a, const double b)
void _barycentricinterpolant_clear(void *_p)
void lsfitcreatef(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const double diffstep, lsfitstate &state)
void rbfv2unpack(rbfv2model *s, ae_int_t *nx, ae_int_t *ny, ae_matrix *xwr, ae_int_t *nc, ae_matrix *v, ae_state *_state)
void polynomialbuildcheb1(double a, double b, ae_vector *y, ae_int_t n, barycentricinterpolant *p, ae_state *_state)
void spline2dresamplebicubic(ae_matrix *a, ae_int_t oldheight, ae_int_t oldwidth, ae_matrix *b, ae_int_t newheight, ae_int_t newwidth, ae_state *_state)
void idwbuildmodifiedshepardr(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const double r, idwinterpolant &z)
void pspline2parametervalues(pspline2interpolant *p, ae_int_t *n, ae_vector *t, ae_state *_state)
void pspline3parametervalues(pspline3interpolant *p, ae_int_t *n, ae_vector *t, ae_state *_state)
void pspline2diff2(const pspline2interpolant &p, const double t, double &x, double &dx, double &d2x, double &y, double &dy, double &d2y)
void lsfitsetgradientcheck(lsfitstate *state, double teststep, ae_state *_state)
void rbfsetalgoqnn(rbfmodel *s, double q, double z, ae_state *_state)
void spline1dfitpenalizedw(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_int_t m, double rho, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void spline3dresampletrilinear(ae_vector *a, ae_int_t oldzcount, ae_int_t oldycount, ae_int_t oldxcount, ae_int_t newzcount, ae_int_t newycount, ae_int_t newxcount, ae_vector *b, ae_state *_state)
void polynomialbar2pow(barycentricinterpolant *p, double c, double s, ae_vector *a, ae_state *_state)
void rbfv1create(ae_int_t nx, ae_int_t ny, rbfv1model *s, ae_state *_state)
void _rbfv2gridcalcbuffer_init(void *_p, ae_state *_state)
void _spline3dinterpolant_clear(void *_p)
alglib_impl::rbfmodel * p_struct
void lsfitcreatewfg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const bool cheapfg, lsfitstate &state)
void lsfitcreatewf(ae_matrix *x, ae_vector *y, ae_vector *w, ae_vector *c, ae_int_t n, ae_int_t m, ae_int_t k, double diffstep, lsfitstate *state, ae_state *_state)
void rbfsetalgoqnn(const rbfmodel &s, const double q, const double z)
void rbfv1unpack(rbfv1model *s, ae_int_t *nx, ae_int_t *ny, ae_matrix *xwr, ae_int_t *nc, ae_matrix *v, ae_state *_state)
spline3dinterpolant & operator=(const spline3dinterpolant &rhs)
void spline3dunpackv(const spline3dinterpolant &c, ae_int_t &n, ae_int_t &m, ae_int_t &l, ae_int_t &d, ae_int_t &stype, real_2d_array &tbl)
void lsfitsetstpmax(lsfitstate *state, double stpmax, ae_state *_state)
void rbfunserialize(ae_serializer *s, rbfmodel *model, ae_state *_state)
void _pexec_polynomialfitwc(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, barycentricinterpolant *p, polynomialfitreport *rep, ae_state *_state)
void _pspline2interpolant_clear(void *_p)
ae_int_t & iterationscount
void lsfitsetcond(lsfitstate *state, double epsx, ae_int_t maxits, ae_state *_state)
void pspline3tangent(pspline3interpolant *p, double t, double *x, double *y, double *z, ae_state *_state)
void spline1dconvdiff2cubic(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, ae_vector *x2, ae_int_t n2, ae_vector *y2, ae_vector *d2, ae_vector *dd2, ae_state *_state)
void rbftscalcbuf(rbfmodel *s, rbfcalcbuffer *buf, ae_vector *x, ae_vector *y, ae_state *_state)
real_1d_array g
void rbfv2tscalcbuf(rbfv2model *s, rbfv2calcbuffer *buf, ae_vector *x, ae_vector *y, ae_state *_state)
void lsfitcreatef(ae_matrix *x, ae_vector *y, ae_vector *c, ae_int_t n, ae_int_t m, ae_int_t k, double diffstep, lsfitstate *state, ae_state *_state)
virtual ~lsfitreport()
void _pexec_rbfgridcalc2v(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *y, ae_state *_state)
alglib_impl::lsfitreport * p_struct
_polynomialfitreport_owner & operator=(const _polynomialfitreport_owner &rhs)
void _pspline3interpolant_destroy(void *_p)
alglib_impl::barycentricinterpolant * c_ptr()
double logisticcalc4(double x, double a, double b, double c, double d, ae_state *_state)
struct alglib_impl::ae_matrix ae_matrix
void spline2dcalcvbuf(const spline2dinterpolant &c, const double x, const double y, real_1d_array &f)
void _gridcalc3v1buf_destroy(void *_p)
void smp_rbfgridcalc3v(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const real_1d_array &x2, const ae_int_t n2, real_1d_array &y)
alglib_impl::spline1dinterpolant * c_ptr()
void polynomialbuild(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p)
void spline3dlintransxyz(const spline3dinterpolant &c, const double ax, const double bx, const double ay, const double by, const double az, const double bz)
void _polynomialfitreport_init_copy(void *_dst, void *_src, ae_state *_state)
void rbfcreate(const ae_int_t nx, const ae_int_t ny, rbfmodel &s)
_idwinterpolant_owner & operator=(const _idwinterpolant_owner &rhs)
void spline1dconvcubic(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, ae_vector *x2, ae_int_t n2, ae_vector *y2, ae_state *_state)
void _rbfv2calcbuffer_init_copy(void *_dst, void *_src, ae_state *_state)
void smp_polynomialfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep)
void spline1dfithermite(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
alglib_impl::lsfitstate * p_struct
void spline2dcalcv(spline2dinterpolant *c, double x, double y, ae_vector *f, ae_state *_state)
void lsfitcreatewfgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, lsfitstate &state)
void pspline3buildperiodic(ae_matrix *xy, ae_int_t n, ae_int_t st, ae_int_t pt, pspline3interpolant *p, ae_state *_state)
void _pexec_barycentricfitfloaterhormann(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_int_t *info, barycentricinterpolant *b, barycentricfitreport *rep, ae_state *_state)
void rbfsetpoints(rbfmodel *s, ae_matrix *xy, ae_int_t n, ae_state *_state)
_spline3dinterpolant_owner & operator=(const _spline3dinterpolant_owner &rhs)
double logisticcalc4(const double x, const double a, const double b, const double c, const double d)
void rbfgridcalc2vsubset(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *flagy, ae_vector *y, ae_state *_state)
barycentricinterpolant(const barycentricinterpolant &rhs)
void spline2dlintransxy(spline2dinterpolant *c, double ax, double bx, double ay, double by, ae_state *_state)
void lsfitsetxrep(lsfitstate *state, ae_bool needxrep, ae_state *_state)
void barycentricdiff1(const barycentricinterpolant &b, const double t, double &f, double &df)
idwinterpolant(const idwinterpolant &rhs)
void lsfitsetcond(const lsfitstate &state, const double epsx, const ae_int_t maxits)
void _lsfitstate_clear(void *_p)
void rbfgridcalc2vsubset(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const boolean_1d_array &flagy, real_1d_array &y)
void pspline2build(ae_matrix *xy, ae_int_t n, ae_int_t st, ae_int_t pt, pspline2interpolant *p, ae_state *_state)
void rbfsetv2its(const rbfmodel &s, const ae_int_t maxits)
void spline1dgriddiffcubic(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, ae_vector *d, ae_state *_state)
void spline3dcalcvbuf(const spline3dinterpolant &c, const double x, const double y, const double z, real_1d_array &f)
real_1d_array x
void lsfitcreatefgh(ae_matrix *x, ae_vector *y, ae_vector *c, ae_int_t n, ae_int_t m, ae_int_t k, lsfitstate *state, ae_state *_state)
real_1d_array c
void rbfv1tscalcbuf(rbfv1model *s, rbfv1calcbuffer *buf, ae_vector *x, ae_vector *y, ae_state *_state)
void spline1dlintransy(spline1dinterpolant *c, double a, double b, ae_state *_state)
void rbfsetv2supportr(rbfmodel *s, double r, ae_state *_state)
void pspline3build(ae_matrix *xy, ae_int_t n, ae_int_t st, ae_int_t pt, pspline3interpolant *p, ae_state *_state)
void lsfitcreatewf(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, const ae_int_t n, const ae_int_t m, const ae_int_t k, const double diffstep, lsfitstate &state)
void rbfv2partialgridcalcrec(rbfv2model *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *x2, ae_int_t n2, ae_vector *x3, ae_int_t n3, ae_vector *blocks0, ae_int_t block0a, ae_int_t block0b, ae_vector *blocks1, ae_int_t block1a, ae_int_t block1b, ae_vector *blocks2, ae_int_t block2a, ae_int_t block2b, ae_vector *blocks3, ae_int_t block3a, ae_int_t block3b, ae_vector *flagy, ae_bool sparsey, ae_int_t levelidx, double avgfuncpernode, ae_shared_pool *bufpool, ae_vector *y, ae_state *_state)
void spline2dbuildbicubicv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &f, const ae_int_t d, spline2dinterpolant &c)
void _barycentricfitreport_destroy(void *_p)
void pspline2calc(const pspline2interpolant &p, const double t, double &x, double &y)
void lsfitlinear(ae_vector *y, ae_matrix *fmatrix, ae_int_t n, ae_int_t m, ae_int_t *info, ae_vector *c, lsfitreport *rep, ae_state *_state)
void spline3dlintransf(const spline3dinterpolant &c, const double a, const double b)
void smp_rbfgridcalc2vsubset(const rbfmodel &s, const real_1d_array &x0, const ae_int_t n0, const real_1d_array &x1, const ae_int_t n1, const boolean_1d_array &flagy, real_1d_array &y)
void rbfserialize(ae_serializer *s, rbfmodel *model, ae_state *_state)
void _rbfv1report_init(void *_p, ae_state *_state)
void rbfv1createcalcbuffer(rbfv1model *s, rbfv1calcbuffer *buf, ae_state *_state)
void _pspline3interpolant_clear(void *_p)
void _spline2dinterpolant_clear(void *_p)
void smp_polynomialfitwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep)
void nsfitspherex(ae_matrix *xy, ae_int_t npoints, ae_int_t nx, ae_int_t problemtype, double epsx, ae_int_t aulits, double penalty, ae_vector *cx, double *rlo, double *rhi, ae_state *_state)
void _pexec_spline1dfithermite(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
void rbfsetalgohierarchical(rbfmodel *s, double rbase, ae_int_t nlayers, double lambdans, ae_state *_state)
void _rbfv1calcbuffer_clear(void *_p)
void rbfv1calcbuf(rbfv1model *s, ae_vector *x, ae_vector *y, ae_state *_state)
void spline3dcalcv(spline3dinterpolant *c, double x, double y, double z, ae_vector *f, ae_state *_state)
alglib_impl::spline3dinterpolant * c_ptr()
void pspline2calc(pspline2interpolant *p, double t, double *x, double *y, ae_state *_state)
void spline1dbuildlinear(ae_vector *x, ae_vector *y, ae_int_t n, spline1dinterpolant *c, ae_state *_state)
void rbfsetalgomultilayer(rbfmodel *s, double rbase, ae_int_t nlayers, double lambdav, ae_state *_state)
void rbfcreatecalcbuffer(const rbfmodel &s, rbfcalcbuffer &buf)
void spline1dunpack(spline1dinterpolant *c, ae_int_t *n, ae_matrix *tbl, ae_state *_state)
void spline1dlintransx(const spline1dinterpolant &c, const double a, const double b)
void spline1dbuildcatmullrom(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t boundtype, const double tension, spline1dinterpolant &c)
void spline1dbuildcatmullrom(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t boundtype, double tension, spline1dinterpolant *c, ae_state *_state)
void nsfitspheremzc(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rlo, double &rhi)
alglib_impl::rbfreport * c_ptr()
void _rbfv1calcbuffer_destroy(void *_p)
void _lsfitstate_destroy(void *_p)
void rbfserialize(rbfmodel &obj, std::string &s_out)
void _nsfitinternalreport_destroy(void *_p)
void _pexec_spline1dfitpenalizedw(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_int_t m, double rho, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep, ae_state *_state)
alglib_impl::rbfcalcbuffer * c_ptr()
double rbfv1calc2(rbfv1model *s, double x0, double x1, ae_state *_state)
void barycentricfitfloaterhormann(ae_vector *x, ae_vector *y, ae_int_t n, ae_int_t m, ae_int_t *info, barycentricinterpolant *b, barycentricfitreport *rep, ae_state *_state)
void rbfv2createcalcbuffer(rbfv2model *s, rbfv2calcbuffer *buf, ae_state *_state)
void nsfitspheremcc(ae_matrix *xy, ae_int_t npoints, ae_int_t nx, ae_vector *cx, double *rhi, ae_state *_state)
ptrdiff_t ae_int_t
Definition: ap.h:185
void _rbfv2model_destroy(void *_p)
pspline2interpolant & operator=(const pspline2interpolant &rhs)
void spline1dbuildlinear(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c)
void rbfv2calcbuf(rbfv2model *s, ae_vector *x, ae_vector *y, ae_state *_state)
void rbfsetv2bf(const rbfmodel &s, const ae_int_t bf)
void spline1dbuildakima(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c)
void _gridcalc3v1buf_init_copy(void *_dst, void *_src, ae_state *_state)
double rbfv2basisfunc(ae_int_t bf, double d2, ae_state *_state)
void spline2dbuildbilinearv(const real_1d_array &x, const ae_int_t n, const real_1d_array &y, const ae_int_t m, const real_1d_array &f, const ae_int_t d, spline2dinterpolant &c)
void _rbfv2calcbuffer_clear(void *_p)
void _barycentricfitreport_init(void *_p, ae_state *_state)
void parametricrdpfixed(const real_2d_array &x, const ae_int_t n, const ae_int_t d, const ae_int_t stopm, const double stopeps, real_2d_array &x2, integer_1d_array &idx2, ae_int_t &nsections)
void logisticfit4ec(ae_vector *x, ae_vector *y, ae_int_t n, double cnstrleft, double cnstrright, double *a, double *b, double *c, double *d, lsfitreport *rep, ae_state *_state)
void spline1dfitcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
_rbfmodel_owner & operator=(const _rbfmodel_owner &rhs)
void spline2dlintransxy(const spline2dinterpolant &c, const double ax, const double bx, const double ay, const double by)
void _spline2dinterpolant_destroy(void *_p)
void lsfitscalexy(ae_vector *x, ae_vector *y, ae_vector *w, ae_int_t n, ae_vector *xc, ae_vector *yc, ae_vector *dc, ae_int_t k, double *xa, double *xb, double *sa, double *sb, ae_vector *xoriginal, ae_vector *yoriginal, ae_state *_state)
void pspline2buildperiodic(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline2interpolant &p)
void rbfgridcalc3vsubset(rbfmodel *s, ae_vector *x0, ae_int_t n0, ae_vector *x1, ae_int_t n1, ae_vector *x2, ae_int_t n2, ae_vector *flagy, ae_vector *y, ae_state *_state)
void _lsfitreport_destroy(void *_p)
void _gridcalc3v1buf_init(void *_p, ae_state *_state)
void _rbfv2gridcalcbuffer_init_copy(void *_dst, void *_src, ae_state *_state)
alglib_impl::spline2dinterpolant * c_ptr()
void rbfsetv2supportr(const rbfmodel &s, const double r)
double polynomialcalccheb2(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t)
void smp_spline1dfitpenalizedw(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void _spline3dinterpolant_init(void *_p, ae_state *_state)
void pspline3diff(pspline3interpolant *p, double t, double *x, double *dx, double *y, double *dy, double *z, double *dz, ae_state *_state)
void nsfitsphereinternal(ae_matrix *xy, ae_int_t npoints, ae_int_t nx, ae_int_t problemtype, ae_int_t solvertype, double epsx, ae_int_t aulits, double penalty, ae_vector *cx, double *rlo, double *rhi, nsfitinternalreport *rep, ae_state *_state)
void lsfitsetscale(lsfitstate *state, ae_vector *s, ae_state *_state)
void pspline2diff(const pspline2interpolant &p, const double t, double &x, double &dx, double &y, double &dy)
void _barycentricinterpolant_init(void *_p, ae_state *_state)
void _barycentricfitreport_init_copy(void *_dst, void *_src, ae_state *_state)
void barycentricfitfloaterhormannwc(const real_1d_array &x, const real_1d_array &y, const real_1d_array &w, const ae_int_t n, const real_1d_array &xc, const real_1d_array &yc, const integer_1d_array &dc, const ae_int_t k, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep)
void _rbfcalcbuffer_init_copy(void *_dst, void *_src, ae_state *_state)
void smp_spline1dfitpenalized(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, const double rho, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep)
void barycentricfitfloaterhormann(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, ae_int_t &info, barycentricinterpolant &b, barycentricfitreport &rep)
void _rbfv2report_init(void *_p, ae_state *_state)
void _spline3dinterpolant_init_copy(void *_dst, void *_src, ae_state *_state)
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich