SAGA API  v9.2
mat_tools.h
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // mat_tools.h //
15 // //
16 // Copyright (C) 2005 by Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. //
22 // //
23 // This library is free software; you can redistribute //
24 // it and/or modify it under the terms of the GNU Lesser //
25 // General Public License as published by the Free //
26 // Software Foundation, either version 2.1 of the //
27 // License, or (at your option) any later version. //
28 // //
29 // This library is distributed in the hope that it will //
30 // be useful, but WITHOUT ANY WARRANTY; without even the //
31 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
32 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
33 // License for more details. //
34 // //
35 // You should have received a copy of the GNU Lesser //
36 // General Public License along with this program; if //
37 // not, see <http://www.gnu.org/licenses/>. //
38 // //
39 //-------------------------------------------------------//
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Goettingen //
44 // Goldschmidtstr. 5 //
45 // 37077 Goettingen //
46 // Germany //
47 // //
48 // e-mail: oconrad@saga-gis.org //
49 // //
51 
52 //---------------------------------------------------------
53 #ifndef HEADER_INCLUDED__SAGA_API__mat_tools_H
54 #define HEADER_INCLUDED__SAGA_API__mat_tools_H
55 
56 
58 // //
59 // //
60 // //
62 
63 //---------------------------------------------------------
80 // //
82 // //
83 // //
85 
86 //---------------------------------------------------------
87 #include "geo_tools.h"
88 
89 
91 // //
92 // //
93 // //
95 
96 //---------------------------------------------------------
97 #ifndef M_PI
98 #define M_PI 3.141592653589793
99 #endif
100 
101 #define M_PI_045 (M_PI / 4.)
102 #define M_PI_090 (M_PI / 2.)
103 #define M_PI_135 (M_PI * 3. / 4.)
104 #define M_PI_180 (M_PI)
105 #define M_PI_225 (M_PI * 5. / 4.)
106 #define M_PI_270 (M_PI * 3. / 2.)
107 #define M_PI_315 (M_PI * 7. / 4.)
108 #define M_PI_360 (M_PI * 2.)
109 
110 #define M_RAD_TO_DEG (180. / M_PI)
111 #define M_DEG_TO_RAD (M_PI / 180.)
112 
113 //---------------------------------------------------------
114 #define M_EULER 2.718281828459045
115 
116 //---------------------------------------------------------
117 #define N_MEGABYTE_BYTES 0x100000
118 
119 //---------------------------------------------------------
120 #define M_ALMOST_ZERO 0.001l
121 #define M_TINY (1.0e-20)
122 
123 //---------------------------------------------------------
124 #define M_SQR(x) ((x) * (x))
125 #define M_SQRT(x) sqrt((double)(x))
126 #define M_GET_LENGTH(x, y) sqrt((double)((x)*(x) + (y)*(y)))
127 
128 #define M_GET_MIN(a, b) (((a) < (b)) ? (a) : (b))
129 #define M_GET_MAX(a, b) (((a) > (b)) ? (a) : (b))
130 #define M_SET_MINMAX(min, max, x) if( min > x ) { min = x; } else if( max < x ) { max = x; }
131 
132 #define M_SET_SIGN(x, sign) ((sign) < 0 ? (x < 0 ? x : -x) : (x > 0 ? x : -x))
133 
134 //---------------------------------------------------------
135 #define SG_ROUND_TO_BYTE(x) ((BYTE )(x < 0. ? x - 0.5 : x + 0.5))
136 #define SG_ROUND_TO_CHAR(x) ((char )(x < 0. ? x - 0.5 : x + 0.5))
137 #define SG_ROUND_TO_WORD(x) ((WORD )(x < 0. ? x - 0.5 : x + 0.5))
138 #define SG_ROUND_TO_SHORT(x) ((short)(x < 0. ? x - 0.5 : x + 0.5))
139 #define SG_ROUND_TO_DWORD(x) ((DWORD)(x < 0. ? x - 0.5 : x + 0.5))
140 #define SG_ROUND_TO_INT(x) ((int )(x < 0. ? x - 0.5 : x + 0.5))
141 #define SG_ROUND_TO_LONG(x) ((long )(x < 0. ? x - 0.5 : x + 0.5))
142 #define SG_ROUND_TO_ULONG(x) ((uLong)(x < 0. ? x - 0.5 : x + 0.5))
143 #define SG_ROUND_TO_SLONG(x) ((sLong)(x < 0. ? x - 0.5 : x + 0.5))
144 
145 
147 // //
148 // //
149 // //
151 
152 //---------------------------------------------------------
153 SAGA_API_DLL_EXPORT double SG_Get_Square (double Value);
154 
155 SAGA_API_DLL_EXPORT double SG_Get_Rounded (double Value, int Decimals = 0);
156 SAGA_API_DLL_EXPORT double SG_Get_Rounded_To_SignificantFigures (double Value, int Decimals);
157 
158 //---------------------------------------------------------
159 SAGA_API_DLL_EXPORT int SG_Get_Digit_Count (int Number);
160 
161 //---------------------------------------------------------
162 SAGA_API_DLL_EXPORT CSG_String SG_Get_Double_asString (double Number, int Width = -1, int Precision = -1, bool bScientific = false);
163 
164 //---------------------------------------------------------
165 SAGA_API_DLL_EXPORT int SG_Compare_Int (const void *a, const void *b);
166 SAGA_API_DLL_EXPORT int SG_Compare_Double (const void *a, const void *b);
167 SAGA_API_DLL_EXPORT int SG_Compare_Char_Ptr (const void *a, const void *b);
168 
169 //---------------------------------------------------------
170 SAGA_API_DLL_EXPORT double SG_Degree_To_Decimal ( double Deg, double Min, double Sec);
171 SAGA_API_DLL_EXPORT void SG_Decimal_To_Degree (double Value, double &Deg, double &Min, double &Sec);
172 
173 
175 // //
176 // //
177 // //
179 
180 //---------------------------------------------------------
181 typedef int (* TSG_PFNC_Compare) (const sLong a, const sLong b);
182 
183 //---------------------------------------------------------
185 {
186 public:
188  {
189  public:
191  virtual ~CSG_Index_Compare(void) {}
192 
193  virtual int Compare (const sLong a, const sLong b) = 0;
194  };
195 
196 
197 public:
198  CSG_Index(void);
199  virtual ~CSG_Index(void);
200 
201  CSG_Index (sLong nValues, CSG_Index_Compare &Compare);
202  bool Create (sLong nValues, CSG_Index_Compare &Compare);
203 
204  CSG_Index (sLong nValues, CSG_Index_Compare *pCompare);
205  bool Create (sLong nValues, CSG_Index_Compare *pCompare);
206 
207  CSG_Index (sLong nValues, int *Values, bool bAscending = true);
208  bool Create (sLong nValues, int *Values, bool bAscending = true);
209 
210  CSG_Index (sLong nValues, double *Values, bool bAscending = true);
211  bool Create (sLong nValues, double *Values, bool bAscending = true);
212 
213  CSG_Index (sLong nValues, TSG_PFNC_Compare fCompare);
214  bool Create (sLong nValues, TSG_PFNC_Compare fCompare);
215 
216  bool Destroy (void);
217 
218  void Show_Progress (bool bProgress = true);
219 
220  bool Add_Entry (sLong Position = -1);
221  bool Del_Entry (sLong Position = -1);
222 
223  bool is_Okay (void) const { return( m_nValues > 0 ); }
224  sLong Get_Count (void) const { return( m_nValues ); }
225 
226  sLong Get_Index (sLong Position, bool Ascending = true) const
227  {
228  return( Position < 0 || Position >= m_nValues ? -1 : m_Index[Ascending ? Position : m_nValues - 1 - Position] );
229  }
230 
231  sLong operator [] (sLong Position) const
232  {
233  return( Position < 0 || Position >= m_nValues ? -1 : m_Index[Position] );
234  }
235 
236 
237 private:
238 
239  bool m_bProgress;
240 
241  sLong m_nValues, *m_Index;
242 
243 
244  void _On_Construction (void);
245 
246  bool _Set_Array (sLong nValues);
247  bool _Set_Index (CSG_Index_Compare *pCompare);
248 
249 };
250 
251 
253 // //
254 // //
255 // //
257 
258 //---------------------------------------------------------
260 {
261 public:
262 
263  //-----------------------------------------------------
265  {
266  public:
268 
269  virtual int Compare (CSG_PriorityQueueItem *pItem) = 0;
270 
271  };
272 
273  //-----------------------------------------------------
274  CSG_PriorityQueue(size_t maxSize = 256);
275 
276  virtual ~CSG_PriorityQueue(void);
277 
278  void Create (size_t maxSize = 256);
279  void Destroy (void);
280 
281  //-----------------------------------------------------
282  bool is_Empty (void) const { return( m_nItems == 0 ); }
283  size_t Get_Size (void) const { return( m_nItems ); }
284  CSG_PriorityQueueItem * Get_Item (size_t i) const { return( m_Items[i] ); }
285 
286  void Add (CSG_PriorityQueueItem *pItem);
287 
288  CSG_PriorityQueueItem * Peek (void) const { return( Minimum() ); }
289  CSG_PriorityQueueItem * Poll (void);
290 
291  //-----------------------------------------------------
293  {
294  if( m_nItems )
295  {
296  if( m_pLeaf[0] )
297  {
298  return( m_pLeaf[0]->Minimum() );
299  }
300 
301  return( m_Items[0] );
302  }
303 
304  return( NULL );
305  }
306 
308  {
309  if( m_nItems )
310  {
311  if( m_pLeaf[1] )
312  {
313  return( m_pLeaf[1]->Maximum() );
314  }
315 
316  return( m_Items[m_nItems - 1] );
317  }
318 
319  return( NULL );
320  }
321 
322 
323 private:
324 
325  size_t m_nItems, m_maxSize;
326 
327  CSG_PriorityQueue *m_pLeaf[2];
328 
329  CSG_PriorityQueueItem **m_Items;
330 
331 
332  size_t _Insert_Position (CSG_PriorityQueueItem *pItem);
333 
334 };
335 
336 
338 // //
339 // //
340 // //
342 
343 //---------------------------------------------------------
345 {
346 public:
347  CSG_Vector(void);
348  virtual ~CSG_Vector(void);
349 
350  CSG_Vector (const CSG_Vector &Vector);
351  bool Create (const CSG_Vector &Vector);
352 
353  CSG_Vector (sLong n, const double *Data = NULL);
354  bool Create (sLong n, const double *Data = NULL);
355 
356  bool Destroy (void);
357 
358  bool Set_Rows (sLong nRows);
359  bool Add_Rows (sLong nRows);
360  bool Del_Rows (sLong nRows);
361  bool Add_Row (double Value = 0.);
362  bool Del_Row (sLong Row = -1);
363 
364  sLong Get_Row_Count (void) const { return( m_Array.Get_Size () ); }
365  sLong Get_Size (void) const { return( m_Array.Get_Size () ); }
366  size_t Get_uSize (void) const { return( m_Array.Get_uSize() ); }
367  int Get_N (void) const { return( (int)m_Array.Get_Size() ); }
368 
369  double * Get_Data (void) const { return( (double *)m_Array.Get_Array() ); }
370  double Get_Data (sLong x) const { return( Get_Data()[x] ); }
371  double operator () (sLong x) const { return( Get_Data()[x] ); }
372  double & operator [] (sLong x) { return( Get_Data()[x] ); }
373  double & operator [] (size_t x) { return( Get_Data()[x] ); }
374  double & operator [] (int x) { return( Get_Data()[x] ); }
375  const double & operator [] (sLong x) const { return( Get_Data()[x] ); }
376  const double & operator [] (size_t x) const { return( Get_Data()[x] ); }
377  const double & operator [] (int x) const { return( Get_Data()[x] ); }
378  operator const double * (void) const { return( Get_Data() ); }
379 
380  CSG_String to_String (int Width = -1, int Precision = -1, bool bScientific = false, const SG_Char *Separator = NULL) const;
381  bool from_String (const CSG_String &String);
382 
383  bool is_Null (void) const;
384  bool is_Equal (const CSG_Vector &Vector) const;
385  bool is_Collinear (const CSG_Vector &Vector) const;
386 
387  bool Assign (double Scalar);
388  bool Assign (const CSG_Vector &Vector);
389  bool Add (double Scalar);
390  bool Add (const CSG_Vector &Vector);
391  bool Subtract (const CSG_Vector &Vector);
392  bool Multiply (double Scalar);
393  bool Multiply (const CSG_Vector &Vector);
394  bool Multiply_Cross (const CSG_Vector &Vector);
395  double Multiply_Scalar (const CSG_Vector &Vector) const;
396  bool Multiply (const class CSG_Matrix &Matrix);
397 
398  bool operator == (const CSG_Vector &Vector) const { return( is_Equal(Vector) ); }
399  bool operator != (const CSG_Vector &Vector) const { return( !is_Equal(Vector) ); }
400  CSG_Vector & operator = (double Scalar);
401  CSG_Vector & operator = (const CSG_Vector &Vector);
402  CSG_Vector & operator += (double Scalar);
403  CSG_Vector & operator += (const CSG_Vector &Vector);
404  CSG_Vector & operator -= (double Scalar);
405  CSG_Vector & operator -= (const CSG_Vector &Vector);
406  CSG_Vector & operator *= (double Scalar);
407  CSG_Vector & operator *= (const CSG_Vector &Vector);
408  CSG_Vector & operator *= (const class CSG_Matrix &Matrix);
409  CSG_Vector operator + (double Scalar) const;
410  CSG_Vector operator + (const CSG_Vector &Vector) const;
411  CSG_Vector operator - (double Scalar) const;
412  CSG_Vector operator - (const CSG_Vector &Vector) const;
413  CSG_Vector operator * (double Scalar) const;
414  double operator * (const CSG_Vector &Vector) const;
415 
416  bool Set_Zero (void);
417  bool Set_Unity (void);
418 
419  bool Flip_Values (void);
420 
421  bool Sort (bool bAscending = true);
422 
423  double Get_Length (void) const;
424  CSG_Vector Get_Scalar_Product (const CSG_Vector &Vector) const;
425  CSG_Vector Get_Cross_Product (const CSG_Vector &Vector) const;
426  double Get_Angle (const CSG_Vector &Vector) const;
427  CSG_Vector Get_Unity (void) const;
428 
429  typedef double const * const_iterator;
430 
431  const_iterator begin (void) const { return( Get_Data() ); }
432  const_iterator end (void) const { return( Get_Data() + Get_Size() ); }
433  const_iterator cbegin (void) const { return( Get_Data() ); }
434  const_iterator cend (void) const { return( Get_Data() + Get_Size() ); }
435 
436 
437 private:
438 
439  CSG_Array m_Array;
440 
441 };
442 
443 //---------------------------------------------------------
444 SAGA_API_DLL_EXPORT CSG_Vector operator * (double Scalar, const CSG_Vector &Vector);
445 
446 //---------------------------------------------------------
447 SAGA_API_DLL_EXPORT bool SG_VectorR2_Rotate (double &x, double &y, double Angle);
448 SAGA_API_DLL_EXPORT bool SG_VectorR2_Rotate (double Vector[2], double Angle);
449 SAGA_API_DLL_EXPORT bool SG_VectorR2_Rotate (CSG_Vector &Vector , double Angle);
450 
451 SAGA_API_DLL_EXPORT bool SG_VectorR3_Rotate (double Vector[3], size_t Axis, double Angle);
452 SAGA_API_DLL_EXPORT bool SG_VectorR3_Rotate (CSG_Vector &Vector , size_t Axis, double Angle);
453 
454 
456 // //
457 // //
458 // //
460 
461 //---------------------------------------------------------
463 {
464 public:
465  CSG_Matrix(void);
466  virtual ~CSG_Matrix(void);
467 
468  CSG_Matrix (const CSG_Matrix &Matrix);
469  bool Create (const CSG_Matrix &Matrix);
470 
471  CSG_Matrix (sLong nCols, sLong nRows, const double *Data = NULL);
472  bool Create (sLong nCols, sLong nRows, const double *Data = NULL);
473 
474  CSG_Matrix (sLong nCols, sLong nRows, const double **Data);
475  bool Create (sLong nCols, sLong nRows, const double **Data);
476 
477  bool Destroy (void);
478 
479  bool Set_Size (sLong nRows, sLong nCols);
480  bool Set_Cols (sLong nCols);
481  bool Set_Rows (sLong nRows);
482  bool Add_Cols (sLong nCols);
483  bool Add_Rows (sLong nRows);
484  bool Del_Cols (sLong nCols);
485  bool Del_Rows (sLong nRows);
486  bool Add_Col ( const double *Data = NULL);
487  bool Add_Col ( const CSG_Vector &Data);
488  bool Add_Row ( const double *Data = NULL);
489  bool Add_Row ( const CSG_Vector &Data);
490  bool Ins_Col (sLong Col, const double *Data = NULL);
491  bool Ins_Col (sLong Col, const CSG_Vector &Data);
492  bool Ins_Row (sLong Row, const double *Data = NULL);
493  bool Ins_Row (sLong Row, const CSG_Vector &Data);
494  bool Set_Col (sLong Col, const double *Data);
495  bool Set_Col (sLong Col, const CSG_Vector &Data);
496  bool Set_Col ( const CSG_Vector &Data);
497  bool Set_Row (sLong Row, const double *Data);
498  bool Set_Row (sLong Row, const CSG_Vector &Data);
499  bool Set_Row ( const CSG_Vector &Data);
500  bool Del_Col (sLong Col);
501  bool Del_Row (sLong Row);
502  CSG_Vector Get_Col (sLong Col) const;
503  CSG_Vector Get_Row (sLong Row) const;
504 
505  int Get_NX (void) const { return( (int)m_nx ); }
506  int Get_NY (void) const { return( (int)m_ny ); }
507  sLong Get_NCols (void) const { return( m_nx ); }
508  sLong Get_NRows (void) const { return( m_ny ); }
509 
510  operator const double ** (void) const { return( (const double **)m_z ); }
511  double ** Get_Data (void) const { return( m_z ); }
512 
513  double operator () (sLong Row, sLong Col) const { return( m_z[Row][Col] ); }
514  double * operator [] (sLong Row) const { return( m_z[Row] ); }
515  double * operator [] (size_t Row) const { return( m_z[Row] ); }
516  double * operator [] (int Row) const { return( m_z[Row] ); }
517 
518  CSG_String to_String (int Width = -1, int Precision = -1, bool bScientific = false, const SG_Char *Separator = NULL) const;
519  bool from_String (const CSG_String &String);
520 
521  bool is_Square (void) const { return( m_nx > 0 && m_nx == m_ny ); }
522  bool is_Equal (const CSG_Matrix &Matrix) const;
523 
524  bool Assign (double Scalar);
525  bool Assign (const CSG_Matrix &Matrix);
526  bool Add (double Scalar);
527  bool Add (const CSG_Matrix &Matrix);
528  bool Subtract (const CSG_Matrix &Matrix);
529  bool Multiply (double Scalar);
530  CSG_Vector Multiply (const CSG_Vector &Vector) const;
531  CSG_Matrix Multiply (const CSG_Matrix &Matrix) const;
532 
533  bool operator == (const CSG_Matrix &Matrix) const;
534  CSG_Matrix & operator = (double Scalar);
535  CSG_Matrix & operator = (const CSG_Matrix &Matrix);
536  CSG_Matrix & operator += (double Scalar);
537  CSG_Matrix & operator += (const CSG_Matrix &Matrix);
538  CSG_Matrix & operator -= (double Scalar);
539  CSG_Matrix & operator -= (const CSG_Matrix &Matrix);
540  CSG_Matrix & operator *= (double Scalar);
541  CSG_Matrix & operator *= (const CSG_Matrix &Matrix);
542  CSG_Matrix operator + (double Scalar) const;
543  CSG_Matrix operator + (const CSG_Matrix &Matrix) const;
544  CSG_Matrix operator - (double Scalar) const;
545  CSG_Matrix operator - (const CSG_Matrix &Matrix) const;
546  CSG_Matrix operator * (double Scalar) const;
547  CSG_Vector operator * (const CSG_Vector &Vector) const;
548  CSG_Matrix operator * (const CSG_Matrix &Matrix) const;
549 
550  bool Set_Zero (void);
551  bool Set_Identity (void);
552  bool Set_Transpose (void);
553  bool Set_Inverse (bool bSilent = true, int nSubSquare = 0);
554 
555  double Get_Determinant (void) const;
556  CSG_Matrix Get_Transpose (void) const;
557  CSG_Matrix Get_Inverse (bool bSilent = true, int nSubSquare = 0) const;
558 
559 
560 private:
561 
562  sLong m_nx, m_ny;
563 
564  double **m_z;
565 
566 
567  void _On_Construction (void);
568 
569 };
570 
571 //---------------------------------------------------------
572 SAGA_API_DLL_EXPORT CSG_Matrix operator * (double Scalar, const CSG_Matrix &Matrix);
573 
574 //---------------------------------------------------------
575 SAGA_API_DLL_EXPORT CSG_Matrix SG_Matrix_Get_Rotation (double R , bool bDegree = false);
576 SAGA_API_DLL_EXPORT CSG_Matrix SG_Matrix_Get_Rotation (double Rx, double Ry, double Rz, bool bDegree = false);
577 
578 //---------------------------------------------------------
579 SAGA_API_DLL_EXPORT bool SG_Matrix_LU_Decomposition (int n, int *Permutation, double **Matrix , bool bSilent = true, int *nRowChanges = NULL);
580 SAGA_API_DLL_EXPORT bool SG_Matrix_LU_Solve (int n, const int *Permutation, const double **Matrix, double *Vector, bool bSilent = true);
581 
582 SAGA_API_DLL_EXPORT bool SG_Matrix_Solve (CSG_Matrix &Matrix, CSG_Vector &Vector, bool bSilent = true);
583 SAGA_API_DLL_EXPORT bool SG_Matrix_Eigen_Reduction (const CSG_Matrix &Matrix, CSG_Matrix &Eigen_Vectors, CSG_Vector &Eigen_Values, bool bSilent = true);
584 
585 
587 // //
588 // //
589 // //
591 
592 //---------------------------------------------------------
594 {
595 public:
596  CSG_Grid_Radius(int maxRadius = 0);
597  ~CSG_Grid_Radius(void);
598 
599  bool Create (int maxRadius);
600  void Destroy (void);
601 
602  int Get_Maximum (void) { return( m_maxRadius ); }
603 
604  int Get_nPoints (void) { return( m_nPoints ); }
605  int Get_nPoints (int iRadius) { return( iRadius >= 0 && iRadius < m_maxRadius ? m_nPoints_R[iRadius] : 0 ); }
606 
607  double Get_Point (int iPoint, int &x, int &y)
608  {
609  if( iPoint >= 0 && iPoint < m_nPoints )
610  {
611  x = m_Points[iPoint].x;
612  y = m_Points[iPoint].y;
613 
614  return( m_Points[iPoint].d ); // Distance...
615  }
616 
617  return( -1. );
618  }
619 
620  double Get_Point (int iPoint, int xOffset, int yOffset, int &x, int &y)
621  {
622  double d;
623 
624  if( (d = Get_Point(iPoint, x, y)) >= 0. )
625  {
626  x += xOffset;
627  y += yOffset;
628  }
629 
630  return( d );
631  }
632 
633  double Get_Point (int iRadius, int iPoint, int &x, int &y)
634  {
635  if( iRadius >= 0 && iRadius <= m_maxRadius && iPoint >= 0 && iPoint < m_nPoints_R[iRadius] )
636  {
637  x = m_Points_R[iRadius][iPoint].x;
638  y = m_Points_R[iRadius][iPoint].y;
639 
640  return( m_Points_R[iRadius][iPoint].d ); // Distance...
641  }
642 
643  return( -1. );
644  }
645 
646  double Get_Point (int iRadius, int iPoint, int xOffset, int yOffset, int &x, int &y)
647  {
648  double d;
649 
650  if( (d = Get_Point(iRadius, iPoint, x, y)) >= 0. )
651  {
652  x += xOffset;
653  y += yOffset;
654  }
655 
656  return( d );
657  }
658 
659 
660 private:
661 
662  int m_maxRadius, m_nPoints, *m_nPoints_R;
663 
664  typedef struct SSG_Grid_Radius
665  {
666  int x, y;
667 
668  double d;
669  }
670  TSG_Grid_Radius;
671 
672  TSG_Grid_Radius *m_Points, **m_Points_R;
673 
674 };
675 
676 
678 // //
679 // //
680 // //
682 
683 //---------------------------------------------------------
685 {
686 public:
687  CSG_Random(void);
688 
689  static void Initialize (void);
690  static void Initialize (unsigned int Value);
691 
692  static double Get_Uniform (void);
693  static double Get_Uniform (double min, double max);
694 
695  static double Get_Gaussian (double mean, double stddev);
696 
697 };
698 
699 
701 // //
702 // //
703 // //
705 
706 //---------------------------------------------------------
708 {
709 public:
710  CSG_Simple_Statistics(void);
711  CSG_Simple_Statistics(bool bHoldValues);
712  CSG_Simple_Statistics(const CSG_Simple_Statistics &Statistics);
713  CSG_Simple_Statistics(double Mean, double StdDev, sLong Count = 1000);
714  CSG_Simple_Statistics(const CSG_Vector &Values, bool bHoldValues = false);
715 
716  bool Create (bool bHoldValues = false);
717  bool Create (const CSG_Simple_Statistics &Statistics);
718  bool Create (double Mean, double StdDev, sLong Count = 1000);
719  bool Create (const CSG_Vector &Values, bool bHoldValues = false);
720 
721  void Invalidate (void);
722  bool Evaluate (void);
723 
724  int is_Evaluated (void) const { return( m_bEvaluated ); }
725 
726  bool Set_Count (sLong Count);
727 
728  sLong Get_Count (void) const { return( m_nValues ); }
729  double Get_Weights (void) const { return( m_Weights ); }
730 
731  double Get_Minimum (void) { if( m_bEvaluated < 1 ) _Evaluate(1); return( m_Minimum ); }
732  double Get_Maximum (void) { if( m_bEvaluated < 1 ) _Evaluate(1); return( m_Maximum ); }
733  double Get_Range (void) { if( m_bEvaluated < 1 ) _Evaluate(1); return( m_Range ); }
734  double Get_Sum (void) { if( m_bEvaluated < 1 ) _Evaluate(1); return( m_Sum ); }
735  double Get_Sum_Of_Squares (void) { if( m_bEvaluated < 1 ) _Evaluate(1); return( m_Sum2 ); }
736  double Get_Mean (void) { if( m_bEvaluated < 1 ) _Evaluate(1); return( m_Mean ); }
737  double Get_Variance (void) { if( m_bEvaluated < 1 ) _Evaluate(1); return( m_Variance ); }
738  double Get_StdDev (void) { if( m_bEvaluated < 1 ) _Evaluate(1); return( m_StdDev ); }
739 
740  double Get_Kurtosis (void) { if( m_bEvaluated < 2 ) _Evaluate(2); return( m_Kurtosis ); }
741  double Get_Skewness (void) { if( m_bEvaluated < 2 ) _Evaluate(2); return( m_Skewness ); }
742  double Get_SkewnessPearson (void);
743 
744  double Get_Quantile (double Quantile);
745  double Get_Percentile (double Percentile);
746  double Get_Median (void);
747  double Get_Gini (void);
748 
749  sLong Get_IndexOfMinimum (void);
750  sLong Get_IndexOfMaximum (void);
751 
752  sLong Get_nValues_Above (double Threshold, bool bEquals = false);
753  sLong Get_nValues_Below (double Threshold, bool bEquals = false);
754 
755  void Add (const CSG_Simple_Statistics &Statistics);
756 
757  void Add_Value (double Value, double Weight = 1.);
758 
759  double * Get_Values (void) const { return( (double *)m_Values.Get_Array() ); }
760  double Get_Value (sLong i) const { return( i >= 0 && i < (sLong)m_Values.Get_Size() ? Get_Values()[i] : m_Mean ); }
761  double operator [] (sLong i) const { return( i >= 0 && i < (sLong)m_Values.Get_Size() ? Get_Values()[i] : m_Mean ); }
762 
763 
764  CSG_Simple_Statistics & operator = (const CSG_Simple_Statistics &Statistics) { Create(Statistics); return( *this ); }
765  CSG_Simple_Statistics & operator += (const CSG_Simple_Statistics &Statistics) { Add(Statistics); return( *this ); }
766  CSG_Simple_Statistics & operator += (double Value) { Add_Value(Value); return( *this ); }
767 
768 
769 protected:
770 
771  bool m_bSorted;
772 
774 
776 
777  double m_Weights, m_Sum, m_Sum2, m_Minimum, m_Maximum, m_Range, m_Mean, m_Variance, m_StdDev, m_Kurtosis, m_Skewness, m_Gini;
778 
780 
781 
782  void _Evaluate (int Level = 1);
783 
784 };
785 
786 
788 // //
789 // //
790 // //
792 
793 //---------------------------------------------------------
795 {
796 public:
799 
800  virtual void Create (bool bWeights = false) { m_bWeights = bWeights; }
801 
802  int Get_Count (void) const { return( (int)m_Count.Get_Size() ); }
803  int Get_Count (int i) const { return( m_Count[i] ); }
804  double Get_Weight (int i) const { return( m_bWeights ? m_Weight[i] : m_Count[i] ); }
805 
806  virtual int Get_Majority (bool bWeighted = false) const;
807  virtual int Get_Minority (bool bWeighted = false) const;
808 
809 
810 protected:
811 
812  bool m_bWeights{false};
813 
815 
817 
818 };
819 
820 //---------------------------------------------------------
822 {
823 public:
824  CSG_Unique_Number_Statistics (bool bWeights = false) { Create(bWeights); }
826 
827  virtual void Create (bool bWeights = false);
828 
829  void operator += (double Value) { Add_Value(Value); }
830  void Add_Value (double Value, double Weight = 1.);
831  double Get_Value (int Index) const { return( m_Value[Index] ); }
832  int Get_Class_Index (double Value) const;
833  bool Get_Class (int Index, double &Value, int &Count) const
834  {
835  if( Index < 0 || Index >= Get_Count() ) return( false );
836 
837  Count = m_Count[Index];
838  Value = m_Value[Index];
839 
840  return( true );
841  }
842 
843  bool Get_Majority (double &Value ) const { int Count; return( Get_Class(CSG_Unique_Value_Statistics::Get_Majority(), Value, Count) ); }
844  bool Get_Majority (double &Value, int &Count) const { return( Get_Class(CSG_Unique_Value_Statistics::Get_Majority(), Value, Count) && Count > 0 ); }
845  bool Get_Minority (double &Value ) const { int Count; return( Get_Class(CSG_Unique_Value_Statistics::Get_Minority(), Value, Count) ); }
846  bool Get_Minority (double &Value, int &Count) const { return( Get_Class(CSG_Unique_Value_Statistics::Get_Minority(), Value, Count) && Count > 0 ); }
847 
848 
849 private:
850 
851  CSG_Vector m_Value;
852 
853 };
854 
855 //---------------------------------------------------------
857 {
858 public:
859  CSG_Unique_String_Statistics (bool bWeights = false) { Create(bWeights); }
861 
862  virtual void Create (bool bWeights = false);
863 
864  void operator += (const CSG_String &Value) { Add_Value(Value); }
865  void Add_Value (const CSG_String &Value, double Weight = 1.);
866  const SG_Char * Get_Value (int Index) const { return( m_Value[Index] ); }
867  int Get_Class_Index (const CSG_String &Value) const;
868  bool Get_Class (int Index, CSG_String &Value, int &Count) const
869  {
870  if( Index < 0 || Index >= Get_Count() ) return( false );
871 
872  Count = m_Count[Index];
873  Value = m_Value[Index];
874 
875  return( true );
876  }
877 
878  bool Get_Majority (CSG_String &Value ) const { int Count; return( Get_Class(CSG_Unique_Value_Statistics::Get_Majority(), Value, Count) ); }
879  bool Get_Majority (CSG_String &Value, int &Count) const { return( Get_Class(CSG_Unique_Value_Statistics::Get_Majority(), Value, Count) && Count > 0 ); }
880  bool Get_Minority (CSG_String &Value ) const { int Count; return( Get_Class(CSG_Unique_Value_Statistics::Get_Minority(), Value, Count) ); }
881  bool Get_Minority (CSG_String &Value, int &Count) const { return( Get_Class(CSG_Unique_Value_Statistics::Get_Minority(), Value, Count) && Count > 0 ); }
882 
883 
884 private:
885 
886  CSG_Strings m_Value;
887 
888 };
889 
890 
892 // //
893 // //
894 // //
896 
897 //---------------------------------------------------------
899 {
900 public:
902  virtual ~CSG_Category_Statistics (void);
903 
904  void Create (TSG_Data_Type Type = SG_DATATYPE_String);
905  void Destroy (void);
906 
907  TSG_Data_Type Get_Category_Type (void) const;
908 
909  int Add_Value (int Value);
910  int Add_Value (double Value);
911  int Add_Value (const CSG_String &Value);
912 
913  void operator += (int Value) { Add_Value(Value); }
914  void operator += (double Value) { Add_Value(Value); }
915  void operator += (const CSG_String &Value) { Add_Value(Value); }
916 
917  bool Sort (void);
918 
919  int Get_Count (void ) const;
920  int Get_Count (int iCategory) const;
921 
922  int asInt (int iCategory) const;
923  double asDouble (int iCategory) const;
924  CSG_String asString (int iCategory) const;
925 
926  int Get_Category (int Value) const;
927  int Get_Category (double Value) const;
928  int Get_Category (const CSG_String &Value) const;
929 
930  bool Get_Category (int iCategory, int &Value, int &Count) const
931  {
932  Count = Get_Count(iCategory);
933  Value = asInt (iCategory);
934 
935  return( iCategory >= 0 && iCategory < Get_Count() );
936  }
937 
938  bool Get_Category (int iCategory, double &Value, int &Count) const
939  {
940  Count = Get_Count(iCategory);
941  Value = asDouble (iCategory);
942 
943  return( iCategory >= 0 && iCategory < Get_Count() );
944  }
945 
946  bool Get_Category (int iCategory, CSG_String &Value, int &Count) const
947  {
948  Count = Get_Count(iCategory);
949  Value = asString (iCategory);
950 
951  return( iCategory >= 0 && iCategory < Get_Count() );
952  }
953 
954  int Get_Majority (void);
955  bool Get_Majority (int &Value ) { int Count; return( Get_Category(Get_Majority(), Value, Count) ); }
956  bool Get_Majority (double &Value ) { int Count; return( Get_Category(Get_Majority(), Value, Count) ); }
957  bool Get_Majority (CSG_String &Value ) { int Count; return( Get_Category(Get_Majority(), Value, Count) ); }
958  bool Get_Majority (int &Value, int &Count) { return( Get_Category(Get_Majority(), Value, Count) && Count > 0 ); }
959  bool Get_Majority (double &Value, int &Count) { return( Get_Category(Get_Majority(), Value, Count) && Count > 0 ); }
960  bool Get_Majority (CSG_String &Value, int &Count) { return( Get_Category(Get_Majority(), Value, Count) && Count > 0 ); }
961 
962  int Get_Minority (void);
963  bool Get_Minority (int &Value ) { int Count; return( Get_Category(Get_Minority(), Value, Count) ); }
964  bool Get_Minority (double &Value ) { int Count; return( Get_Category(Get_Minority(), Value, Count) ); }
965  bool Get_Minority (CSG_String &Value ) { int Count; return( Get_Category(Get_Minority(), Value, Count) ); }
966  bool Get_Minority (int &Value, int &Count) { return( Get_Category(Get_Minority(), Value, Count) && Count > 0 ); }
967  bool Get_Minority (double &Value, int &Count) { return( Get_Category(Get_Minority(), Value, Count) && Count > 0 ); }
968  bool Get_Minority (CSG_String &Value, int &Count) { return( Get_Category(Get_Minority(), Value, Count) && Count > 0 ); }
969 
970 
971 private:
972 
973  class CSG_Table *m_pTable;
974 
975 };
976 
977 
979 // //
980 // //
981 // //
983 
984 //---------------------------------------------------------
986 {
987 public:
988  CSG_Histogram(void);
989  virtual ~CSG_Histogram(void);
990 
991  bool Destroy (void);
992 
993  CSG_Histogram (const CSG_Histogram &Histogram);
994  bool Create (const CSG_Histogram &Histogram);
995 
996  CSG_Histogram (size_t nClasses, double Minimum, double Maximum);
997  bool Create (size_t nClasses, double Minimum, double Maximum);
998 
999  CSG_Histogram (size_t nClasses, double Minimum, double Maximum, const CSG_Vector &Values , size_t maxSamples = 0);
1000  bool Create (size_t nClasses, double Minimum, double Maximum, const CSG_Vector &Values , size_t maxSamples = 0);
1001 
1002  CSG_Histogram (size_t nClasses, double Minimum, double Maximum, class CSG_Table *pTable, int Field, size_t maxSamples = 0);
1003  bool Create (size_t nClasses, double Minimum, double Maximum, class CSG_Table *pTable, int Field, size_t maxSamples = 0);
1004 
1005  CSG_Histogram (size_t nClasses, double Minimum, double Maximum, class CSG_Grid *pGrid , size_t maxSamples = 0);
1006  bool Create (size_t nClasses, double Minimum, double Maximum, class CSG_Grid *pGrid , size_t maxSamples = 0);
1007 
1008  CSG_Histogram (size_t nClasses, double Minimum, double Maximum, class CSG_Grids *pGrids , size_t maxSamples = 0);
1009  bool Create (size_t nClasses, double Minimum, double Maximum, class CSG_Grids *pGrids , size_t maxSamples = 0);
1010 
1011  //-----------------------------------------------------
1012  void Add_Value (double Value);
1013 
1014  bool Scale_Element_Count (double Scale);
1015 
1016  bool Update (void);
1017 
1018  size_t Get_Class_Count (void) const { return( m_nClasses ); }
1019 
1020  size_t Get_Element_Count (void) const { return( m_nClasses > 0 ? m_Cumulative[m_nClasses - 1] : 0 ); }
1021  size_t Get_Element_Maximum (void) const { return( m_nMaximum ); }
1022 
1023  size_t Get_Elements (int i) const { return( Get_Elements((size_t)i) ); }
1024  size_t Get_Elements (size_t i) const { return( i < m_nClasses ? m_Elements[i] : 0 ); }
1025 
1026  size_t Get_Cumulative (int i) const { return( Get_Cumulative((size_t)i) ); }
1027  size_t Get_Cumulative (size_t i) const { return( i < m_nClasses ? m_Cumulative[i] : 0 ); }
1028 
1029  double Get_Value (double i) const { return( m_nClasses < 1 ? m_Minimum : m_Minimum + i * m_ClassWidth ); }
1030 
1031  double Get_Break (int i) const { return( Get_Value((double)(i)) ); }
1032  double Get_Break (size_t i) const { return( Get_Value((double)(i)) ); }
1033 
1034  double Get_Center (int i) const { return( Get_Value((double)(i + 0.5)) ); }
1035  double Get_Center (size_t i) const { return( Get_Value((double)(i + 0.5)) ); }
1036 
1037  //-----------------------------------------------------
1038  CSG_Histogram & operator = (const CSG_Histogram &Histogram);
1039 
1040  void operator += (double Value) { Add_Value(Value); }
1041 
1042  size_t operator [] (int i) const { return( Get_Elements(i) ); }
1043  size_t operator [] (size_t i) const { return( Get_Elements(i) ); }
1044 
1045  double Get_Quantile (double Quantile) const;
1046  double Get_Quantile_Value (double Value) const;
1047 
1048  double Get_Percentile (double Percentile) const;
1049  double Get_Percentile_Value(double Value) const;
1050 
1051  const CSG_Simple_Statistics & Get_Statistics (void) const { return( m_Statistics ); }
1052 
1053 
1054 private:
1055 
1056  size_t m_nClasses, m_nMaximum, *m_Elements, *m_Cumulative;
1057 
1058  double m_Minimum, m_Maximum, m_ClassWidth;
1059 
1060  CSG_Simple_Statistics m_Statistics;
1061 
1062 
1063  void _On_Construction (void);
1064 
1065  bool _Create (size_t nClasses, double Minimum, double Maximum);
1066 
1067  bool _Update (sLong nElements);
1068 
1069 };
1070 
1071 
1073 // //
1074 // //
1075 // //
1077 
1078 //---------------------------------------------------------
1080 {
1081 public:
1082  CSG_Natural_Breaks(void);
1083  virtual ~CSG_Natural_Breaks(void);
1084 
1085  CSG_Natural_Breaks (class CSG_Table *pTable, int Field, int nClasses, int Histogram = 0);
1086  bool Create (class CSG_Table *pTable, int Field, int nClasses, int Histogram = 0);
1087 
1088  CSG_Natural_Breaks (class CSG_Grid *pGrid , int nClasses, int Histogram = 0);
1089  bool Create (class CSG_Grid *pGrid , int nClasses, int Histogram = 0);
1090 
1091  CSG_Natural_Breaks (class CSG_Grids *pGrids , int nClasses, int Histogram = 0);
1092  bool Create (class CSG_Grids *pGrids , int nClasses, int Histogram = 0);
1093 
1094  CSG_Natural_Breaks (const CSG_Vector &Values , int nClasses, int Histogram = 0);
1095  bool Create (const CSG_Vector &Values , int nClasses, int Histogram = 0);
1096 
1097  int Get_Count (void) const { return( m_Breaks.Get_N() ); }
1098  double Get_Break (int i) const { return( m_Breaks[i] ); }
1099 
1100  double operator [] (int i) const { return( m_Breaks[i] ); }
1101 
1102 
1103 private:
1104 
1105  CSG_Histogram m_Histogram;
1106 
1107  CSG_Vector m_Breaks, m_Values;
1108 
1109 
1110  bool _Histogram (int nClasses);
1111 
1112  double _Get_Value (int i);
1113 
1114  bool _Calculate (int nClasses);
1115 
1116 };
1117 
1118 
1120 // //
1121 // //
1122 // //
1124 
1125 //---------------------------------------------------------
1127 {
1131 };
1132 
1133 //---------------------------------------------------------
1135 {
1136 public:
1137  CSG_Cluster_Analysis(void);
1138  virtual ~CSG_Cluster_Analysis(void);
1139 
1140  bool Create (int nFeatures);
1141  bool Destroy (void);
1142 
1143  bool Add_Element (void);
1144  bool Set_Feature (sLong iElement, int iFeature, double Value);
1145 
1146  sLong Get_Cluster (sLong iElement) const { return( iElement >= 0 && iElement < Get_nElements() ? m_Clusters[iElement] : -1 ); }
1147 
1148  bool Execute (int Method, int nClusters, int nMaxIterations = 0, int Initialization = 0);
1149 
1150  sLong Get_nElements (void) const { return( m_Features.Get_Size() ); }
1151  int Get_nFeatures (void) const { return( m_nFeatures ); }
1152  int Get_nClusters (void) const { return( (int)m_nMembers.Get_Size() ); }
1153 
1154  int Get_Iteration (void) const { return( m_Iteration ); }
1155 
1156  double Get_SP (void) const { return( m_SP ); }
1157 
1158  int Get_nMembers (int iCluster) const { return( m_nMembers[iCluster] ); }
1159  double Get_Variance (int iCluster) const { return( m_Variance[iCluster] ); }
1160  double Get_Centroid (int iCluster, int iFeature) const { return( m_Centroid[iCluster][iFeature] ); }
1161 
1162 
1163 private:
1164 
1165  int m_Iteration, m_nFeatures;
1166 
1167  double m_SP;
1168 
1169  CSG_Array_Int m_Clusters, m_nMembers;
1170 
1171  CSG_Array m_Features;
1172 
1173  CSG_Vector m_Variance;
1174 
1175  CSG_Matrix m_Centroid;
1176 
1177 
1178  bool _Minimum_Distance (bool bInitialize, int nMaxIterations);
1179 
1180  bool _Hill_Climbing (bool bInitialize, int nMaxIterations);
1181 
1182 };
1183 
1184 
1186 // //
1187 // //
1188 // //
1190 
1191 //---------------------------------------------------------
1193 {
1203 };
1204 
1205 //---------------------------------------------------------
1207 {
1208 public:
1210  virtual ~CSG_Classifier_Supervised(void);
1211 
1212  void Create (int nFeatures);
1213  void Destroy (void);
1214 
1215  bool Load (const CSG_String &File);
1216  bool Save (const CSG_String &File, const SG_Char *Feature_Info = NULL);
1217 
1218  bool Train_Clr_Samples (void);
1219  bool Train_Add_Sample (const CSG_String &Class_ID, const CSG_Vector &Features);
1220  bool Train (bool bClr_Samples = false);
1221 
1222  bool Add_Class (const CSG_String &Class_ID, const CSG_Vector &Mean, const CSG_Vector &Min, const CSG_Vector &Max, const CSG_Matrix &Cov);
1223 
1224  CSG_String Print (void);
1225 
1226  //-----------------------------------------------------
1227  int Get_Feature_Count (void) { return( m_nFeatures ); }
1228 
1229  int Get_Class_Count (void) { return( m_nClasses ); }
1230 
1231  const CSG_String & Get_Class_ID (int iClass) { return( m_pClasses[iClass]->m_ID ); }
1232  double Get_Class_Mean (int iClass, int iFeature) { return( m_pClasses[iClass]->m_Mean[iFeature] ); }
1233  double Get_Class_Minimum (int iClass, int iFeature) { return( m_pClasses[iClass]->m_Min [iFeature] ); }
1234  double Get_Class_Maximum (int iClass, int iFeature) { return( m_pClasses[iClass]->m_Max [iFeature] ); }
1235 
1236  int Get_Class (const CSG_String &Class_ID);
1237  bool Get_Class (const CSG_Vector &Features, int &Class, double &Quality, int Method);
1238 
1239  //-----------------------------------------------------
1240  void Set_Threshold_Distance (double Value);
1241  double Get_Threshold_Distance (void);
1242 
1243  void Set_Threshold_Angle (double Value);
1244  double Get_Threshold_Angle (void);
1245 
1246  void Set_Threshold_Probability (double Value);
1247  double Get_Threshold_Probability (void);
1248 
1249  void Set_Probability_Relative (bool Value);
1250  bool Get_Probability_Relative (void);
1251 
1252  void Set_WTA (int Method, bool bOn);
1253  bool Get_WTA (int Method);
1254 
1255  static CSG_String Get_Name_of_Method (int Method);
1256  static CSG_String Get_Name_of_Quality (int Method);
1257 
1258 
1259 private:
1260 
1261  //-----------------------------------------------------
1262  class CClass
1263  {
1264  public:
1265  CClass(const CSG_String &ID) : m_ID(ID) {}
1266 
1267  CSG_String m_ID;
1268 
1269  double m_Cov_Det, m_Mean_Spectral;
1270 
1271  CSG_Vector m_Mean, m_Min, m_Max;
1272 
1273  CSG_Matrix m_Cov, m_Cov_Inv, m_Samples;
1274 
1275 
1276  bool Train (void);
1277 
1278  };
1279 
1280  //-----------------------------------------------------
1281  bool m_Probability_Relative, m_bWTA[SG_CLASSIFY_SUPERVISED_WTA];
1282 
1283  int m_nFeatures, m_nClasses;
1284 
1285  double m_Threshold_Distance, m_Threshold_Probability, m_Threshold_Angle;
1286 
1287  CSG_String m_Info;
1288 
1289  CClass **m_pClasses;
1290 
1291 
1292  void _Get_Binary_Encoding (const CSG_Vector &Features, int &Class, double &Quality);
1293  void _Get_Parallel_Epiped (const CSG_Vector &Features, int &Class, double &Quality);
1294  void _Get_Minimum_Distance (const CSG_Vector &Features, int &Class, double &Quality);
1295  void _Get_Mahalanobis_Distance (const CSG_Vector &Features, int &Class, double &Quality);
1296  void _Get_Maximum_Likelihood (const CSG_Vector &Features, int &Class, double &Quality);
1297  void _Get_Spectral_Angle_Mapping (const CSG_Vector &Features, int &Class, double &Quality);
1298  void _Get_Spectral_Divergence (const CSG_Vector &Features, int &Class, double &Quality);
1299  void _Get_Winner_Takes_All (const CSG_Vector &Features, int &Class, double &Quality);
1300 
1301 };
1302 
1303 
1305 // //
1306 // //
1307 // //
1309 
1310 //---------------------------------------------------------
1311 #ifdef WITH_MRMR
1312 
1313 //---------------------------------------------------------
1314 enum ESG_mRMR_Method
1315 {
1316  SG_mRMR_Method_MID = 0, // Mutual Information Difference (MID)
1317  SG_mRMR_Method_MIQ // Mutual Information Quotient (MIQ)
1318 };
1319 
1320 //---------------------------------------------------------
1321 class SAGA_API_DLL_EXPORT CSG_mRMR
1322 {
1323 public:
1324 
1325  CSG_mRMR(void);
1326  virtual ~CSG_mRMR(void);
1327 
1328  void Destroy (void);
1329 
1330  static CSG_String Get_Description (void);
1331 
1332  static bool Parameters_Add (class CSG_Parameters *pParameters, class CSG_Parameter *pNode = NULL);
1333  static int Parameters_Enable (class CSG_Parameters *pParameters, class CSG_Parameter *pParameter);
1334 
1335  void Set_Verbose (bool bOn = true) { m_bVerbose = bOn; }
1336 
1337  bool Set_Data (CSG_Table &Data, int ClassField, class CSG_Parameters *pParameters);
1338  bool Set_Data (CSG_Matrix &Data, int ClassField, class CSG_Parameters *pParameters);
1339  bool Set_Data (CSG_Table &Data, int ClassField = 0, double Threshold = -1.);
1340  bool Set_Data (CSG_Matrix &Data, int ClassField = 0, double Threshold = -1.);
1341 
1342  bool Get_Selection (class CSG_Parameters *pParameters);
1343  bool Get_Selection (int nFeatures, int Method);
1344 
1345  int Get_Count (void) const;
1346  int Get_Index (int i) const;
1347  CSG_String Get_Name (int i) const;
1348  double Get_Score (int i) const;
1349 
1350 
1351 private:
1352 
1353  bool m_bDiscretized, m_bVerbose;
1354 
1355  long m_nSamples, m_nVars;
1356 
1357  double **m_Samples;
1358 
1359  CSG_Strings m_VarNames;
1360 
1361  class CSG_Table *m_pSelection;
1362 
1363 
1364  bool Get_Memory (int nVars, int nSamples);
1365 
1366  bool Discretize (double Threshold);
1367 
1368  double Get_MutualInfo (long v1, long v2);
1369  double Get_MutualInfo (double *pab, long pabhei, long pabwid);
1370 
1371  template <class T> double * Get_JointProb (T *img1, T *img2, long len, long maxstatenum, int &nstate1, int &nstate2);
1372  template <class T> void Copy_Vector (T *srcdata, long len, int *desdata, int &nstate);
1373 
1374 
1375  typedef struct SPool
1376  {
1377  char Mask;
1378  long Index;
1379  double mival;
1380  }
1381  TPool;
1382 
1383  static int Pool_Compare (const void *a, const void *b);
1384 
1385 };
1386 
1387 //---------------------------------------------------------
1388 #endif // WITH_MRMR
1389 
1390 
1392 // //
1393 // //
1394 // //
1396 
1397 //---------------------------------------------------------
1399 {
1400 public:
1401  CSG_Spline(void);
1402  virtual ~CSG_Spline(void);
1403 
1404  void Destroy (void);
1405 
1406  bool Create (double *xValues, double *yValues, int nValues, double yA = 1.0e30, double yB = 1.0e30);
1407  bool Create (double yA = 1.0e30, double yB = 1.0e30);
1408 
1409  void Add (double x, double y);
1410 
1411  int Get_Count (void) const { return( m_x.Get_N() ); }
1412  double Get_xMin (void) const { return( m_x.Get_N() > 0 ? m_x(0 ) : 0. ); }
1413  double Get_xMax (void) const { return( m_x.Get_N() > 0 ? m_x(m_x.Get_Size() - 1) : 0. ); }
1414  double Get_x (int i) const { return( i >= 0 && i < m_x.Get_N() ? m_x(i) : 0. ); }
1415  double Get_y (int i) const { return( i >= 0 && i < m_y.Get_N() ? m_y(i) : 0. ); }
1416 
1417  bool Get_Value (double x, double &y);
1418  double Get_Value (double x);
1419 
1420 
1421 protected:
1422 
1424 
1425  CSG_Vector m_x, m_y, m_z;
1426 
1427 
1428  bool _Create (double yA, double yB);
1429 
1430 };
1431 
1432 //---------------------------------------------------------
1434 {
1435 public:
1436  CSG_Thin_Plate_Spline(void);
1437  virtual ~CSG_Thin_Plate_Spline(void);
1438 
1439  bool Destroy (void);
1440 
1441  bool Set_Point_Count (int Count) { return( m_Points.Set_Count(Count) ); }
1442  int Get_Point_Count (void) { return( (int)m_Points.Get_Count() ); }
1443 
1444  CSG_Points_3D & Get_Points (void) { return( m_Points ); }
1445 
1446  bool Add_Point (double x, double y, double z) { return( m_Points.Add( x, y, z) ); }
1447  bool Add_Point (const TSG_Point &p, double z) { return( m_Points.Add(p.x, p.y, z) ); }
1448 
1449  bool Set_Point (int Index, double x, double y, double z)
1450  {
1451  if( Index >= 0 && Index < m_Points.Get_Count() )
1452  {
1453  m_Points[Index].x = x;
1454  m_Points[Index].y = y;
1455  m_Points[Index].z = z;
1456 
1457  return( true );
1458  }
1459 
1460  return( false );
1461  }
1462 
1463  bool Set_Point (int Index, const TSG_Point &p, double z) { return( Set_Point(Index, p.x, p.y, z) ); }
1464 
1465  bool Create (double Regularization = 0., bool bSilent = true);
1466 
1467  bool is_Okay (void) { return( m_V.Get_N() > 0 ); }
1468 
1469  double Get_Value (double x, double y);
1470 
1471 
1472 private:
1473 
1474  CSG_Points_3D m_Points;
1475 
1476  CSG_Vector m_V;
1477 
1478 
1479  double _Get_hDistance (TSG_Point_3D A, TSG_Point_3D B);
1480  double _Get_Base_Funtion (double x);
1481  double _Get_Base_Funtion (TSG_Point_3D A, double x, double y);
1482 
1483 };
1484 
1485 
1487 // //
1488 // //
1489 // //
1491 
1492 //---------------------------------------------------------
1493 typedef enum
1494 {
1501 
1502 //---------------------------------------------------------
1504 {
1505 public:
1506 
1507  static double Get_F_Tail_from_R2 (double R2, int nPredictors, int nSamples, TSG_Test_Distribution_Type Type = TESTDIST_TYPE_Right);
1508 
1509  static double Get_F_Tail (double F , int dfn, int dfd, TSG_Test_Distribution_Type Type = TESTDIST_TYPE_Right);
1510  static double Get_F_Inverse (double alpha, int dfn, int dfd, TSG_Test_Distribution_Type Type = TESTDIST_TYPE_Right);
1511 
1512  static double Get_T_Tail (double T , int df, TSG_Test_Distribution_Type Type = TESTDIST_TYPE_Right);
1513  static double Get_T_Inverse (double alpha, int df, TSG_Test_Distribution_Type Type = TESTDIST_TYPE_Right);
1514 
1515  static double Get_Norm_P (double Z);
1516  static double Get_Norm_Z (double P);
1517 
1518 
1519 private:
1520 
1521  static double Get_Gamma (double F, double dfn, double dfd);
1522  static double Get_Log_Gamma (double a);
1523 
1524  static double Get_T_P (double T, int df);
1525  static double Get_T_Z (double T, int df);
1526  static double Get_T_Inv (double p, int df);
1527 
1528  static double _Change_Tail_Type (double p, TSG_Test_Distribution_Type from, TSG_Test_Distribution_Type to, bool bNegative);
1529 
1530 };
1531 
1532 
1534 // //
1535 // //
1536 // //
1538 
1539 //---------------------------------------------------------
1540 // Values: (matrix) array with number of variables = number of rows (x), number of samples = number of columns (y)
1541 SAGA_API_DLL_EXPORT CSG_Matrix SG_Get_Correlation_Matrix (const CSG_Matrix &Values, bool bCovariances = false);
1542 
1543 
1545 // //
1546 // //
1547 // //
1549 
1550 //---------------------------------------------------------
1551 typedef enum
1552 {
1562 
1563 //---------------------------------------------------------
1564 SAGA_API_DLL_EXPORT double SG_Regression_Get_Adjusted_R2 (double R2, int nSamples, int nPredictors, TSG_Regression_Correction Correction = REGRESSION_CORR_Wherry_1);
1565 
1566 
1568 // //
1570 
1571 //---------------------------------------------------------
1572 typedef enum
1573 {
1574  REGRESSION_Linear = 0, // Y = a + b * X
1575  REGRESSION_Rez_X, // Y = a + b / X
1576  REGRESSION_Rez_Y, // Y = a / (b - X)
1577  REGRESSION_Pow, // Y = a * X^b
1578  REGRESSION_Exp, // Y = a * e^(b * X)
1579  REGRESSION_Log // Y = a + b * ln(X)
1582 
1583 //---------------------------------------------------------
1585 {
1586 public:
1587  CSG_Regression(void);
1588  virtual ~CSG_Regression(void);
1589 
1590  void Destroy (void);
1591 
1592  bool Set_Values (int nValues, double *x, double *y);
1593  bool Add_Values (double x, double y);
1594 
1595  int Get_Count (void) const { return( (int)m_x.Get_Size() ); }
1596 
1597  double Get_xValue (int i) const { return( i >= 0 && i < Get_Count() ? m_x[i] : 0. ); }
1598  double Get_yValue (int i) const { return( i >= 0 && i < Get_Count() ? m_y[i] : 0. ); }
1599  bool Get_Values (int i, double &x, double &y) const
1600  {
1601  if( i >= 0 && i < Get_Count() )
1602  {
1603  x = m_x[i];
1604  y = m_y[i];
1605 
1606  return( true );
1607  }
1608 
1609  return( false );
1610  }
1611 
1612  double Get_xMin (void) const { return( m_xMin ); }
1613  double Get_xMax (void) const { return( m_xMax ); }
1614  double Get_xMean (void) const { return( m_xMean ); }
1615  double Get_xVariance (void) const { return( m_xVar ); }
1616  double Get_x (double y) const; // returns INF on error, this can be checked using the _finite() function (libc, include <float.h>)...
1617 
1618  double Get_yMin (void) const { return( m_yMin ); }
1619  double Get_yMax (void) const { return( m_yMax ); }
1620  double Get_yMean (void) const { return( m_yMean ); }
1621  double Get_yVariance (void) const { return( m_yVar ); }
1622  double Get_y (double x) const; // returns INF on error, this can be checked using the _finite() function (libc, include <float.h>)...
1623 
1624  double Get_Constant (void) const { return( m_RConst ); }
1625  double Get_Coefficient (void) const { return( m_RCoeff ); }
1626  double Get_R (void) const { return( m_R ); }
1627  double Get_R2 (void) const { return( m_R2 ); }
1628  double Get_R2_Adj (void) const { return( m_R2_Adj ); }
1629  double Get_P (void) const { return( m_P ); }
1630  double Get_StdError (void) const { return( m_SE ); }
1631 
1632  const SG_Char * asString (void);
1633 
1634  TSG_Regression_Type Get_Type (void) const { return( m_Type ); }
1635 
1636  bool Calculate ( TSG_Regression_Type Type = REGRESSION_Linear, bool bStdError = false);
1637  bool Calculate (int nValues, double *x, double *y, TSG_Regression_Type Type = REGRESSION_Linear, bool bStdError = false);
1638 
1639 
1640 protected:
1641 
1642  double m_RConst, m_RCoeff, m_R, m_R2, m_R2_Adj, m_P, m_SE,
1643  m_xMin, m_xMax, m_xMean, m_xVar,
1644  m_yMin, m_yMax, m_yMean, m_yVar;
1645 
1647 
1649 
1650 
1651  double _Y_Transform (double x);
1652  double _X_Transform (double y);
1653 
1654 };
1655 
1656 
1658 // //
1660 
1661 //---------------------------------------------------------
1663 {
1673  MLR_VAR_P
1674 };
1675 
1676 //---------------------------------------------------------
1678 {
1679 public:
1680  CSG_Regression_Multiple(bool bIntercept = true);
1681  virtual ~CSG_Regression_Multiple(void);
1682 
1683  void Destroy (void);
1684 
1685  bool Set_Data (const CSG_Matrix &Samples, CSG_Strings *pNames = NULL);
1686 
1687  void Set_With_Intercept (bool bOn = true) { m_bIntercept = bOn; }
1688  bool Get_With_Intercept (void) const { return( m_bIntercept ); }
1689 
1690  bool Get_Model (const CSG_Matrix &Samples , CSG_Strings *pNames = NULL);
1691  bool Get_Model_Forward (const CSG_Matrix &Samples, double P_in , CSG_Strings *pNames = NULL);
1692  bool Get_Model_Backward (const CSG_Matrix &Samples, double P_out , CSG_Strings *pNames = NULL);
1693  bool Get_Model_Stepwise (const CSG_Matrix &Samples, double P_in, double P_out, CSG_Strings *pNames = NULL);
1694 
1695  bool Get_Model (void);
1696  bool Get_Model_Forward (double P_in);
1697  bool Get_Model_Backward (double P_out);
1698  bool Get_Model_Stepwise (double P_in, double P_out);
1699 
1700  bool Get_CrossValidation (int nSubSamples = 0);
1701 
1702  CSG_String Get_Info (void) const;
1703  class CSG_Table * Get_Info_Regression (void) const { return( m_pRegression ); }
1704  class CSG_Table * Get_Info_Model (void) const { return( m_pModel ); }
1705  class CSG_Table * Get_Info_Steps (void) const { return( m_pSteps ); }
1706 
1707  double Get_R2 (void) const;
1708  double Get_R2_Adj (void) const;
1709  double Get_StdError (void) const;
1710  double Get_F (void) const;
1711  double Get_P (void) const;
1712  double Get_CV_RMSE (void) const;
1713  double Get_CV_NRMSE (void) const;
1714  double Get_CV_R2 (void) const;
1715  int Get_CV_nSamples (void) const;
1716  int Get_DegFreedom (void) const;
1717  int Get_nSamples (void) const;
1718  int Get_nPredictors (void) const;
1719  int Get_Predictor (int i) const { return( i >= 0 && i < Get_nPredictors() ? m_Predictor[i] : -1 ); }
1720 
1721  double Get_RConst (void) const;
1722  const SG_Char * Get_Name (int iVariable) const;
1723  double Get_ID (int iVariable) const { return( Get_Parameter(iVariable, MLR_VAR_ID ) ); }
1724  double Get_RCoeff (int iVariable) const { return( Get_Parameter(iVariable, MLR_VAR_RCOEFF) ); }
1725  double Get_R2_Partial (int iVariable) const { return( Get_Parameter(iVariable, MLR_VAR_R2 ) ); }
1726  double Get_R2_Partial_Adj (int iVariable) const { return( Get_Parameter(iVariable, MLR_VAR_R2_ADJ) ); }
1727  double Get_StdError (int iVariable) const { return( Get_Parameter(iVariable, MLR_VAR_SE ) ); }
1728  double Get_T (int iVariable) const { return( Get_Parameter(iVariable, MLR_VAR_T ) ); }
1729  double Get_P (int iVariable) const { return( Get_Parameter(iVariable, MLR_VAR_SIG ) ); }
1730 
1731  double Get_Parameter (int iVariable, int Parameter) const;
1732 
1733  double Get_Value (const CSG_Vector &Predictors) const;
1734  bool Get_Value (const CSG_Vector &Predictors, double &Value) const;
1735 
1736  double Get_Residual (int iSample) const;
1737  bool Get_Residual (int iSample, double &Residual) const;
1738 
1739  bool Get_Residuals (CSG_Vector &Residuals) const;
1740 
1741 
1742 protected:
1743 
1745 
1746  int *m_bIncluded, *m_Predictor, m_nPredictors;
1747 
1749 
1751 
1752  class CSG_Table *m_pRegression, *m_pModel, *m_pSteps;
1753 
1754 
1755  bool _Initialize (bool bInclude);
1756 
1757  double _Get_F (int nPredictors, int nSamples, double r2_full, double r2_reduced);
1758  double _Get_P (int nPredictors, int nSamples, double r2_full, double r2_reduced);
1759 
1760  bool _Get_Regression (const class CSG_Matrix &Samples);
1761 
1762  int _Get_Step_In (CSG_Matrix &X, double P_in , double &R2, const CSG_Matrix &Samples);
1763  int _Get_Step_Out (CSG_Matrix &X, double P_out, double &R2);
1764 
1765  bool _Set_Step_Info (const CSG_Matrix &X);
1766  bool _Set_Step_Info (const CSG_Matrix &X, double R2_prev, int iVariable, bool bIn);
1767 
1768 };
1769 
1770 
1772 // //
1774 
1775 //---------------------------------------------------------
1777 {
1778 public:
1780  virtual ~CSG_Regression_Weighted(void);
1781 
1782  bool Destroy (void);
1783 
1784  bool Add_Sample (double Weight, double Dependent, const CSG_Vector &Predictors);
1785  int Get_Sample_Count (void) const { return( m_X.Get_NY() ); }
1786  int Get_Predictor_Count (void) const { return( m_X.Get_NX() - 1 ); }
1787 
1788  bool Calculate (const CSG_Vector &Weights, const CSG_Vector &Dependents, const CSG_Matrix &Predictors, bool bLogistic = false);
1789  bool Calculate (bool bLogistic = false);
1790 
1791  double Get_R2 (void) const { return( m_r2 ); }
1792  const CSG_Vector & Get_RCoeff (void) const { return( m_b ); }
1793  double Get_RCoeff (int i) const { return( m_b[i] ); }
1794  double operator [] (int i) const { return( m_b[i] ); }
1795 
1796  //-----------------------------------------------------
1797  int Get_Log_maxIter (void) const { return( m_Log_maxIter ); }
1798  double Get_Log_Epsilon (void) const { return( m_Log_Epsilon ); }
1799  double Get_Log_Difference (void) const { return( m_Log_Difference ); }
1800 
1801  bool Set_Log_maxIter (int maxIter );
1802  bool Set_Log_Epsilon (double Epsilon );
1803  bool Set_Log_Difference (double Difference);
1804 
1805  //-----------------------------------------------------
1806  bool Get_CrossValidation (int nSubSamples = 0);
1807 
1808  int Get_CV_nSamples (void) const { return( m_CV_nSamples ); }
1809  double Get_CV_RMSE (void) const { return( m_CV_RMSE ); }
1810  double Get_CV_NRMSE (void) const { return( m_CV_NRMSE ); }
1811  double Get_CV_R2 (void) const { return( m_CV_R2 ); }
1812 
1813 
1814 private:
1815 
1816  int m_Log_maxIter, m_CV_nSamples;
1817 
1818  double m_r2, m_Log_Epsilon, m_Log_Difference, m_CV_RMSE, m_CV_NRMSE, m_CV_R2;
1819 
1820  CSG_Vector m_y, m_w, m_b;
1821 
1822  CSG_Matrix m_X;
1823 
1824 
1825  CSG_Vector _Log_Get_Beta (const CSG_Matrix &X, const CSG_Vector &y, const CSG_Vector &w);
1826  CSG_Vector _Log_Get_Beta (const CSG_Vector &b, const CSG_Matrix &X, const CSG_Vector &y, const CSG_Vector &w, const CSG_Vector &p);
1827  CSG_Matrix _Log_Get_Xwp (const CSG_Vector &p, const CSG_Matrix &X, const CSG_Vector &w);
1828  CSG_Vector _Log_Get_Ywp (const CSG_Vector &p, const CSG_Vector &y, const CSG_Vector &w);
1829  CSG_Vector _Log_Get_Props (const CSG_Matrix &X, const CSG_Vector &b);
1830  bool _Log_NoChange (const CSG_Vector &b_old, const CSG_Vector &b_new);
1831  bool _Log_OutOfControl (const CSG_Vector &b_old, const CSG_Vector &b_new);
1832 
1833 };
1834 
1835 
1837 // //
1838 // Formula Parser (A. Ringeler) //
1839 // //
1841 
1842 //---------------------------------------------------------
1843 typedef double (*TSG_Formula_Function_0)(void);
1844 typedef double (*TSG_Formula_Function_1)(double);
1845 typedef double (*TSG_Formula_Function_2)(double, double);
1846 typedef double (*TSG_Formula_Function_3)(double, double, double);
1847 
1848 //---------------------------------------------------------
1850 {
1851 public:
1852  CSG_Formula(void);
1853  virtual ~CSG_Formula(void);
1854 
1855  bool Destroy (void);
1856 
1857  static CSG_String Get_Help_Operators (bool bHTML = true, const CSG_String Additional[][2] = NULL);
1858 
1859  bool Get_Error (CSG_String &Message);
1860 
1861  bool Add_Function (const char *Name, TSG_Formula_Function_1 Function, int nParameters, bool bVarying = false);
1862 
1863  bool Set_Formula (const CSG_String &Formula);
1864  CSG_String Get_Formula (void) const { return( m_sFormula ); }
1865 
1866  void Set_Variable (char Variable, double Value);
1867 
1868  double Get_Value (void ) const;
1869  double Get_Value (double x ) const;
1870  double Get_Value (const CSG_Vector &Values ) const;
1871  double Get_Value (double *Values, int nValues) const;
1872  double Get_Value (const char *Arguments, ... ) const;
1873 
1874  const char * Get_Used_Variables (void);
1875 
1876 
1877  //-----------------------------------------------------
1878  typedef struct SSG_Function
1879  {
1880  const char *Name;
1881 
1883 
1885 
1886  bool bVarying;
1887  }
1889 
1890 
1891 private:
1892 
1893  //-----------------------------------------------------
1894  typedef struct SSG_Formula
1895  {
1896  char *code;
1897 
1898  double *ctable;
1899  }
1900  TSG_Formula;
1901 
1902 
1903  //-----------------------------------------------------
1904  bool m_bError, m_Vars_Used[256];
1905 
1906  int m_Error_Position, m_Length;
1907 
1908  TSG_Formula m_Formula;
1909 
1910  TSG_Function *m_Functions;
1911 
1912 
1913  CSG_String m_sFormula, m_sError;
1914 
1915  const char *m_error;
1916 
1917  int m_pctable;
1918 
1919  double m_Parameters[32], *m_ctable;
1920 
1921 
1922  void _Set_Error (const CSG_String &Error = "");
1923 
1924  double _Get_Value (const double *Parameters, TSG_Formula Function) const;
1925 
1926  int _is_Operand (char c);
1927  int _is_Operand_Code (char c);
1928  int _is_Number (char c);
1929 
1930  int _Get_Function (int i, char *Name, int *nParameters, int *bVarying);
1931  int _Get_Function (const char *Name);
1932 
1933  TSG_Formula _Translate (const char *source, const char *args, int *length, int *error);
1934 
1935  char * _i_trans (char *function, char *begin, char *end);
1936  char * _comp_time (char *function, char *fend, int npars);
1937  int _max_size (const char *source);
1938  char * _my_strtok (char *s);
1939 
1940 };
1941 
1942 
1944 // //
1945 // //
1946 // //
1948 
1949 //---------------------------------------------------------
1951 {
1957 };
1958 
1959 //---------------------------------------------------------
1961 {
1962 public:
1963  CSG_Trend(void);
1964 
1965  bool Set_Formula (const CSG_String &Formula);
1966  CSG_String Get_Formula (int Type = SG_TREND_STRING_Complete);
1967 
1968  int Get_Parameter_Count (void) const { return( m_Params .Get_Count() ); }
1969  double * Get_Parameters (void) const { return( m_Params.m_A.Get_Data() ); }
1970  bool Init_Parameter (const SG_Char &Variable, double Value);
1971 
1972  void Clr_Data (void);
1973  bool Add_Data (double x, double y);
1974  void Set_Data (double *x, double *y, int n, bool bAdd = false);
1975  void Set_Data (const CSG_Points &Data , bool bAdd = false);
1976  int Get_Data_Count (void) const { return( (int)m_Data[0].Get_Count() ); }
1977  double Get_Data_X (int i) const { return( m_Data[0][i] ); }
1978  double Get_Data_XMin (void) { return( m_Data[0].Get_Minimum() ); }
1979  double Get_Data_XMax (void) { return( m_Data[0].Get_Maximum() ); }
1980  CSG_Simple_Statistics & Get_Data_XStats (void) { return( m_Data[0] ); }
1981  double Get_Data_Y (int i) const { return( m_Data[1][i] ); }
1982  double Get_Data_YMin (void) { return( m_Data[1].Get_Minimum() ); }
1983  double Get_Data_YMax (void) { return( m_Data[1].Get_Maximum() ); }
1984  CSG_Simple_Statistics & Get_Data_YStats (void) { return( m_Data[1] ); }
1985 
1986  bool Set_Max_Iterations (int Iterations);
1987  int Get_Max_Iterations (void) const { return( m_Iter_Max); }
1988  bool Set_Max_Lambda (double Lambda);
1989  double Get_Max_Lambda (void) const { return( m_Lambda_Max); }
1990 
1991  bool Get_Trend (double *x, double *y, int n, const CSG_String &Formula);
1992  bool Get_Trend (const CSG_Points &Data , const CSG_String &Formula);
1993  bool Get_Trend (const CSG_String &Formula);
1994  bool Get_Trend (void);
1995 
1996  bool is_Okay (void) const { return( m_bOkay ); }
1997 
1998  CSG_String Get_Error (void);
1999 
2000  double Get_ChiSquare (void) const { return( m_bOkay ? m_ChiSqr : 0. ); }
2001  double Get_R2 (void) const { return( m_bOkay ? m_ChiSqr_o : 0. ); }
2002 
2003  double Get_Value (double x) const { return( m_bOkay ? m_Formula.Get_Value(x) : 0. ); }
2004 
2005 
2006 private:
2007 
2008  //-----------------------------------------------------
2009  class SAGA_API_DLL_EXPORT CParams
2010  {
2011  public:
2012  CParams(void) {}
2013 
2014  bool Create (const CSG_String &Variables);
2015  bool Destroy (void);
2016 
2017  int Get_Count (void) const { return( (int)m_Variables.Length() ); }
2018 
2019 
2020  CSG_String m_Variables;
2021 
2022  CSG_Vector m_A, m_Atry, m_dA, m_dA2, m_Beta;
2023 
2024  CSG_Matrix m_Alpha, m_Covar;
2025 
2026  };
2027 
2028 
2029  //-----------------------------------------------------
2030  bool m_bOkay;
2031 
2032  int m_Iter_Max;
2033 
2034  double m_ChiSqr, m_ChiSqr_o, m_Lambda, m_Lambda_Max;
2035 
2036  CParams m_Params;
2037 
2038  CSG_Simple_Statistics m_Data[2];
2039 
2040  CSG_Formula m_Formula;
2041 
2042 
2043  bool _Fit_Function (void);
2044  bool _Get_Gaussj (void);
2045  bool _Get_mrqcof (CSG_Vector &Parameters, CSG_Matrix &Alpha, CSG_Vector &Beta);
2046 
2047  void _Get_Function (double &y, double *dy_da, double x, const double *Parameters);
2048 
2049 };
2050 
2051 
2053 // //
2054 // //
2055 // //
2057 
2058 //---------------------------------------------------------
2060 {
2061 public:
2062  CSG_Trend_Polynom(void);
2063 
2064  bool Destroy (void);
2065 
2066  bool Set_Order (int Order = 1);
2067 
2068  bool Clr_Data (void);
2069  bool Set_Data (double *x, double *y, int n, bool bAdd = false);
2070  bool Add_Data (double x, double y);
2071  int Get_Data_Count (void) const { return( m_x.Get_N() ); }
2072  double Get_Data_X (int i) const { return( m_x(i) ); }
2073  double Get_Data_Y (int i) const { return( m_y(i) ); }
2074 
2075  bool Get_Trend (void);
2076 
2077  int Get_Order (void) const { return( m_Order ); }
2078  int Get_nCoefficients (void) const { return( m_Order + 1 ); }
2079  double Get_Coefficient (int i) const { return( m_a(i) ); }
2080  double Get_R2 (void) const { return( m_r2 ); }
2081 
2082  double Get_Value (double x) const;
2083 
2084 
2085 private:
2086 
2087  double m_r2;
2088 
2089  int m_Order;
2090 
2091  CSG_Vector m_x, m_y, m_a;
2092 
2093 };
2094 
2095 
2097 // //
2098 // //
2099 // //
2101 
2102 //---------------------------------------------------------
2103 #endif // #ifndef HEADER_INCLUDED__SAGA_API__mat_tools_H
CSG_Index
Definition: mat_tools.h:185
SG_Get_Square
SAGA_API_DLL_EXPORT double SG_Get_Square(double Value)
Definition: mat_tools.cpp:70
CSG_Regression_Multiple::Get_StdError
double Get_StdError(int iVariable) const
Definition: mat_tools.h:1727
CSG_Category_Statistics::Get_Majority
bool Get_Majority(CSG_String &Value, int &Count)
Definition: mat_tools.h:960
CSG_Trend::Get_Max_Lambda
double Get_Max_Lambda(void) const
Definition: mat_tools.h:1989
CSG_Regression_Multiple::Get_RCoeff
double Get_RCoeff(int iVariable) const
Definition: mat_tools.h:1724
MLR_VAR_R2_ADJ
@ MLR_VAR_R2_ADJ
Definition: mat_tools.h:1669
CSG_Category_Statistics
Definition: mat_tools.h:899
REGRESSION_CORR_Pratt
@ REGRESSION_CORR_Pratt
Definition: mat_tools.h:1558
CSG_Index::is_Okay
bool is_Okay(void) const
Definition: mat_tools.h:223
CSG_Histogram::Get_Cumulative
size_t Get_Cumulative(int i) const
Definition: mat_tools.h:1026
CSG_Regression::Get_Type
TSG_Regression_Type Get_Type(void) const
Definition: mat_tools.h:1634
CSG_Cluster_Analysis::Get_Cluster
sLong Get_Cluster(sLong iElement) const
Definition: mat_tools.h:1146
SG_Compare_Char_Ptr
SAGA_API_DLL_EXPORT int SG_Compare_Char_Ptr(const void *a, const void *b)
Definition: mat_tools.cpp:211
CSG_Histogram::Get_Cumulative
size_t Get_Cumulative(size_t i) const
Definition: mat_tools.h:1027
CSG_Trend::Get_Parameter_Count
int Get_Parameter_Count(void) const
Definition: mat_tools.h:1968
CSG_Points_3D
Definition: geo_tools.h:320
CSG_Trend_Polynom::Get_Data_Y
double Get_Data_Y(int i) const
Definition: mat_tools.h:2073
SG_Matrix_LU_Solve
SAGA_API_DLL_EXPORT bool SG_Matrix_LU_Solve(int n, const int *Permutation, const double **Matrix, double *Vector, bool bSilent=true)
Definition: mat_matrix.cpp:2053
CSG_Formula::SSG_Function::Function
TSG_Formula_Function_1 Function
Definition: mat_tools.h:1882
CSG_Category_Statistics::Get_Minority
bool Get_Minority(int &Value)
Definition: mat_tools.h:963
CSG_Classifier_Supervised::Get_Class_Minimum
double Get_Class_Minimum(int iClass, int iFeature)
Definition: mat_tools.h:1233
ESG_Classify_Supervised
ESG_Classify_Supervised
Definition: mat_tools.h:1193
SG_Matrix_Get_Rotation
SAGA_API_DLL_EXPORT CSG_Matrix SG_Matrix_Get_Rotation(double R, bool bDegree=false)
Definition: mat_matrix.cpp:1866
CSG_Trend::Get_Data_YStats
CSG_Simple_Statistics & Get_Data_YStats(void)
Definition: mat_tools.h:1984
SG_DATATYPE_String
@ SG_DATATYPE_String
Definition: api_core.h:997
CSG_Unique_Number_Statistics::Get_Class
bool Get_Class(int Index, double &Value, int &Count) const
Definition: mat_tools.h:833
CSG_Regression_Weighted::Get_Predictor_Count
int Get_Predictor_Count(void) const
Definition: mat_tools.h:1786
CSG_Category_Statistics::Get_Category
bool Get_Category(int iCategory, CSG_String &Value, int &Count) const
Definition: mat_tools.h:946
CSG_Unique_Value_Statistics::~CSG_Unique_Value_Statistics
virtual ~CSG_Unique_Value_Statistics(void)
Definition: mat_tools.h:798
CSG_Regression_Multiple::m_Samples_Model
CSG_Matrix m_Samples_Model
Definition: mat_tools.h:1750
CSG_Vector::cend
const_iterator cend(void) const
Definition: mat_tools.h:434
SG_CLUSTERANALYSIS_Hill_Climbing
@ SG_CLUSTERANALYSIS_Hill_Climbing
Definition: mat_tools.h:1129
CSG_Unique_Value_Statistics::m_Count
CSG_Array_Int m_Count
Definition: mat_tools.h:814
CSG_Cluster_Analysis::Get_nMembers
int Get_nMembers(int iCluster) const
Definition: mat_tools.h:1158
SG_TREND_STRING_Formula_Parameters
@ SG_TREND_STRING_Formula_Parameters
Definition: mat_tools.h:1954
CSG_Vector::Get_Data
double * Get_Data(void) const
Definition: mat_tools.h:369
CSG_PriorityQueue::CSG_PriorityQueueItem::Compare
virtual int Compare(CSG_PriorityQueueItem *pItem)=0
SG_CLASSIFY_SUPERVISED_Mahalonobis
@ SG_CLASSIFY_SUPERVISED_Mahalonobis
Definition: mat_tools.h:1197
SG_Get_Rounded
SAGA_API_DLL_EXPORT double SG_Get_Rounded(double Value, int Decimals=0)
Definition: mat_tools.cpp:83
CSG_Grid_Radius::Get_Point
double Get_Point(int iRadius, int iPoint, int xOffset, int yOffset, int &x, int &y)
Definition: mat_tools.h:646
TESTDIST_TYPE_Right
@ TESTDIST_TYPE_Right
Definition: mat_tools.h:1496
CSG_Thin_Plate_Spline::Add_Point
bool Add_Point(const TSG_Point &p, double z)
Definition: mat_tools.h:1447
CSG_Regression_Multiple::Get_R2_Partial
double Get_R2_Partial(int iVariable) const
Definition: mat_tools.h:1725
REGRESSION_CORR_Olkin_Pratt
@ REGRESSION_CORR_Olkin_Pratt
Definition: mat_tools.h:1557
CSG_Grid_Radius
Definition: mat_tools.h:594
SG_Get_Digit_Count
SAGA_API_DLL_EXPORT int SG_Get_Digit_Count(int Number)
Definition: mat_tools.cpp:144
CSG_Simple_Statistics::Get_Sum_Of_Squares
double Get_Sum_Of_Squares(void)
Definition: mat_tools.h:735
CSG_Thin_Plate_Spline::Set_Point_Count
bool Set_Point_Count(int Count)
Definition: mat_tools.h:1441
CSG_Regression_Multiple::Get_Predictor
int Get_Predictor(int i) const
Definition: mat_tools.h:1719
CSG_Trend::Get_Data_X
double Get_Data_X(int i) const
Definition: mat_tools.h:1977
A
#define A
CSG_Matrix::Get_NRows
sLong Get_NRows(void) const
Definition: mat_tools.h:508
CSG_Spline::Get_y
double Get_y(int i) const
Definition: mat_tools.h:1415
CSG_Simple_Statistics::Get_Variance
double Get_Variance(void)
Definition: mat_tools.h:737
CSG_Histogram::Get_Break
double Get_Break(int i) const
Definition: mat_tools.h:1031
CSG_Regression_Weighted::Get_RCoeff
const CSG_Vector & Get_RCoeff(void) const
Definition: mat_tools.h:1792
CSG_Unique_Value_Statistics::Get_Count
int Get_Count(int i) const
Definition: mat_tools.h:803
CSG_Regression::Get_Count
int Get_Count(void) const
Definition: mat_tools.h:1595
CSG_Trend::Get_Data_Y
double Get_Data_Y(int i) const
Definition: mat_tools.h:1981
operator*
SAGA_API_DLL_EXPORT CSG_Vector operator*(double Scalar, const CSG_Vector &Vector)
Definition: mat_matrix.cpp:579
CSG_Test_Distribution
Definition: mat_tools.h:1504
TESTDIST_TYPE_Middle
@ TESTDIST_TYPE_Middle
Definition: mat_tools.h:1497
CSG_Table::Get_Value
virtual bool Get_Value(sLong Index, int iField, CSG_String &Value) const
Definition: table.cpp:1161
CSG_Index::Get_Index
sLong Get_Index(sLong Position, bool Ascending=true) const
Definition: mat_tools.h:226
CSG_Unique_Number_Statistics
Definition: mat_tools.h:822
CSG_Index::CSG_Index_Compare
Definition: mat_tools.h:188
MLR_VAR_RCOEFF
@ MLR_VAR_RCOEFF
Definition: mat_tools.h:1666
CSG_PriorityQueue::Get_Item
CSG_PriorityQueueItem * Get_Item(size_t i) const
Definition: mat_tools.h:284
CSG_Regression::Get_xVariance
double Get_xVariance(void) const
Definition: mat_tools.h:1615
CSG_Unique_Value_Statistics::Get_Minority
virtual int Get_Minority(bool bWeighted=false) const
Definition: mat_tools.cpp:833
CSG_Regression::m_yVar
double m_yVar
Definition: mat_tools.h:1644
CSG_Histogram
Definition: mat_tools.h:986
CSG_Trend
Definition: mat_tools.h:1961
CSG_Vector::Get_uSize
size_t Get_uSize(void) const
Definition: mat_tools.h:366
CSG_Histogram::Get_Elements
size_t Get_Elements(size_t i) const
Definition: mat_tools.h:1024
SG_Matrix_Solve
SAGA_API_DLL_EXPORT bool SG_Matrix_Solve(CSG_Matrix &Matrix, CSG_Vector &Vector, bool bSilent=true)
Definition: mat_matrix.cpp:1910
CSG_Regression_Weighted::Get_R2
double Get_R2(void) const
Definition: mat_tools.h:1791
CSG_Unique_Number_Statistics::Get_Minority
bool Get_Minority(double &Value, int &Count) const
Definition: mat_tools.h:846
CSG_Regression::m_xVar
double m_xVar
Definition: mat_tools.h:1643
CSG_Formula::SSG_Function
Definition: mat_tools.h:1879
CSG_Unique_String_Statistics::Get_Minority
bool Get_Minority(CSG_String &Value, int &Count) const
Definition: mat_tools.h:881
SSG_Point_3D
Definition: geo_tools.h:264
CSG_Regression_Weighted::Get_Log_maxIter
int Get_Log_maxIter(void) const
Definition: mat_tools.h:1797
CSG_Classifier_Supervised::Get_Feature_Count
int Get_Feature_Count(void)
Definition: mat_tools.h:1227
MLR_VAR_R2
@ MLR_VAR_R2
Definition: mat_tools.h:1668
SG_Matrix_Eigen_Reduction
SAGA_API_DLL_EXPORT bool SG_Matrix_Eigen_Reduction(const CSG_Matrix &Matrix, CSG_Matrix &Eigen_Vectors, CSG_Vector &Eigen_Values, bool bSilent=true)
Definition: mat_matrix.cpp:1933
CSG_Index::CSG_Index_Compare::Compare
virtual int Compare(const sLong a, const sLong b)=0
CSG_Trend_Polynom
Definition: mat_tools.h:2060
CSG_Regression_Multiple::Get_R2_Partial_Adj
double Get_R2_Partial_Adj(int iVariable) const
Definition: mat_tools.h:1726
CSG_Simple_Statistics::Get_Sum
double Get_Sum(void)
Definition: mat_tools.h:734
CSG_Data_Object::Get_Name
const SG_Char * Get_Name(void) const
Definition: dataobject.cpp:290
CSG_Cluster_Analysis::Get_Iteration
int Get_Iteration(void) const
Definition: mat_tools.h:1154
CSG_Spline::Get_xMax
double Get_xMax(void) const
Definition: mat_tools.h:1413
REGRESSION_CORR_Wherry_1
@ REGRESSION_CORR_Wherry_1
Definition: mat_tools.h:1555
REGRESSION_Log
@ REGRESSION_Log
Definition: mat_tools.h:1579
CSG_Cluster_Analysis
Definition: mat_tools.h:1135
CSG_Regression::Get_R2
double Get_R2(void) const
Definition: mat_tools.h:1627
CSG_Regression::Get_yMin
double Get_yMin(void) const
Definition: mat_tools.h:1618
CSG_Regression::m_SE
double m_SE
Definition: mat_tools.h:1642
CSG_Natural_Breaks
Definition: mat_tools.h:1080
CSG_Formula::Get_Formula
CSG_String Get_Formula(void) const
Definition: mat_tools.h:1864
CSG_Category_Statistics::Get_Minority
bool Get_Minority(double &Value, int &Count)
Definition: mat_tools.h:967
CSG_Natural_Breaks::Get_Break
double Get_Break(int i) const
Definition: mat_tools.h:1098
CSG_Regression_Multiple::Get_P
double Get_P(int iVariable) const
Definition: mat_tools.h:1729
CSG_Regression::Get_xMean
double Get_xMean(void) const
Definition: mat_tools.h:1614
SSG_Point
Definition: geo_tools.h:128
CSG_Regression::Get_yVariance
double Get_yVariance(void) const
Definition: mat_tools.h:1621
CSG_Category_Statistics::Get_Minority
bool Get_Minority(int &Value, int &Count)
Definition: mat_tools.h:966
CSG_Simple_Statistics::Get_Kurtosis
double Get_Kurtosis(void)
Definition: mat_tools.h:740
CSG_Regression::Get_R2_Adj
double Get_R2_Adj(void) const
Definition: mat_tools.h:1628
SG_TREND_STRING_Compact
@ SG_TREND_STRING_Compact
Definition: mat_tools.h:1956
SG_TREND_STRING_Complete
@ SG_TREND_STRING_Complete
Definition: mat_tools.h:1955
CSG_Thin_Plate_Spline::Get_Point_Count
int Get_Point_Count(void)
Definition: mat_tools.h:1442
CSG_Category_Statistics::Get_Minority
bool Get_Minority(CSG_String &Value)
Definition: mat_tools.h:965
CSG_Unique_Number_Statistics::Get_Majority
bool Get_Majority(double &Value, int &Count) const
Definition: mat_tools.h:844
CSG_Trend::Get_R2
double Get_R2(void) const
Definition: mat_tools.h:2001
CSG_Matrix::Get_Data
double ** Get_Data(void) const
Definition: mat_tools.h:511
CSG_Histogram::Get_Element_Count
size_t Get_Element_Count(void) const
Definition: mat_tools.h:1020
CSG_Regression_Multiple::Get_ID
double Get_ID(int iVariable) const
Definition: mat_tools.h:1723
CSG_Histogram::Get_Center
double Get_Center(int i) const
Definition: mat_tools.h:1034
CSG_Trend::Get_Data_YMax
double Get_Data_YMax(void)
Definition: mat_tools.h:1983
CSG_Category_Statistics::Get_Minority
bool Get_Minority(CSG_String &Value, int &Count)
Definition: mat_tools.h:968
MLR_VAR_T
@ MLR_VAR_T
Definition: mat_tools.h:1671
CSG_Trend_Polynom::Get_R2
double Get_R2(void) const
Definition: mat_tools.h:2080
CSG_Trend_Polynom::Get_Coefficient
double Get_Coefficient(int i) const
Definition: mat_tools.h:2079
CSG_Matrix::Get_NCols
sLong Get_NCols(void) const
Definition: mat_tools.h:507
SG_Regression_Get_Adjusted_R2
SAGA_API_DLL_EXPORT double SG_Regression_Get_Adjusted_R2(double R2, int nSamples, int nPredictors, TSG_Regression_Correction Correction=REGRESSION_CORR_Wherry_1)
Definition: mat_regression.cpp:63
SG_Get_Rounded_To_SignificantFigures
SAGA_API_DLL_EXPORT double SG_Get_Rounded_To_SignificantFigures(double Value, int Decimals)
Definition: mat_tools.cpp:107
CSG_Grid_Radius::Get_Maximum
int Get_Maximum(void)
Definition: mat_tools.h:602
CSG_Category_Statistics::Get_Majority
bool Get_Majority(int &Value)
Definition: mat_tools.h:955
SG_CLASSIFY_SUPERVISED_SVM
@ SG_CLASSIFY_SUPERVISED_SVM
Definition: mat_tools.h:1202
CSG_Formula
Definition: mat_tools.h:1850
CSG_Spline::m_bCreated
bool m_bCreated
Definition: mat_tools.h:1423
REGRESSION_Linear
@ REGRESSION_Linear
Definition: mat_tools.h:1574
CSG_Simple_Statistics::Get_Maximum
double Get_Maximum(void)
Definition: mat_tools.h:732
SG_CLASSIFY_SUPERVISED_SID
@ SG_CLASSIFY_SUPERVISED_SID
Definition: mat_tools.h:1201
CSG_Unique_String_Statistics
Definition: mat_tools.h:857
SG_Get_Correlation_Matrix
SAGA_API_DLL_EXPORT CSG_Matrix SG_Get_Correlation_Matrix(const CSG_Matrix &Values, bool bCovariances=false)
Definition: mat_tools.cpp:3473
CSG_Spline::Get_x
double Get_x(int i) const
Definition: mat_tools.h:1414
REGRESSION_CORR_Claudy_3
@ REGRESSION_CORR_Claudy_3
Definition: mat_tools.h:1559
CSG_Regression_Multiple::Get_Info_Steps
class CSG_Table * Get_Info_Steps(void) const
Definition: mat_tools.h:1705
CSG_Histogram::Get_Center
double Get_Center(size_t i) const
Definition: mat_tools.h:1035
CSG_Unique_String_Statistics::~CSG_Unique_String_Statistics
virtual ~CSG_Unique_String_Statistics(void)
Definition: mat_tools.h:860
SG_CLASSIFY_SUPERVISED_WTA
@ SG_CLASSIFY_SUPERVISED_WTA
Definition: mat_tools.h:1200
CSG_Vector
Definition: mat_tools.h:345
REGRESSION_CORR_Wherry_2
@ REGRESSION_CORR_Wherry_2
Definition: mat_tools.h:1556
CSG_Parameter
Definition: parameters.h:207
TSG_Test_Distribution_Type
TSG_Test_Distribution_Type
Definition: mat_tools.h:1494
CSG_Trend::Get_Data_XMax
double Get_Data_XMax(void)
Definition: mat_tools.h:1979
CSG_Category_Statistics::Get_Majority
bool Get_Majority(int &Value, int &Count)
Definition: mat_tools.h:958
MLR_VAR_R
@ MLR_VAR_R
Definition: mat_tools.h:1667
SG_Get_Double_asString
SAGA_API_DLL_EXPORT CSG_String SG_Get_Double_asString(double Number, int Width=-1, int Precision=-1, bool bScientific=false)
Definition: mat_tools.cpp:159
CSG_Simple_Statistics::Get_Count
sLong Get_Count(void) const
Definition: mat_tools.h:728
CSG_Natural_Breaks::Get_Count
int Get_Count(void) const
Definition: mat_tools.h:1097
CSG_Cluster_Analysis::Get_nElements
sLong Get_nElements(void) const
Definition: mat_tools.h:1150
CSG_Trend_Polynom::Get_Data_X
double Get_Data_X(int i) const
Definition: mat_tools.h:2072
SG_Matrix_LU_Decomposition
SAGA_API_DLL_EXPORT bool SG_Matrix_LU_Decomposition(int n, int *Permutation, double **Matrix, bool bSilent=true, int *nRowChanges=NULL)
Definition: mat_matrix.cpp:1948
CSG_Classifier_Supervised::Get_Class_ID
const CSG_String & Get_Class_ID(int iClass)
Definition: mat_tools.h:1231
MLR_VAR_NAME
@ MLR_VAR_NAME
Definition: mat_tools.h:1665
CSG_Regression_Multiple::Get_T
double Get_T(int iVariable) const
Definition: mat_tools.h:1728
CSG_Simple_Statistics::Get_Minimum
double Get_Minimum(void)
Definition: mat_tools.h:731
TSG_PFNC_Compare
int(* TSG_PFNC_Compare)(const sLong a, const sLong b)
Definition: mat_tools.h:181
CSG_Regression_Weighted::Get_RCoeff
double Get_RCoeff(int i) const
Definition: mat_tools.h:1793
CSG_Trend::Get_Parameters
double * Get_Parameters(void) const
Definition: mat_tools.h:1969
CSG_Regression_Multiple::m_Predictor
int * m_Predictor
Definition: mat_tools.h:1746
CSG_Simple_Statistics::Get_Weights
double Get_Weights(void) const
Definition: mat_tools.h:729
CSG_Regression_Weighted::Get_Log_Difference
double Get_Log_Difference(void) const
Definition: mat_tools.h:1799
CSG_Unique_Value_Statistics
Definition: mat_tools.h:795
CSG_Unique_Number_Statistics::CSG_Unique_Number_Statistics
CSG_Unique_Number_Statistics(bool bWeights=false)
Definition: mat_tools.h:824
CSG_Regression_Weighted::Get_CV_RMSE
double Get_CV_RMSE(void) const
Definition: mat_tools.h:1809
CSG_Regression::Get_xMax
double Get_xMax(void) const
Definition: mat_tools.h:1613
SG_Degree_To_Decimal
SAGA_API_DLL_EXPORT double SG_Degree_To_Decimal(double Deg, double Min, double Sec)
Definition: mat_tools.cpp:224
sLong
signed long long sLong
Definition: api_core.h:158
CSG_Category_Statistics::Get_Majority
bool Get_Majority(double &Value)
Definition: mat_tools.h:956
CSG_Regression_Multiple::m_bIntercept
bool m_bIntercept
Definition: mat_tools.h:1744
CSG_Regression_Weighted::Get_CV_R2
double Get_CV_R2(void) const
Definition: mat_tools.h:1811
CSG_Simple_Statistics::m_bEvaluated
int m_bEvaluated
Definition: mat_tools.h:773
CSG_Unique_Number_Statistics::Get_Majority
bool Get_Majority(double &Value) const
Definition: mat_tools.h:843
CSG_Trend::is_Okay
bool is_Okay(void) const
Definition: mat_tools.h:1996
CSG_Simple_Statistics::Get_StdDev
double Get_StdDev(void)
Definition: mat_tools.h:738
ESG_Multiple_Regression_Info_Vars
ESG_Multiple_Regression_Info_Vars
Definition: mat_tools.h:1663
CSG_Histogram::Get_Break
double Get_Break(size_t i) const
Definition: mat_tools.h:1032
CSG_Regression::Get_Values
bool Get_Values(int i, double &x, double &y) const
Definition: mat_tools.h:1599
CSG_Classifier_Supervised::Get_Class_Count
int Get_Class_Count(void)
Definition: mat_tools.h:1229
CSG_PriorityQueue::Peek
CSG_PriorityQueueItem * Peek(void) const
Definition: mat_tools.h:288
TSG_Formula_Function_0
double(* TSG_Formula_Function_0)(void)
Definition: mat_tools.h:1843
CSG_Cluster_Analysis::Get_Variance
double Get_Variance(int iCluster) const
Definition: mat_tools.h:1159
CSG_Regression::Get_yValue
double Get_yValue(int i) const
Definition: mat_tools.h:1598
SG_CLASSIFY_SUPERVISED_SAM
@ SG_CLASSIFY_SUPERVISED_SAM
Definition: mat_tools.h:1199
CSG_Regression::m_Type
TSG_Regression_Type m_Type
Definition: mat_tools.h:1648
CSG_Trend_Polynom::Get_nCoefficients
int Get_nCoefficients(void) const
Definition: mat_tools.h:2078
CSG_Array_Int
Definition: api_core.h:421
CSG_Trend::Get_Data_XMin
double Get_Data_XMin(void)
Definition: mat_tools.h:1978
CSG_Simple_Statistics::is_Evaluated
int is_Evaluated(void) const
Definition: mat_tools.h:724
CSG_Vector::Get_N
int Get_N(void) const
Definition: mat_tools.h:367
REGRESSION_Rez_X
@ REGRESSION_Rez_X
Definition: mat_tools.h:1575
SAGA_API_DLL_EXPORT
#define SAGA_API_DLL_EXPORT
Definition: api_core.h:94
CSG_Vector::cbegin
const_iterator cbegin(void) const
Definition: mat_tools.h:433
REGRESSION_Rez_Y
@ REGRESSION_Rez_Y
Definition: mat_tools.h:1576
CSG_Classifier_Supervised::Get_Class_Maximum
double Get_Class_Maximum(int iClass, int iFeature)
Definition: mat_tools.h:1234
CSG_Formula::SSG_Function::nParameters
int nParameters
Definition: mat_tools.h:1884
CSG_Unique_Value_Statistics::m_Weight
CSG_Vector m_Weight
Definition: mat_tools.h:816
SG_CLASSIFY_SUPERVISED_ParallelEpiped
@ SG_CLASSIFY_SUPERVISED_ParallelEpiped
Definition: mat_tools.h:1195
CSG_Regression::Get_Constant
double Get_Constant(void) const
Definition: mat_tools.h:1624
CSG_Vector::end
const_iterator end(void) const
Definition: mat_tools.h:432
CSG_Unique_Number_Statistics::~CSG_Unique_Number_Statistics
virtual ~CSG_Unique_Number_Statistics(void)
Definition: mat_tools.h:825
CSG_Grid_Radius::Get_nPoints
int Get_nPoints(int iRadius)
Definition: mat_tools.h:605
CSG_Simple_Statistics::Get_Mean
double Get_Mean(void)
Definition: mat_tools.h:736
CSG_Strings
Definition: api_core.h:693
CSG_Simple_Statistics::Get_Skewness
double Get_Skewness(void)
Definition: mat_tools.h:741
CSG_Regression_Weighted::Get_CV_NRMSE
double Get_CV_NRMSE(void) const
Definition: mat_tools.h:1810
REGRESSION_Pow
@ REGRESSION_Pow
Definition: mat_tools.h:1577
CSG_Unique_Value_Statistics::Get_Count
int Get_Count(void) const
Definition: mat_tools.h:802
CSG_Points
Definition: geo_tools.h:184
CSG_Category_Statistics::Get_Minority
bool Get_Minority(double &Value)
Definition: mat_tools.h:964
SG_CLASSIFY_SUPERVISED_MaximumLikelihood
@ SG_CLASSIFY_SUPERVISED_MaximumLikelihood
Definition: mat_tools.h:1198
CSG_Histogram::Get_Class_Count
size_t Get_Class_Count(void) const
Definition: mat_tools.h:1018
SG_Compare_Int
SAGA_API_DLL_EXPORT int SG_Compare_Int(const void *a, const void *b)
Definition: mat_tools.cpp:187
SG_CLUSTERANALYSIS_Combined
@ SG_CLUSTERANALYSIS_Combined
Definition: mat_tools.h:1130
CSG_Regression_Multiple::Get_With_Intercept
bool Get_With_Intercept(void) const
Definition: mat_tools.h:1688
CSG_Unique_Number_Statistics::Get_Value
double Get_Value(int Index) const
Definition: mat_tools.h:831
CSG_Vector::Get_Data
double Get_Data(sLong x) const
Definition: mat_tools.h:370
CSG_Regression_Multiple::Set_With_Intercept
void Set_With_Intercept(bool bOn=true)
Definition: mat_tools.h:1687
CSG_Cluster_Analysis::Get_SP
double Get_SP(void) const
Definition: mat_tools.h:1156
CSG_Table
Definition: table.h:283
CSG_Matrix::is_Square
bool is_Square(void) const
Definition: mat_tools.h:521
CSG_Cluster_Analysis::Get_nFeatures
int Get_nFeatures(void) const
Definition: mat_tools.h:1151
CSG_Vector::Get_Size
sLong Get_Size(void) const
Definition: mat_tools.h:365
ESG_Trend_String
ESG_Trend_String
Definition: mat_tools.h:1951
TSG_Regression_Type
TSG_Regression_Type
Definition: mat_tools.h:1573
CSG_Spline::Get_xMin
double Get_xMin(void) const
Definition: mat_tools.h:1412
TSG_Regression_Correction
TSG_Regression_Correction
Definition: mat_tools.h:1552
CSG_Regression_Weighted::Get_CV_nSamples
int Get_CV_nSamples(void) const
Definition: mat_tools.h:1808
SG_TREND_STRING_Formula
@ SG_TREND_STRING_Formula
Definition: mat_tools.h:1952
CSG_PriorityQueue::Get_Size
size_t Get_Size(void) const
Definition: mat_tools.h:283
TSG_Formula_Function_2
double(* TSG_Formula_Function_2)(double, double)
Definition: mat_tools.h:1845
CSG_Unique_Number_Statistics::Get_Minority
bool Get_Minority(double &Value) const
Definition: mat_tools.h:845
CSG_Regression_Weighted
Definition: mat_tools.h:1777
CSG_Simple_Statistics::m_nValues
sLong m_nValues
Definition: mat_tools.h:775
TESTDIST_TYPE_TwoTail
@ TESTDIST_TYPE_TwoTail
Definition: mat_tools.h:1498
SG_Char
#define SG_Char
Definition: api_core.h:530
CSG_Unique_String_Statistics::Get_Majority
bool Get_Majority(CSG_String &Value, int &Count) const
Definition: mat_tools.h:879
CSG_Spline
Definition: mat_tools.h:1399
CSG_Thin_Plate_Spline::Get_Points
CSG_Points_3D & Get_Points(void)
Definition: mat_tools.h:1444
CSG_Regression::Get_xMin
double Get_xMin(void) const
Definition: mat_tools.h:1612
CSG_Array
Definition: api_core.h:308
CSG_Classifier_Supervised::Get_Class_Mean
double Get_Class_Mean(int iClass, int iFeature)
Definition: mat_tools.h:1232
B
#define B
CSG_PriorityQueue::Minimum
CSG_PriorityQueueItem * Minimum(void) const
Definition: mat_tools.h:292
CSG_String
Definition: api_core.h:557
CSG_Formula::SSG_Function::Name
const char * Name
Definition: mat_tools.h:1880
CSG_Unique_Value_Statistics::Get_Weight
double Get_Weight(int i) const
Definition: mat_tools.h:804
CSG_Simple_Statistics::Get_Values
double * Get_Values(void) const
Definition: mat_tools.h:759
CSG_Simple_Statistics::Get_Value
double Get_Value(sLong i) const
Definition: mat_tools.h:760
CSG_Regression_Multiple::m_pSteps
class CSG_Table * m_pSteps
Definition: mat_tools.h:1752
CSG_Regression::m_y
CSG_Vector m_y
Definition: mat_tools.h:1646
CSG_Regression::Get_Coefficient
double Get_Coefficient(void) const
Definition: mat_tools.h:1625
CSG_PriorityQueue::is_Empty
bool is_Empty(void) const
Definition: mat_tools.h:282
CSG_Regression::Get_R
double Get_R(void) const
Definition: mat_tools.h:1626
TSG_Formula_Function_1
double(* TSG_Formula_Function_1)(double)
Definition: mat_tools.h:1844
CSG_Category_Statistics::Get_Majority
bool Get_Majority(double &Value, int &Count)
Definition: mat_tools.h:959
CSG_Simple_Statistics::Get_Range
double Get_Range(void)
Definition: mat_tools.h:733
MLR_VAR_P
@ MLR_VAR_P
Definition: mat_tools.h:1673
CSG_Regression_Multiple::Get_Info_Model
class CSG_Table * Get_Info_Model(void) const
Definition: mat_tools.h:1704
CSG_Unique_Value_Statistics::Get_Majority
virtual int Get_Majority(bool bWeighted=false) const
Definition: mat_tools.cpp:805
CSG_Regression_Multiple::m_Names
CSG_Strings m_Names
Definition: mat_tools.h:1748
SG_CLASSIFY_SUPERVISED_BinaryEncoding
@ SG_CLASSIFY_SUPERVISED_BinaryEncoding
Definition: mat_tools.h:1194
SSG_Point::x
double x
Definition: geo_tools.h:129
SG_VectorR2_Rotate
SAGA_API_DLL_EXPORT bool SG_VectorR2_Rotate(double &x, double &y, double Angle)
Definition: mat_matrix.cpp:750
CSG_Cluster_Analysis::Get_nClusters
int Get_nClusters(void) const
Definition: mat_tools.h:1152
CSG_Category_Statistics::Get_Category
bool Get_Category(int iCategory, double &Value, int &Count) const
Definition: mat_tools.h:938
SG_TREND_STRING_Function
@ SG_TREND_STRING_Function
Definition: mat_tools.h:1953
CSG_Random
Definition: mat_tools.h:685
CSG_Cluster_Analysis::Get_Centroid
double Get_Centroid(int iCluster, int iFeature) const
Definition: mat_tools.h:1160
CSG_Unique_String_Statistics::Get_Majority
bool Get_Majority(CSG_String &Value) const
Definition: mat_tools.h:878
CSG_PriorityQueue
Definition: mat_tools.h:260
CSG_Formula::TSG_Function
struct CSG_Formula::SSG_Function TSG_Function
CSG_Formula::SSG_Function::bVarying
bool bVarying
Definition: mat_tools.h:1886
CSG_Unique_Value_Statistics::Create
virtual void Create(bool bWeights=false)
Definition: mat_tools.h:800
CSG_Grid_Radius::Get_Point
double Get_Point(int iPoint, int &x, int &y)
Definition: mat_tools.h:607
CSG_Trend_Polynom::Get_Data_Count
int Get_Data_Count(void) const
Definition: mat_tools.h:2071
CSG_Regression::Get_StdError
double Get_StdError(void) const
Definition: mat_tools.h:1630
SSG_Point::y
double y
Definition: geo_tools.h:129
CSG_Grid
Definition: grid.h:473
TSG_Formula_Function_3
double(* TSG_Formula_Function_3)(double, double, double)
Definition: mat_tools.h:1846
MLR_VAR_ID
@ MLR_VAR_ID
Definition: mat_tools.h:1664
CSG_Trend::Get_Value
double Get_Value(double x) const
Definition: mat_tools.h:2003
MLR_VAR_SE
@ MLR_VAR_SE
Definition: mat_tools.h:1670
CSG_Trend::Get_Data_Count
int Get_Data_Count(void) const
Definition: mat_tools.h:1976
SG_CLASSIFY_SUPERVISED_MinimumDistance
@ SG_CLASSIFY_SUPERVISED_MinimumDistance
Definition: mat_tools.h:1196
SG_Compare_Double
SAGA_API_DLL_EXPORT int SG_Compare_Double(const void *a, const void *b)
Definition: mat_tools.cpp:199
CSG_PriorityQueue::CSG_PriorityQueueItem::CSG_PriorityQueueItem
CSG_PriorityQueueItem(void)
Definition: mat_tools.h:267
CSG_Unique_String_Statistics::Get_Minority
bool Get_Minority(CSG_String &Value) const
Definition: mat_tools.h:880
CSG_Trend::Get_Data_YMin
double Get_Data_YMin(void)
Definition: mat_tools.h:1982
CSG_Unique_String_Statistics::Get_Value
const SG_Char * Get_Value(int Index) const
Definition: mat_tools.h:866
CSG_Unique_Value_Statistics::CSG_Unique_Value_Statistics
CSG_Unique_Value_Statistics(void)
Definition: mat_tools.h:797
CSG_Grid_Radius::Get_Point
double Get_Point(int iPoint, int xOffset, int yOffset, int &x, int &y)
Definition: mat_tools.h:620
CSG_Thin_Plate_Spline
Definition: mat_tools.h:1434
CSG_Vector::begin
const_iterator begin(void) const
Definition: mat_tools.h:431
CSG_Parameters
Definition: parameters.h:1650
CSG_Grid_Radius::Get_nPoints
int Get_nPoints(void)
Definition: mat_tools.h:604
TSG_Data_Type
TSG_Data_Type
Definition: api_core.h:985
TESTDIST_TYPE_Left
@ TESTDIST_TYPE_Left
Definition: mat_tools.h:1495
CSG_Unique_String_Statistics::Get_Class
bool Get_Class(int Index, CSG_String &Value, int &Count) const
Definition: mat_tools.h:868
SG_CLUSTERANALYSIS_Minimum_Distance
@ SG_CLUSTERANALYSIS_Minimum_Distance
Definition: mat_tools.h:1128
CSG_Thin_Plate_Spline::Set_Point
bool Set_Point(int Index, double x, double y, double z)
Definition: mat_tools.h:1449
CSG_Category_Statistics::Get_Majority
bool Get_Majority(CSG_String &Value)
Definition: mat_tools.h:957
CSG_Grid_Radius::Get_Point
double Get_Point(int iRadius, int iPoint, int &x, int &y)
Definition: mat_tools.h:633
CSG_Regression::Get_P
double Get_P(void) const
Definition: mat_tools.h:1629
MLR_VAR_SIG
@ MLR_VAR_SIG
Definition: mat_tools.h:1672
CSG_PriorityQueue::CSG_PriorityQueueItem
Definition: mat_tools.h:265
CSG_PriorityQueue::Maximum
CSG_PriorityQueueItem * Maximum(void) const
Definition: mat_tools.h:307
CSG_Regression_Weighted::Get_Log_Epsilon
double Get_Log_Epsilon(void) const
Definition: mat_tools.h:1798
CSG_Regression
Definition: mat_tools.h:1585
CSG_Spline::Get_Count
int Get_Count(void) const
Definition: mat_tools.h:1411
CSG_Index::Get_Count
sLong Get_Count(void) const
Definition: mat_tools.h:224
SG_Decimal_To_Degree
SAGA_API_DLL_EXPORT void SG_Decimal_To_Degree(double Value, double &Deg, double &Min, double &Sec)
Definition: mat_tools.cpp:233
CSG_Trend::Get_Data_XStats
CSG_Simple_Statistics & Get_Data_XStats(void)
Definition: mat_tools.h:1980
CSG_Histogram::Get_Element_Maximum
size_t Get_Element_Maximum(void) const
Definition: mat_tools.h:1021
CSG_Matrix
Definition: mat_tools.h:463
CSG_Grids
Definition: grids.h:119
CSG_Thin_Plate_Spline::Set_Point
bool Set_Point(int Index, const TSG_Point &p, double z)
Definition: mat_tools.h:1463
CSG_Category_Statistics::Get_Category
bool Get_Category(int iCategory, int &Value, int &Count) const
Definition: mat_tools.h:930
CSG_Index::CSG_Index_Compare::~CSG_Index_Compare
virtual ~CSG_Index_Compare(void)
Definition: mat_tools.h:191
REGRESSION_Exp
@ REGRESSION_Exp
Definition: mat_tools.h:1578
CSG_Trend::Get_Max_Iterations
int Get_Max_Iterations(void) const
Definition: mat_tools.h:1987
REGRESSION_CORR_Smith
@ REGRESSION_CORR_Smith
Definition: mat_tools.h:1554
SG_VectorR3_Rotate
SAGA_API_DLL_EXPORT bool SG_VectorR3_Rotate(double Vector[3], size_t Axis, double Angle)
Definition: mat_matrix.cpp:776
CSG_Histogram::Get_Elements
size_t Get_Elements(int i) const
Definition: mat_tools.h:1023
CSG_Simple_Statistics
Definition: mat_tools.h:708
CSG_Simple_Statistics::m_Values
CSG_Array m_Values
Definition: mat_tools.h:779
CSG_Index::CSG_Index_Compare::CSG_Index_Compare
CSG_Index_Compare(void)
Definition: mat_tools.h:190
CSG_Trend::Get_ChiSquare
double Get_ChiSquare(void) const
Definition: mat_tools.h:2000
REGRESSION_CORR_None
@ REGRESSION_CORR_None
Definition: mat_tools.h:1553
CSG_Classifier_Supervised
Definition: mat_tools.h:1207
CSG_Histogram::Get_Value
double Get_Value(double i) const
Definition: mat_tools.h:1029
ESG_Cluster_Analysis_Method
ESG_Cluster_Analysis_Method
Definition: mat_tools.h:1127
CSG_Matrix::Get_NY
int Get_NY(void) const
Definition: mat_tools.h:506
CSG_Unique_String_Statistics::CSG_Unique_String_Statistics
CSG_Unique_String_Statistics(bool bWeights=false)
Definition: mat_tools.h:859
CSG_Regression_Multiple::Get_Info_Regression
class CSG_Table * Get_Info_Regression(void) const
Definition: mat_tools.h:1703
geo_tools.h
CSG_Regression::Get_yMax
double Get_yMax(void) const
Definition: mat_tools.h:1619
CSG_Vector::Get_Row_Count
sLong Get_Row_Count(void) const
Definition: mat_tools.h:364
CSG_Histogram::Get_Statistics
const CSG_Simple_Statistics & Get_Statistics(void) const
Definition: mat_tools.h:1051
CSG_Spline::m_z
CSG_Vector m_z
Definition: mat_tools.h:1425
CSG_Regression::Get_yMean
double Get_yMean(void) const
Definition: mat_tools.h:1620
CSG_Simple_Statistics::m_Weights
double m_Weights
Definition: mat_tools.h:777
CSG_Thin_Plate_Spline::Add_Point
bool Add_Point(double x, double y, double z)
Definition: mat_tools.h:1446
CSG_Matrix::Get_NX
int Get_NX(void) const
Definition: mat_tools.h:505
CSG_Thin_Plate_Spline::is_Okay
bool is_Okay(void)
Definition: mat_tools.h:1467
CSG_Simple_Statistics::m_bSorted
bool m_bSorted
Definition: mat_tools.h:771
CSG_Regression_Multiple
Definition: mat_tools.h:1678
CSG_Regression_Weighted::Get_Sample_Count
int Get_Sample_Count(void) const
Definition: mat_tools.h:1785
CSG_Vector::const_iterator
double const * const_iterator
Definition: mat_tools.h:429
CSG_Trend_Polynom::Get_Order
int Get_Order(void) const
Definition: mat_tools.h:2077
CSG_Regression::Get_xValue
double Get_xValue(int i) const
Definition: mat_tools.h:1597
operator+
SAGA_API_DLL_EXPORT CSG_String operator+(const char *A, const CSG_String &B)
Definition: api_string.cpp:473