-
Notifications
You must be signed in to change notification settings - Fork 3
/
Interpolation.h
1560 lines (1476 loc) · 85.4 KB
/
Interpolation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ALGLIB++
// Based on ALGLIB: Copyright (c) Sergey Bochkanov (ALGLIB project).
// Revisions Copyright (c) Lydia Marie Williamson, Mark Hopkins Consulting
// Source License:
// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation (www.fsf.org);
// either version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// A copy of the GNU General Public License is available at http://www.fsf.org/licensing/licenses
#ifndef OnceOnlyInterpolation_h
#define OnceOnlyInterpolation_h
#include "Integration.h"
#include "Optimization.h"
// === RATINT Package ===
// Depends on: (AlgLibInternal) TSORT
namespace alglib_impl {
struct barycentricinterpolant {
ae_int_t n;
double sy;
ae_vector x;
ae_vector y;
ae_vector w;
};
void barycentricinterpolant_init(void *_p, bool make_automatic);
void barycentricinterpolant_copy(void *_dst, const void *_src, bool make_automatic);
void barycentricinterpolant_free(void *_p, bool make_automatic);
double barycentriccalc(barycentricinterpolant *b, double t);
void barycentricdiff1(barycentricinterpolant *b, double t, double *f, double *df);
void barycentricdiff2(barycentricinterpolant *b, double t, double *f, double *df, double *d2f);
void barycentriclintransx(barycentricinterpolant *b, double ca, double cb);
void barycentriclintransy(barycentricinterpolant *b, double ca, double cb);
void barycentricunpack(barycentricinterpolant *b, ae_int_t *n, RVector *x, RVector *y, RVector *w);
void barycentricbuildxyw(RVector *x, RVector *y, RVector *w, ae_int_t n, barycentricinterpolant *b);
void barycentricbuildfloaterhormann(RVector *x, RVector *y, ae_int_t n, ae_int_t d, barycentricinterpolant *b);
void barycentriccopy(barycentricinterpolant *b, barycentricinterpolant *b2);
} // end of namespace alglib_impl
namespace alglib {
DecClass(barycentricinterpolant, );
double barycentriccalc(const barycentricinterpolant &b, const double t);
void barycentricdiff1(const barycentricinterpolant &b, const double t, double &f, double &df);
void barycentricdiff2(const barycentricinterpolant &b, const double t, double &f, double &df, double &d2f);
void barycentriclintransx(const barycentricinterpolant &b, const double ca, const double cb);
void barycentriclintransy(const barycentricinterpolant &b, const double ca, const double cb);
void barycentricunpack(const barycentricinterpolant &b, ae_int_t &n, real_1d_array &x, real_1d_array &y, real_1d_array &w);
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 barycentricbuildfloaterhormann(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t d, barycentricinterpolant &b);
} // end of namespace alglib
// === IDW Package ===
// Depends on: (AlgLibMisc) HQRND, NEARESTNEIGHBOR
// Depends on: (LinAlg) ABLAS
namespace alglib_impl {
struct idwcalcbuffer {
ae_vector x;
ae_vector y;
ae_vector tsyw;
ae_vector tsw;
ae_matrix tsxy;
ae_vector tsdist;
kdtreerequestbuffer requestbuffer;
};
void idwcalcbuffer_init(void *_p, bool make_automatic);
void idwcalcbuffer_copy(void *_dst, const void *_src, bool make_automatic);
void idwcalcbuffer_free(void *_p, bool make_automatic);
struct idwmodel {
ae_int_t nx;
ae_int_t ny;
ae_vector globalprior;
ae_int_t algotype;
ae_int_t nlayers;
double r0;
double rdecay;
double lambda0;
double lambdalast;
double lambdadecay;
double shepardp;
kdtree tree;
ae_int_t npoints;
ae_vector shepardxy;
idwcalcbuffer buffer;
};
void idwmodel_init(void *_p, bool make_automatic);
void idwmodel_copy(void *_dst, const void *_src, bool make_automatic);
void idwmodel_free(void *_p, bool make_automatic);
void idwalloc(ae_serializer *s, idwmodel *model);
void idwserialize(ae_serializer *s, idwmodel *model);
void idwunserialize(ae_serializer *s, idwmodel *model);
struct idwbuilder {
ae_int_t priortermtype;
ae_vector priortermval;
ae_int_t algotype;
ae_int_t nlayers;
double r0;
double rdecay;
double lambda0;
double lambdalast;
double lambdadecay;
double shepardp;
ae_vector xy;
ae_int_t npoints;
ae_int_t nx;
ae_int_t ny;
ae_matrix tmpxy;
ae_matrix tmplayers;
ae_vector tmptags;
ae_vector tmpdist;
ae_vector tmpx;
ae_vector tmpwy;
ae_vector tmpw;
kdtree tmptree;
ae_vector tmpmean;
};
void idwbuilder_init(void *_p, bool make_automatic);
void idwbuilder_copy(void *_dst, const void *_src, bool make_automatic);
void idwbuilder_free(void *_p, bool make_automatic);
struct idwreport {
double rmserror;
double avgerror;
double maxerror;
double r2;
};
void idwreport_init(void *_p, bool make_automatic);
void idwreport_copy(void *_dst, const void *_src, bool make_automatic);
void idwreport_free(void *_p, bool make_automatic);
void idwcreatecalcbuffer(idwmodel *s, idwcalcbuffer *buf);
void idwbuildercreate(ae_int_t nx, ae_int_t ny, idwbuilder *state);
void idwbuildersetnlayers(idwbuilder *state, ae_int_t nlayers);
void idwbuildersetpoints(idwbuilder *state, RMatrix *xy, ae_int_t n);
void idwbuildersetalgomstab(idwbuilder *state, double srad);
void idwbuildersetalgotextbookshepard(idwbuilder *state, double p);
void idwbuildersetalgotextbookmodshepard(idwbuilder *state, double r);
void idwbuildersetuserterm(idwbuilder *state, double v);
void idwbuildersetconstterm(idwbuilder *state);
void idwbuildersetzeroterm(idwbuilder *state);
void idwtscalcbuf(idwmodel *s, idwcalcbuffer *buf, RVector *x, RVector *y);
void idwcalc(idwmodel *s, RVector *x, RVector *y);
void idwcalcbuf(idwmodel *s, RVector *x, RVector *y);
double idwcalc1(idwmodel *s, double x0);
double idwcalc2(idwmodel *s, double x0, double x1);
double idwcalc3(idwmodel *s, double x0, double x1, double x2);
void idwfit(idwbuilder *state, idwmodel *model, idwreport *rep);
} // end of namespace alglib_impl
namespace alglib {
DecClass(idwcalcbuffer, );
DecClass(idwmodel, );
DecClass(idwbuilder, );
DecClass(idwreport, double &rmserror; double &avgerror; double &maxerror; double &r2;);
void idwserialize(idwmodel &obj, std::string &s_out);
void idwserialize(idwmodel &obj, std::ostream &s_out);
void idwunserialize(const std::string &s_in, idwmodel &obj);
void idwunserialize(const std::istream &s_in, idwmodel &obj);
void idwcreatecalcbuffer(const idwmodel &s, idwcalcbuffer &buf);
void idwbuildercreate(const ae_int_t nx, const ae_int_t ny, idwbuilder &state);
void idwbuildersetnlayers(const idwbuilder &state, const ae_int_t nlayers);
void idwbuildersetpoints(const idwbuilder &state, const real_2d_array &xy, const ae_int_t n);
void idwbuildersetpoints(const idwbuilder &state, const real_2d_array &xy);
void idwbuildersetalgomstab(const idwbuilder &state, const double srad);
void idwbuildersetalgotextbookshepard(const idwbuilder &state, const double p);
void idwbuildersetalgotextbookmodshepard(const idwbuilder &state, const double r);
void idwbuildersetuserterm(const idwbuilder &state, const double v);
void idwbuildersetconstterm(const idwbuilder &state);
void idwbuildersetzeroterm(const idwbuilder &state);
void idwtscalcbuf(const idwmodel &s, const idwcalcbuffer &buf, const real_1d_array &x, real_1d_array &y);
void idwcalc(const idwmodel &s, const real_1d_array &x, real_1d_array &y);
void idwcalcbuf(const idwmodel &s, const real_1d_array &x, real_1d_array &y);
double idwcalc1(const idwmodel &s, const double x0);
double idwcalc2(const idwmodel &s, const double x0, const double x1);
double idwcalc3(const idwmodel &s, const double x0, const double x1, const double x2);
void idwfit(const idwbuilder &state, idwmodel &model, idwreport &rep);
} // end of namespace alglib
// === INTFITSERV Package ===
// Depends on: (LinAlg) TRFAC
namespace alglib_impl {
void lsfitscalexy(RVector *x, RVector *y, RVector *w, ae_int_t n, RVector *xc, RVector *yc, ZVector *dc, ae_int_t k, double *xa, double *xb, double *sa, double *sb, RVector *xoriginal, RVector *yoriginal);
void buildpriorterm(RMatrix *xy, ae_int_t n, ae_int_t nx, ae_int_t ny, ae_int_t modeltype, double priorval, RMatrix *v);
void buildpriorterm1(RVector *xy1, ae_int_t n, ae_int_t nx, ae_int_t ny, ae_int_t modeltype, double priorval, RMatrix *v);
} // end of namespace alglib_impl
// === POLINT Package ===
// Depends on: RATINT
namespace alglib_impl {
void polynomialbuild(RVector *x, RVector *y, ae_int_t n, barycentricinterpolant *p);
void polynomialbuildeqdist(double a, double b, RVector *y, ae_int_t n, barycentricinterpolant *p);
void polynomialbuildcheb1(double a, double b, RVector *y, ae_int_t n, barycentricinterpolant *p);
void polynomialbuildcheb2(double a, double b, RVector *y, ae_int_t n, barycentricinterpolant *p);
void polynomialbar2cheb(barycentricinterpolant *p, double a, double b, RVector *t);
void polynomialcheb2bar(RVector *t, ae_int_t n, double a, double b, barycentricinterpolant *p);
void polynomialbar2pow(barycentricinterpolant *p, double c, double s, RVector *a);
void polynomialpow2bar(RVector *a, ae_int_t n, double c, double s, barycentricinterpolant *p);
double polynomialcalceqdist(double a, double b, RVector *f, ae_int_t n, double t);
double polynomialcalccheb1(double a, double b, RVector *f, ae_int_t n, double t);
double polynomialcalccheb2(double a, double b, RVector *f, ae_int_t n, double t);
} // end of namespace alglib_impl
namespace alglib {
void polynomialbuild(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
void polynomialbuild(const real_1d_array &x, const real_1d_array &y, barycentricinterpolant &p);
void polynomialbuildeqdist(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
void polynomialbuildeqdist(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
void polynomialbuildcheb1(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
void polynomialbuildcheb1(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
void polynomialbuildcheb2(const double a, const double b, const real_1d_array &y, const ae_int_t n, barycentricinterpolant &p);
void polynomialbuildcheb2(const double a, const double b, const real_1d_array &y, barycentricinterpolant &p);
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);
void polynomialcheb2bar(const real_1d_array &t, const double a, const double b, barycentricinterpolant &p);
void polynomialbar2pow(const barycentricinterpolant &p, const double c, const double s, real_1d_array &a);
void polynomialbar2pow(const barycentricinterpolant &p, real_1d_array &a);
void polynomialpow2bar(const real_1d_array &a, const ae_int_t n, const double c, const double s, barycentricinterpolant &p);
void polynomialpow2bar(const real_1d_array &a, barycentricinterpolant &p);
double polynomialcalceqdist(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
double polynomialcalceqdist(const double a, const double b, const real_1d_array &f, const double t);
double polynomialcalccheb1(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
double polynomialcalccheb1(const double a, const double b, const real_1d_array &f, const double t);
double polynomialcalccheb2(const double a, const double b, const real_1d_array &f, const ae_int_t n, const double t);
double polynomialcalccheb2(const double a, const double b, const real_1d_array &f, const double t);
} // end of namespace alglib
// === SPLINE1D Package ===
// Depends on: (LinAlg) FBLS
// Depends on: (Solvers) LINLSQR
// Depends on: INTFITSERV
namespace alglib_impl {
struct spline1dinterpolant {
bool periodic;
ae_int_t n;
ae_int_t k;
ae_int_t continuity;
ae_vector x;
ae_vector c;
};
void spline1dinterpolant_init(void *_p, bool make_automatic);
void spline1dinterpolant_copy(void *_dst, const void *_src, bool make_automatic);
void spline1dinterpolant_free(void *_p, bool make_automatic);
struct spline1dfitreport {
double taskrcond;
double rmserror;
double avgerror;
double avgrelerror;
double maxerror;
};
void spline1dfitreport_init(void *_p, bool make_automatic);
void spline1dfitreport_copy(void *_dst, const void *_src, bool make_automatic);
void spline1dfitreport_free(void *_p, bool make_automatic);
void heapsortdpoints(RVector *x, RVector *y, RVector *d, ae_int_t n);
void spline1dbuildlinear(RVector *x, RVector *y, ae_int_t n, spline1dinterpolant *c);
void spline1dbuildhermite(RVector *x, RVector *y, RVector *d, ae_int_t n, spline1dinterpolant *c);
void spline1dbuildcubic(RVector *x, RVector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, spline1dinterpolant *c);
void spline1dbuildcatmullrom(RVector *x, RVector *y, ae_int_t n, ae_int_t boundtype, double tension, spline1dinterpolant *c);
void spline1dbuildakima(RVector *x, RVector *y, ae_int_t n, spline1dinterpolant *c);
void spline1dbuildmonotone(RVector *x, RVector *y, ae_int_t n, spline1dinterpolant *c);
void spline1dgriddiffcubic(RVector *x, RVector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, RVector *d);
void spline1dgriddiff2cubic(RVector *x, RVector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, RVector *d1, RVector *d2);
void spline1dconvcubic(RVector *x, RVector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, RVector *x2, ae_int_t n2, RVector *y2);
void spline1dconvdiffcubic(RVector *x, RVector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, RVector *x2, ae_int_t n2, RVector *y2, RVector *d2);
void spline1dconvdiff2cubic(RVector *x, RVector *y, ae_int_t n, ae_int_t boundltype, double boundl, ae_int_t boundrtype, double boundr, RVector *x2, ae_int_t n2, RVector *y2, RVector *d2, RVector *dd2);
double spline1dcalc(spline1dinterpolant *c, double x);
void spline1ddiff(spline1dinterpolant *c, double x, double *s, double *ds, double *d2s);
void spline1dcopy(spline1dinterpolant *c, spline1dinterpolant *cc);
void spline1dunpack(spline1dinterpolant *c, ae_int_t *n, RMatrix *tbl);
void spline1dlintransx(spline1dinterpolant *c, double a, double b);
void spline1dlintransy(spline1dinterpolant *c, double a, double b);
double spline1dintegrate(spline1dinterpolant *c, double x);
void spline1dfitpenalizedw(RVector *x, RVector *y, RVector *w, ae_int_t n, ae_int_t m, double rho, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep);
void spline1dfitpenalized(RVector *x, RVector *y, ae_int_t n, ae_int_t m, double rho, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep);
void spline1dfit(RVector *x, RVector *y, ae_int_t n, ae_int_t m, double lambdans, spline1dinterpolant *s, spline1dfitreport *rep);
void solvepolinom2(double p0, double m0, double p1, double m1, double *x0, double *x1, ae_int_t *nr);
ae_int_t bisectmethod(double pa, double ma, double pb, double mb, double a, double b, double *x);
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, RVector *tempdata);
void spline1drootsandextrema(spline1dinterpolant *c, RVector *r, ae_int_t *nr, bool *dr, RVector *e, ZVector *et, ae_int_t *ne, bool *de);
} // end of namespace alglib_impl
namespace alglib {
DecClass(spline1dinterpolant, );
DecClass(spline1dfitreport, double &taskrcond; double &rmserror; double &avgerror; double &avgrelerror; double &maxerror;);
void spline1dbuildlinear(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c);
void spline1dbuildlinear(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
void spline1dbuildhermite(const real_1d_array &x, const real_1d_array &y, const real_1d_array &d, const ae_int_t n, spline1dinterpolant &c);
void spline1dbuildhermite(const real_1d_array &x, const real_1d_array &y, const real_1d_array &d, spline1dinterpolant &c);
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 spline1dbuildcubic(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
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(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
void spline1dbuildakima(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c);
void spline1dbuildakima(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
void spline1dbuildmonotone(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, spline1dinterpolant &c);
void spline1dbuildmonotone(const real_1d_array &x, const real_1d_array &y, spline1dinterpolant &c);
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 spline1dgriddiffcubic(const real_1d_array &x, const real_1d_array &y, real_1d_array &d);
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);
void spline1dgriddiff2cubic(const real_1d_array &x, const real_1d_array &y, real_1d_array &d1, real_1d_array &d2);
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 spline1dconvcubic(const real_1d_array &x, const real_1d_array &y, const real_1d_array &x2, real_1d_array &y2);
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 spline1dconvdiffcubic(const real_1d_array &x, const real_1d_array &y, const real_1d_array &x2, real_1d_array &y2, real_1d_array &d2);
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 spline1dconvdiff2cubic(const real_1d_array &x, const real_1d_array &y, const real_1d_array &x2, real_1d_array &y2, real_1d_array &d2, real_1d_array &dd2);
double spline1dcalc(const spline1dinterpolant &c, const double x);
void spline1ddiff(const spline1dinterpolant &c, const double x, double &s, double &ds, double &d2s);
void spline1dunpack(const spline1dinterpolant &c, ae_int_t &n, real_2d_array &tbl);
void spline1dlintransx(const spline1dinterpolant &c, const double a, const double b);
void spline1dlintransy(const spline1dinterpolant &c, const double a, const double b);
double spline1dintegrate(const spline1dinterpolant &c, const double x);
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 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);
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 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);
void spline1dfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t n, const ae_int_t m, const double lambdans, spline1dinterpolant &s, spline1dfitreport &rep);
void spline1dfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, const double lambdans, spline1dinterpolant &s, spline1dfitreport &rep);
} // end of namespace alglib
// === LSFIT Package ===
// Depends on: (Optimization) MINLM
// Depends on: POLINT, SPLINE1D
namespace alglib_impl {
struct polynomialfitreport {
double taskrcond;
double rmserror;
double avgerror;
double avgrelerror;
double maxerror;
};
void polynomialfitreport_init(void *_p, bool make_automatic);
void polynomialfitreport_copy(void *_dst, const void *_src, bool make_automatic);
void polynomialfitreport_free(void *_p, bool make_automatic);
struct barycentricfitreport {
double taskrcond;
ae_int_t dbest;
double rmserror;
double avgerror;
double avgrelerror;
double maxerror;
};
void barycentricfitreport_init(void *_p, bool make_automatic);
void barycentricfitreport_copy(void *_dst, const void *_src, bool make_automatic);
void barycentricfitreport_free(void *_p, bool make_automatic);
struct lsfitreport {
double taskrcond;
ae_int_t iterationscount;
ae_int_t varidx;
double rmserror;
double avgerror;
double avgrelerror;
double maxerror;
double wrmserror;
ae_matrix covpar;
ae_vector errpar;
ae_vector errcurve;
ae_vector noise;
double r2;
};
void lsfitreport_init(void *_p, bool make_automatic);
void lsfitreport_copy(void *_dst, const void *_src, bool make_automatic);
void lsfitreport_free(void *_p, bool make_automatic);
struct lsfitstate {
ae_int_t optalgo;
ae_int_t m;
ae_int_t k;
double epsx;
ae_int_t maxits;
double stpmax;
bool xrep;
ae_vector c0;
ae_vector c1;
ae_vector s;
ae_vector bndl;
ae_vector bndu;
ae_matrix taskx;
ae_vector tasky;
ae_int_t npoints;
ae_vector taskw;
ae_int_t nweights;
ae_int_t wkind;
ae_int_t wits;
double diffstep;
double teststep;
ae_matrix cleic;
ae_int_t nec;
ae_int_t nic;
bool xupdated;
bool needf;
bool needfg;
bool needfgh;
ae_int_t pointindex;
ae_vector x;
ae_vector c;
double f;
ae_vector g;
ae_matrix h;
ae_vector wcur;
ae_vector tmpct;
ae_vector tmp;
ae_vector tmpf;
ae_matrix tmpjac;
ae_matrix tmpjacw;
double tmpnoise;
matinvreport invrep;
ae_int_t repiterationscount;
ae_int_t repterminationtype;
ae_int_t repvaridx;
double reprmserror;
double repavgerror;
double repavgrelerror;
double repmaxerror;
double repwrmserror;
lsfitreport rep;
minlmstate optstate;
minlmreport optrep;
ae_int_t prevnpt;
ae_int_t prevalgo;
ae_int_t PQ;
};
void lsfitstate_init(void *_p, bool make_automatic);
void lsfitstate_copy(void *_dst, const void *_src, bool make_automatic);
void lsfitstate_free(void *_p, bool make_automatic);
void lstfitpiecewiselinearrdpfixed(RVector *x, RVector *y, ae_int_t n, ae_int_t m, RVector *x2, RVector *y2, ae_int_t *nsections);
void lstfitpiecewiselinearrdp(RVector *x, RVector *y, ae_int_t n, double eps, RVector *x2, RVector *y2, ae_int_t *nsections);
void lsfitlinearw(RVector *y, RVector *w, RMatrix *fmatrix, ae_int_t n, ae_int_t m, ae_int_t *info, RVector *c, lsfitreport *rep);
void lsfitlinearwc(RVector *y, RVector *w, RMatrix *fmatrix, RMatrix *cmatrix, ae_int_t n, ae_int_t m, ae_int_t k, ae_int_t *info, RVector *c, lsfitreport *rep);
void lsfitlinear(RVector *y, RMatrix *fmatrix, ae_int_t n, ae_int_t m, ae_int_t *info, RVector *c, lsfitreport *rep);
void lsfitlinearc(RVector *y, RMatrix *fmatrix, RMatrix *cmatrix, ae_int_t n, ae_int_t m, ae_int_t k, ae_int_t *info, RVector *c, lsfitreport *rep);
void polynomialfitwc(RVector *x, RVector *y, RVector *w, ae_int_t n, RVector *xc, RVector *yc, ZVector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, barycentricinterpolant *p, polynomialfitreport *rep);
void polynomialfit(RVector *x, RVector *y, ae_int_t n, ae_int_t m, ae_int_t *info, barycentricinterpolant *p, polynomialfitreport *rep);
double logisticcalc4(double x, double a, double b, double c, double d);
double logisticcalc5(double x, double a, double b, double c, double d, double g);
void logisticfit45x(RVector *x, RVector *y, ae_int_t n, double cnstrleft, double cnstrright, bool is4pl, double lambdav, double epsx, ae_int_t rscnt, double *a, double *b, double *c, double *d, double *g, lsfitreport *rep);
void logisticfit4(RVector *x, RVector *y, ae_int_t n, double *a, double *b, double *c, double *d, lsfitreport *rep);
void logisticfit4ec(RVector *x, RVector *y, ae_int_t n, double cnstrleft, double cnstrright, double *a, double *b, double *c, double *d, lsfitreport *rep);
void logisticfit5(RVector *x, RVector *y, ae_int_t n, double *a, double *b, double *c, double *d, double *g, lsfitreport *rep);
void logisticfit5ec(RVector *x, RVector *y, ae_int_t n, double cnstrleft, double cnstrright, double *a, double *b, double *c, double *d, double *g, lsfitreport *rep);
void barycentricfitfloaterhormannwc(RVector *x, RVector *y, RVector *w, ae_int_t n, RVector *xc, RVector *yc, ZVector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, barycentricinterpolant *b, barycentricfitreport *rep);
void barycentricfitfloaterhormann(RVector *x, RVector *y, ae_int_t n, ae_int_t m, ae_int_t *info, barycentricinterpolant *b, barycentricfitreport *rep);
void spline1dfitcubicwc(RVector *x, RVector *y, RVector *w, ae_int_t n, RVector *xc, RVector *yc, ZVector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep);
void spline1dfitcubic(RVector *x, RVector *y, ae_int_t n, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep);
void spline1dfithermitewc(RVector *x, RVector *y, RVector *w, ae_int_t n, RVector *xc, RVector *yc, ZVector *dc, ae_int_t k, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep);
void spline1dfithermite(RVector *x, RVector *y, ae_int_t n, ae_int_t m, ae_int_t *info, spline1dinterpolant *s, spline1dfitreport *rep);
void lsfitsetcond(lsfitstate *state, double epsx, ae_int_t maxits);
void lsfitsetstpmax(lsfitstate *state, double stpmax);
void lsfitsetxrep(lsfitstate *state, bool needxrep);
void lsfitsetscale(lsfitstate *state, RVector *s);
void lsfitsetbc(lsfitstate *state, RVector *bndl, RVector *bndu);
void lsfitsetlc(lsfitstate *state, RMatrix *c, ZVector *ct, ae_int_t k);
void lsfitsetgradientcheck(lsfitstate *state, double teststep);
void lsfitcreatewf(RMatrix *x, RVector *y, RVector *w, RVector *c, ae_int_t n, ae_int_t m, ae_int_t k, double diffstep, lsfitstate *state);
void lsfitcreatef(RMatrix *x, RVector *y, RVector *c, ae_int_t n, ae_int_t m, ae_int_t k, double diffstep, lsfitstate *state);
void lsfitcreatewfg(RMatrix *x, RVector *y, RVector *w, RVector *c, ae_int_t n, ae_int_t m, ae_int_t k, bool cheapfg, lsfitstate *state);
void lsfitcreatefg(RMatrix *x, RVector *y, RVector *c, ae_int_t n, ae_int_t m, ae_int_t k, bool cheapfg, lsfitstate *state);
void lsfitcreatewfgh(RMatrix *x, RVector *y, RVector *w, RVector *c, ae_int_t n, ae_int_t m, ae_int_t k, lsfitstate *state);
void lsfitcreatefgh(RMatrix *x, RVector *y, RVector *c, ae_int_t n, ae_int_t m, ae_int_t k, lsfitstate *state);
bool lsfititeration(lsfitstate *state);
void lsfitresults(lsfitstate *state, ae_int_t *info, RVector *c, lsfitreport *rep);
} // end of namespace alglib_impl
namespace alglib {
DecClass(polynomialfitreport, double &taskrcond; double &rmserror; double &avgerror; double &avgrelerror; double &maxerror;);
DecClass(barycentricfitreport, double &taskrcond; ae_int_t &dbest; double &rmserror; double &avgerror; double &avgrelerror; double &maxerror;);
DecClass(lsfitreport, double &taskrcond; ae_int_t &iterationscount; ae_int_t &varidx; double &rmserror; double &avgerror; double &avgrelerror; double &maxerror; double &wrmserror; real_2d_array covpar; real_1d_array errpar; real_1d_array errcurve; real_1d_array noise; double &r2;);
DecClass(lsfitstate, bool &needf; bool &needfg; bool &needfgh; bool &xupdated; real_1d_array c; double &f; real_1d_array g; real_2d_array h; real_1d_array x;);
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 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 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 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);
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 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);
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);
void lsfitlinear(const real_1d_array &y, const real_2d_array &fmatrix, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
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 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);
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 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);
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 polynomialfit(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, barycentricinterpolant &p, polynomialfitreport &rep);
double logisticcalc4(const double x, const double a, const double b, const double c, const double d);
double logisticcalc5(const double x, const double a, const double b, const double c, const double d, const double g);
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 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);
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 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 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 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 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 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 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);
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);
void spline1dfitcubic(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
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 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);
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 spline1dfithermite(const real_1d_array &x, const real_1d_array &y, const ae_int_t m, ae_int_t &info, spline1dinterpolant &s, spline1dfitreport &rep);
void lsfitsetcond(const lsfitstate &state, const double epsx, const ae_int_t maxits);
void lsfitsetstpmax(const lsfitstate &state, const double stpmax);
void lsfitsetxrep(const lsfitstate &state, const bool needxrep);
void lsfitsetscale(const lsfitstate &state, const real_1d_array &s);
void lsfitsetbc(const lsfitstate &state, const real_1d_array &bndl, const real_1d_array &bndu);
void lsfitsetlc(const lsfitstate &state, const real_2d_array &c, const integer_1d_array &ct, const ae_int_t k);
void lsfitsetlc(const lsfitstate &state, const real_2d_array &c, const integer_1d_array &ct);
void lsfitsetgradientcheck(const lsfitstate &state, const double teststep);
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 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);
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 lsfitcreatef(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const double diffstep, lsfitstate &state);
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 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);
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 lsfitcreatefg(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, const bool cheapfg, lsfitstate &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 lsfitcreatewfgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &w, const real_1d_array &c, lsfitstate &state);
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 lsfitcreatefgh(const real_2d_array &x, const real_1d_array &y, const real_1d_array &c, lsfitstate &state);
bool lsfititeration(const lsfitstate &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 lsfitfit(lsfitstate &state, void (*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr), void (*grad)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, void *ptr), void (*rep)(const real_1d_array &c, double func, void *ptr) = NULL, void *ptr = NULL);
void lsfitfit(lsfitstate &state, void (*func)(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr), void (*grad)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, void *ptr), void (*hess)(const real_1d_array &c, const real_1d_array &x, double &func, real_1d_array &grad, real_2d_array &hess, void *ptr), void (*rep)(const real_1d_array &c, double func, void *ptr) = NULL, void *ptr = NULL);
void lsfitresults(const lsfitstate &state, ae_int_t &info, real_1d_array &c, lsfitreport &rep);
} // end of namespace alglib
// === FITSPHERE Package ===
// Depends on: (Optimization) MINLM, MINNLC
namespace alglib_impl {
struct fitsphereinternalreport {
ae_int_t nfev;
ae_int_t iterationscount;
};
void fitsphereinternalreport_init(void *_p, bool make_automatic);
void fitsphereinternalreport_copy(void *_dst, const void *_src, bool make_automatic);
void fitsphereinternalreport_free(void *_p, bool make_automatic);
void fitsphereinternal(RMatrix *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, RVector *cx, double *rlo, double *rhi, fitsphereinternalreport *rep);
void fitspherex(RMatrix *xy, ae_int_t npoints, ae_int_t nx, ae_int_t problemtype, double epsx, ae_int_t aulits, double penalty, RVector *cx, double *rlo, double *rhi);
void fitspherels(RMatrix *xy, ae_int_t npoints, ae_int_t nx, RVector *cx, double *r);
void fitspheremc(RMatrix *xy, ae_int_t npoints, ae_int_t nx, RVector *cx, double *rhi);
void fitspheremi(RMatrix *xy, ae_int_t npoints, ae_int_t nx, RVector *cx, double *rlo);
void fitspheremz(RMatrix *xy, ae_int_t npoints, ae_int_t nx, RVector *cx, double *rlo, double *rhi);
} // end of namespace alglib_impl
namespace alglib {
void fitspherex(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);
void fitspherels(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &r);
void fitspheremc(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rhi);
void fitspheremi(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rlo);
void fitspheremz(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nx, real_1d_array &cx, double &rlo, double &rhi);
} // end of namespace alglib
// === PARAMETRIC Package ===
// Depends on: (Integration) AUTOGK
// Depends on: SPLINE1D
namespace alglib_impl {
struct pspline2interpolant {
ae_int_t n;
bool periodic;
ae_vector p;
spline1dinterpolant x;
spline1dinterpolant y;
};
void pspline2interpolant_init(void *_p, bool make_automatic);
void pspline2interpolant_copy(void *_dst, const void *_src, bool make_automatic);
void pspline2interpolant_free(void *_p, bool make_automatic);
struct pspline3interpolant {
ae_int_t n;
bool periodic;
ae_vector p;
spline1dinterpolant x;
spline1dinterpolant y;
spline1dinterpolant z;
};
void pspline3interpolant_init(void *_p, bool make_automatic);
void pspline3interpolant_copy(void *_dst, const void *_src, bool make_automatic);
void pspline3interpolant_free(void *_p, bool make_automatic);
void pspline2build(RMatrix *xy, ae_int_t n, ae_int_t st, ae_int_t pt, pspline2interpolant *p);
void pspline3build(RMatrix *xy, ae_int_t n, ae_int_t st, ae_int_t pt, pspline3interpolant *p);
void pspline2buildperiodic(RMatrix *xy, ae_int_t n, ae_int_t st, ae_int_t pt, pspline2interpolant *p);
void pspline3buildperiodic(RMatrix *xy, ae_int_t n, ae_int_t st, ae_int_t pt, pspline3interpolant *p);
void pspline2parametervalues(pspline2interpolant *p, ae_int_t *n, RVector *t);
void pspline3parametervalues(pspline3interpolant *p, ae_int_t *n, RVector *t);
void pspline2calc(pspline2interpolant *p, double t, double *x, double *y);
void pspline3calc(pspline3interpolant *p, double t, double *x, double *y, double *z);
void pspline2diff(pspline2interpolant *p, double t, double *x, double *dx, double *y, double *dy);
void pspline3diff(pspline3interpolant *p, double t, double *x, double *dx, double *y, double *dy, double *z, double *dz);
void pspline2tangent(pspline2interpolant *p, double t, double *x, double *y);
void pspline3tangent(pspline3interpolant *p, double t, double *x, double *y, double *z);
void pspline2diff2(pspline2interpolant *p, double t, double *x, double *dx, double *d2x, double *y, double *dy, double *d2y);
void pspline3diff2(pspline3interpolant *p, double t, double *x, double *dx, double *d2x, double *y, double *dy, double *d2y, double *z, double *dz, double *d2z);
double pspline2arclength(pspline2interpolant *p, double a, double b);
double pspline3arclength(pspline3interpolant *p, double a, double b);
void parametricrdpfixed(RMatrix *x, ae_int_t n, ae_int_t d, ae_int_t stopm, double stopeps, RMatrix *x2, ZVector *idx2, ae_int_t *nsections);
} // end of namespace alglib_impl
namespace alglib {
DecClass(pspline2interpolant, );
DecClass(pspline3interpolant, );
void pspline2build(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline2interpolant &p);
void pspline3build(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline3interpolant &p);
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 pspline3buildperiodic(const real_2d_array &xy, const ae_int_t n, const ae_int_t st, const ae_int_t pt, pspline3interpolant &p);
void pspline2parametervalues(const pspline2interpolant &p, ae_int_t &n, real_1d_array &t);
void pspline3parametervalues(const pspline3interpolant &p, ae_int_t &n, real_1d_array &t);
void pspline2calc(const pspline2interpolant &p, const double t, double &x, double &y);
void pspline3calc(const pspline3interpolant &p, const double t, double &x, double &y, double &z);
void pspline2diff(const pspline2interpolant &p, const double t, double &x, double &dx, double &y, double &dy);
void pspline3diff(const pspline3interpolant &p, const double t, double &x, double &dx, double &y, double &dy, double &z, double &dz);
void pspline2tangent(const pspline2interpolant &p, const double t, double &x, double &y);
void pspline3tangent(const pspline3interpolant &p, const double t, double &x, double &y, double &z);
void pspline2diff2(const pspline2interpolant &p, const double t, double &x, double &dx, double &d2x, double &y, double &dy, double &d2y);
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);
double pspline2arclength(const pspline2interpolant &p, const double a, const double b);
double pspline3arclength(const pspline3interpolant &p, const double a, const double b);
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);
} // end of namespace alglib
// === RBFV1 Package ===
// Depends on: (AlgLibMisc) NEARESTNEIGHBOR
// Depends on: LSFIT
namespace alglib_impl {
struct rbfv1calcbuffer {
ae_vector calcbufxcx;
ae_matrix calcbufx;
ae_vector calcbuftags;
kdtreerequestbuffer requestbuffer;
};
void rbfv1calcbuffer_init(void *_p, bool make_automatic);
void rbfv1calcbuffer_copy(void *_dst, const void *_src, bool make_automatic);
void rbfv1calcbuffer_free(void *_p, bool make_automatic);
struct rbfv1model {
ae_int_t ny;
ae_int_t nx;
ae_int_t nc;
ae_int_t nl;
kdtree tree;
ae_matrix xc;
ae_matrix wr;
double rmax;
ae_matrix v;
ae_vector calcbufxcx;
ae_matrix calcbufx;
ae_vector calcbuftags;
};
void rbfv1model_init(void *_p, bool make_automatic);
void rbfv1model_copy(void *_dst, const void *_src, bool make_automatic);
void rbfv1model_free(void *_p, bool make_automatic);
void rbfv1alloc(ae_serializer *s, rbfv1model *model);
void rbfv1serialize(ae_serializer *s, rbfv1model *model);
void rbfv1unserialize(ae_serializer *s, rbfv1model *model);
struct gridcalc3v1buf {
ae_vector tx;
ae_vector cx;
ae_vector ty;
ae_vector flag0;
ae_vector flag1;
ae_vector flag2;
ae_vector flag12;
ae_vector expbuf0;
ae_vector expbuf1;
ae_vector expbuf2;
kdtreerequestbuffer requestbuf;
ae_matrix calcbufx;
ae_vector calcbuftags;
};
void gridcalc3v1buf_init(void *_p, bool make_automatic);
void gridcalc3v1buf_copy(void *_dst, const void *_src, bool make_automatic);
void gridcalc3v1buf_free(void *_p, bool make_automatic);
struct rbfv1report {
ae_int_t arows;
ae_int_t acols;
ae_int_t annz;
ae_int_t iterationscount;
ae_int_t nmv;
ae_int_t terminationtype;
};
void rbfv1report_init(void *_p, bool make_automatic);
void rbfv1report_copy(void *_dst, const void *_src, bool make_automatic);
void rbfv1report_free(void *_p, bool make_automatic);
void rbfv1create(ae_int_t nx, ae_int_t ny, rbfv1model *s);
void rbfv1createcalcbuffer(rbfv1model *s, rbfv1calcbuffer *buf);
void rbfv1buildmodel(RMatrix *x, RMatrix *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);
double rbfv1calc2(rbfv1model *s, double x0, double x1);
double rbfv1calc3(rbfv1model *s, double x0, double x1, double x2);
void rbfv1calcbuf(rbfv1model *s, RVector *x, RVector *y);
void rbfv1tscalcbuf(rbfv1model *s, rbfv1calcbuffer *buf, RVector *x, RVector *y);
void rbfv1tsdiffbuf(rbfv1model *s, rbfv1calcbuffer *buf, RVector *x, RVector *y, RVector *dy);
void rbfv1tshessbuf(rbfv1model *s, rbfv1calcbuffer *buf, RVector *x, RVector *y, RVector *dy, RVector *d2y);
void rbfv1gridcalc2(rbfv1model *s, RVector *x0, ae_int_t n0, RVector *x1, ae_int_t n1, RMatrix *y);
void rbfv1gridcalc3vrec(rbfv1model *s, RVector *x0, ae_int_t n0, RVector *x1, ae_int_t n1, RVector *x2, ae_int_t n2, ZVector *blocks0, ae_int_t block0a, ae_int_t block0b, ZVector *blocks1, ae_int_t block1a, ae_int_t block1b, ZVector *blocks2, ae_int_t block2a, ae_int_t block2b, BVector *flagy, bool sparsey, double searchradius, double avgfuncpernode, ae_shared_pool *bufpool, RVector *y);
void rbfv1unpack(rbfv1model *s, ae_int_t *nx, ae_int_t *ny, RMatrix *xwr, ae_int_t *nc, RMatrix *v);
} // end of namespace alglib_impl
// === RBFV3FARFIELDS Package ===
// Depends on: (AlgLibInternal) SCODES, TSORT
namespace alglib_impl {
struct biharmonicevaluator {
ae_int_t maxp;
ae_int_t precomputedcount;
ae_vector tdoublefactorial;
ae_vector tfactorial;
ae_vector tsqrtfactorial;
ae_vector tpowminus1;
ae_vector tpowi;
ae_vector tpowminusi;
ae_vector ynma;
ae_vector pnma;
ae_vector pnmb;
ae_vector pmmc;
ae_vector pmmcdiag;
ae_vector mnma;
ae_vector nnma;
ae_vector inma;
};
void biharmonicevaluator_init(void *_p, bool make_automatic);
void biharmonicevaluator_copy(void *_dst, const void *_src, bool make_automatic);
void biharmonicevaluator_free(void *_p, bool make_automatic);
struct biharmonicpanel {
double c0;
double c1;
double c2;
double rmax;
double useatdistance;
ae_int_t ny;
ae_int_t p;
ae_int_t sizen;
ae_int_t sizem;
ae_int_t stride;
ae_int_t sizeinner;
ae_vector tbln;
ae_vector tblm;
ae_vector tblmodn;
ae_vector tblmodm;
ae_vector tblpowrmax;
ae_vector tblrmodmn;
double maxsumabs;
ae_vector funcsphericaly;
ae_vector tpowr;
};
void biharmonicpanel_init(void *_p, bool make_automatic);
void biharmonicpanel_copy(void *_dst, const void *_src, bool make_automatic);
void biharmonicpanel_free(void *_p, bool make_automatic);
void biharmonicevaluatorinit(biharmonicevaluator *eval, ae_int_t maxp);
void bhpanelinit(biharmonicpanel *panel, RMatrix *xw, ae_int_t xidx0, ae_int_t xidx1, ae_int_t ny, biharmonicevaluator *eval);
void bhpanelsetprec(biharmonicpanel *panel, double tol);
void bhpaneleval1(biharmonicpanel *panel, biharmonicevaluator *eval, double x0, double x1, double x2, double *f, bool neederrbnd, double *errbnd);
void bhpaneleval(biharmonicpanel *panel, biharmonicevaluator *eval, double x0, double x1, double x2, RVector *f, bool neederrbnd, double *errbnd);
} // end of namespace alglib_impl
// === RBFV3 Package ===
// Depends on: (AlgLibMisc) NEARESTNEIGHBOR
// Depends on: (LinAlg) RCOND
// Depends on: (Solvers) ITERATIVESPARSE
// Depends on: RBFV3FARFIELDS
namespace alglib_impl {
struct rbf3evaluatorbuffer {
ae_vector x;
ae_vector y;
ae_vector coeffbuf;
ae_vector funcbuf;
ae_vector wrkbuf;
ae_vector mindist2;
ae_vector df1;
ae_vector df2;
ae_vector x2;
ae_vector y2;
ae_matrix deltabuf;
};
void rbf3evaluatorbuffer_init(void *_p, bool make_automatic);
void rbf3evaluatorbuffer_copy(void *_dst, const void *_src, bool make_automatic);
void rbf3evaluatorbuffer_free(void *_p, bool make_automatic);
struct rbf3panel {
ae_int_t paneltype;
double clusterrad;
ae_vector clustercenter;
double c0;
double c1;
double c2;
double c3;
ae_int_t farfieldexpansion;
double farfielddistance;
ae_int_t idx0;
ae_int_t idx1;
ae_int_t childa;
ae_int_t childb;
ae_vector ptidx;
ae_matrix xt;
ae_matrix wt;
biharmonicpanel bhexpansion;
rbf3evaluatorbuffer tgtbuf;
};
void rbf3panel_init(void *_p, bool make_automatic);
void rbf3panel_copy(void *_dst, const void *_src, bool make_automatic);
void rbf3panel_free(void *_p, bool make_automatic);
struct rbf3fastevaluator {
ae_int_t n;
ae_int_t nx;
ae_int_t ny;
ae_int_t maxpanelsize;
ae_int_t functype;
double funcparam;
ae_matrix permx;
ae_vector origptidx;
ae_matrix wstoredorig;
bool isloaded;
ae_obj_array panels;
biharmonicevaluator bheval;
ae_shared_pool bufferpool;
ae_matrix tmpx3w;
};
void rbf3fastevaluator_init(void *_p, bool make_automatic);
void rbf3fastevaluator_copy(void *_dst, const void *_src, bool make_automatic);
void rbf3fastevaluator_free(void *_p, bool make_automatic);
struct rbf3evaluator {
ae_int_t n;
ae_int_t storagetype;
ae_matrix f;
ae_int_t nx;
ae_int_t functype;
double funcparam;
ae_int_t chunksize;
ae_vector entireset;
ae_matrix x;
ae_matrix xtchunked;
ae_shared_pool bufferpool;
ae_vector chunk1;
};
void rbf3evaluator_init(void *_p, bool make_automatic);
void rbf3evaluator_copy(void *_dst, const void *_src, bool make_automatic);
void rbf3evaluator_free(void *_p, bool make_automatic);
struct rbfv3calcbuffer {
ae_vector x;
rbf3evaluatorbuffer evalbuf;
ae_vector x123;
ae_vector y123;
ae_matrix x2d;
ae_matrix y2d;
ae_vector xg;
ae_vector yg;
};
void rbfv3calcbuffer_init(void *_p, bool make_automatic);
void rbfv3calcbuffer_copy(void *_dst, const void *_src, bool make_automatic);
void rbfv3calcbuffer_free(void *_p, bool make_automatic);
struct acbfbuilder {
ae_int_t ntotal;
ae_int_t nx;
ae_matrix xx;
ae_int_t functype;
double funcparam;
double roughdatasetdiameter;
ae_int_t nglobal;
ae_vector globalgrid;
double globalgridseparation;
ae_int_t nlocal;
ae_int_t ncorrection;
double correctorgrowth;
ae_int_t batchsize;
double lambdav;
ae_int_t aterm;
kdtree kdt;
kdtree kdt1;
kdtree kdt2;
ae_shared_pool bufferpool;
ae_shared_pool chunksproducer;
ae_shared_pool chunkspool;
ae_vector wrkidx;
};
void acbfbuilder_init(void *_p, bool make_automatic);
void acbfbuilder_copy(void *_dst, const void *_src, bool make_automatic);
void acbfbuilder_free(void *_p, bool make_automatic);
struct acbfbuffer {
ae_vector bflags;
kdtreerequestbuffer kdtbuf;
kdtreerequestbuffer kdt1buf;
kdtreerequestbuffer kdt2buf;
ae_vector tmpboxmin;
ae_vector tmpboxmax;
ae_vector currentnodes;
ae_vector neighbors;
ae_vector chosenneighbors;
ae_vector y;
ae_vector z;
ae_vector d;
ae_matrix atwrk;
ae_matrix xq;
ae_matrix q;
ae_matrix q1;
ae_matrix wrkq;
ae_matrix b;
ae_matrix c;
ae_vector choltmp;
ae_vector tau;
ae_matrix r;
ae_vector perm;
};
void acbfbuffer_init(void *_p, bool make_automatic);
void acbfbuffer_copy(void *_dst, const void *_src, bool make_automatic);
void acbfbuffer_free(void *_p, bool make_automatic);
struct acbfchunk {
ae_int_t ntargetrows;
ae_int_t ntargetcols;
ae_vector targetrows;
ae_vector targetcols;
ae_matrix s;
};
void acbfchunk_init(void *_p, bool make_automatic);
void acbfchunk_copy(void *_dst, const void *_src, bool make_automatic);
void acbfchunk_free(void *_p, bool make_automatic);
struct rbf3ddmbuffer {
ae_vector bflags;
ae_vector idx2preccol;
kdtreerequestbuffer kdtbuf;
ae_vector tmpboxmin;
ae_vector tmpboxmax;
};
void rbf3ddmbuffer_init(void *_p, bool make_automatic);
void rbf3ddmbuffer_copy(void *_dst, const void *_src, bool make_automatic);
void rbf3ddmbuffer_free(void *_p, bool make_automatic);
struct rbf3ddmsubproblem {
bool isvalid;
ae_int_t ntarget;
ae_vector targetnodes;
ae_int_t nwork;
ae_vector workingnodes;
ae_matrix regsystem;
ae_int_t decomposition;
ae_matrix wrklu;
ae_matrix rhs;
ae_matrix qtrhs;
ae_matrix sol;
ae_matrix pred;
ae_vector wrkp;
ae_matrix wrkq;
ae_matrix wrkr;
};
void rbf3ddmsubproblem_init(void *_p, bool make_automatic);
void rbf3ddmsubproblem_copy(void *_dst, const void *_src, bool make_automatic);
void rbf3ddmsubproblem_free(void *_p, bool make_automatic);
struct rbf3ddmsolver {
double lambdav;
kdtree kdt;
ae_shared_pool bufferpool;
ae_int_t subproblemscnt;
ae_shared_pool subproblemspool;
ae_shared_pool subproblemsbuffer;
ae_int_t ncorrector;
ae_matrix corrq;
ae_matrix corrr;
ae_vector corrnodes;
ae_matrix corrx;
ae_matrix tmpres1;
ae_matrix tmpupd1;
ae_int_t cntlu;
ae_int_t cntregqr;
};
void rbf3ddmsolver_init(void *_p, bool make_automatic);
void rbf3ddmsolver_copy(void *_dst, const void *_src, bool make_automatic);
void rbf3ddmsolver_free(void *_p, bool make_automatic);
struct rbfv3model {
ae_int_t ny;
ae_int_t nx;
ae_int_t bftype;
double bfparam;
ae_vector s;