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