 |
SAGA API
v9.2
|
Go to the documentation of this file.
53 #ifndef HEADER_INCLUDED__SAGA_API__mat_tools_H
54 #define HEADER_INCLUDED__SAGA_API__mat_tools_H
98 #define M_PI 3.141592653589793
101 #define M_PI_045 (M_PI / 4.)
102 #define M_PI_090 (M_PI / 2.)
103 #define M_PI_135 (M_PI * 3. / 4.)
104 #define M_PI_180 (M_PI)
105 #define M_PI_225 (M_PI * 5. / 4.)
106 #define M_PI_270 (M_PI * 3. / 2.)
107 #define M_PI_315 (M_PI * 7. / 4.)
108 #define M_PI_360 (M_PI * 2.)
110 #define M_RAD_TO_DEG (180. / M_PI)
111 #define M_DEG_TO_RAD (M_PI / 180.)
114 #define M_EULER 2.718281828459045
117 #define N_MEGABYTE_BYTES 0x100000
120 #define M_ALMOST_ZERO 0.001l
121 #define M_TINY (1.0e-20)
124 #define M_SQR(x) ((x) * (x))
125 #define M_SQRT(x) sqrt((double)(x))
126 #define M_GET_LENGTH(x, y) sqrt((double)((x)*(x) + (y)*(y)))
128 #define M_GET_MIN(a, b) (((a) < (b)) ? (a) : (b))
129 #define M_GET_MAX(a, b) (((a) > (b)) ? (a) : (b))
130 #define M_SET_MINMAX(min, max, x) if( min > x ) { min = x; } else if( max < x ) { max = x; }
132 #define M_SET_SIGN(x, sign) ((sign) < 0 ? (x < 0 ? x : -x) : (x > 0 ? x : -x))
135 #define SG_ROUND_TO_BYTE(x) ((BYTE )(x < 0. ? x - 0.5 : x + 0.5))
136 #define SG_ROUND_TO_CHAR(x) ((char )(x < 0. ? x - 0.5 : x + 0.5))
137 #define SG_ROUND_TO_WORD(x) ((WORD )(x < 0. ? x - 0.5 : x + 0.5))
138 #define SG_ROUND_TO_SHORT(x) ((short)(x < 0. ? x - 0.5 : x + 0.5))
139 #define SG_ROUND_TO_DWORD(x) ((DWORD)(x < 0. ? x - 0.5 : x + 0.5))
140 #define SG_ROUND_TO_INT(x) ((int )(x < 0. ? x - 0.5 : x + 0.5))
141 #define SG_ROUND_TO_LONG(x) ((long )(x < 0. ? x - 0.5 : x + 0.5))
142 #define SG_ROUND_TO_ULONG(x) ((uLong)(x < 0. ? x - 0.5 : x + 0.5))
143 #define SG_ROUND_TO_SLONG(x) ((sLong)(x < 0. ? x - 0.5 : x + 0.5))
208 bool Create (
sLong nValues,
int *Values,
bool bAscending =
true);
210 CSG_Index (
sLong nValues,
double *Values,
bool bAscending =
true);
211 bool Create (
sLong nValues,
double *Values,
bool bAscending =
true);
218 void Show_Progress (
bool bProgress =
true);
220 bool Add_Entry (
sLong Position = -1);
221 bool Del_Entry (
sLong Position = -1);
223 bool is_Okay (
void)
const {
return( m_nValues > 0 ); }
228 return( Position < 0 || Position >= m_nValues ? -1 : m_Index[Ascending ? Position : m_nValues - 1 - Position] );
233 return( Position < 0 || Position >= m_nValues ? -1 : m_Index[Position] );
241 sLong m_nValues, *m_Index;
244 void _On_Construction (
void);
246 bool _Set_Array (
sLong nValues);
247 bool _Set_Index (CSG_Index_Compare *pCompare);
278 void Create (
size_t maxSize = 256);
282 bool is_Empty (
void)
const {
return( m_nItems == 0 ); }
283 size_t Get_Size (
void)
const {
return( m_nItems ); }
286 void Add (CSG_PriorityQueueItem *pItem);
289 CSG_PriorityQueueItem * Poll (
void);
298 return( m_pLeaf[0]->Minimum() );
301 return( m_Items[0] );
313 return( m_pLeaf[1]->Maximum() );
316 return( m_Items[m_nItems - 1] );
325 size_t m_nItems, m_maxSize;
329 CSG_PriorityQueueItem **m_Items;
332 size_t _Insert_Position (CSG_PriorityQueueItem *pItem);
354 bool Create (
sLong n,
const double *Data = NULL);
358 bool Set_Rows (
sLong nRows);
359 bool Add_Rows (
sLong nRows);
360 bool Del_Rows (
sLong nRows);
361 bool Add_Row (
double Value = 0.);
362 bool Del_Row (
sLong Row = -1);
366 size_t Get_uSize (
void)
const {
return( m_Array.Get_uSize() ); }
367 int Get_N (
void)
const {
return( (
int)m_Array.Get_Size() ); }
369 double *
Get_Data (
void)
const {
return( (
double *)m_Array.Get_Array() ); }
371 double operator () (
sLong x)
const {
return( Get_Data()[x] ); }
372 double & operator [] (
sLong x) {
return( Get_Data()[x] ); }
373 double & operator [] (
size_t x) {
return( Get_Data()[x] ); }
374 double & operator [] (
int x) {
return( Get_Data()[x] ); }
375 const double & operator [] (
sLong x)
const {
return( Get_Data()[x] ); }
376 const double & operator [] (
size_t x)
const {
return( Get_Data()[x] ); }
377 const double & operator [] (
int x)
const {
return( Get_Data()[x] ); }
378 operator const double * (void)
const {
return( Get_Data() ); }
380 CSG_String to_String (
int Width = -1,
int Precision = -1,
bool bScientific =
false,
const SG_Char *Separator = NULL)
const;
383 bool is_Null (
void)
const;
384 bool is_Equal (
const CSG_Vector &Vector)
const;
385 bool is_Collinear (
const CSG_Vector &Vector)
const;
387 bool Assign (
double Scalar);
389 bool Add (
double Scalar);
392 bool Multiply (
double Scalar);
394 bool Multiply_Cross (
const CSG_Vector &Vector);
395 double Multiply_Scalar (
const CSG_Vector &Vector)
const;
396 bool Multiply (
const class CSG_Matrix &Matrix);
398 bool operator == (
const CSG_Vector &Vector)
const {
return( is_Equal(Vector) ); }
399 bool operator != (
const CSG_Vector &Vector)
const {
return( !is_Equal(Vector) ); }
416 bool Set_Zero (
void);
417 bool Set_Unity (
void);
419 bool Flip_Values (
void);
421 bool Sort (
bool bAscending =
true);
423 double Get_Length (
void)
const;
426 double Get_Angle (
const CSG_Vector &Vector)
const;
472 bool Create (
sLong nCols,
sLong nRows,
const double *Data = NULL);
475 bool Create (
sLong nCols,
sLong nRows,
const double **Data);
480 bool Set_Cols (
sLong nCols);
481 bool Set_Rows (
sLong nRows);
482 bool Add_Cols (
sLong nCols);
483 bool Add_Rows (
sLong nRows);
484 bool Del_Cols (
sLong nCols);
485 bool Del_Rows (
sLong nRows);
486 bool Add_Col (
const double *Data = NULL);
488 bool Add_Row (
const double *Data = NULL);
490 bool Ins_Col (
sLong Col,
const double *Data = NULL);
492 bool Ins_Row (
sLong Row,
const double *Data = NULL);
494 bool Set_Col (
sLong Col,
const double *Data);
497 bool Set_Row (
sLong Row,
const double *Data);
500 bool Del_Col (
sLong Col);
501 bool Del_Row (
sLong Row);
505 int Get_NX (
void)
const {
return( (
int)m_nx ); }
506 int Get_NY (
void)
const {
return( (
int)m_ny ); }
510 operator const double ** (void)
const {
return( (
const double **)m_z ); }
513 double operator () (
sLong Row,
sLong Col)
const {
return( m_z[Row][Col] ); }
514 double * operator [] (
sLong Row)
const {
return( m_z[Row] ); }
515 double * operator [] (
size_t Row)
const {
return( m_z[Row] ); }
516 double * operator [] (
int Row)
const {
return( m_z[Row] ); }
518 CSG_String to_String (
int Width = -1,
int Precision = -1,
bool bScientific =
false,
const SG_Char *Separator = NULL)
const;
521 bool is_Square (
void)
const {
return( m_nx > 0 && m_nx == m_ny ); }
522 bool is_Equal (
const CSG_Matrix &Matrix)
const;
524 bool Assign (
double Scalar);
526 bool Add (
double Scalar);
529 bool Multiply (
double Scalar);
533 bool operator == (
const CSG_Matrix &Matrix)
const;
550 bool Set_Zero (
void);
551 bool Set_Identity (
void);
552 bool Set_Transpose (
void);
553 bool Set_Inverse (
bool bSilent =
true,
int nSubSquare = 0);
555 double Get_Determinant (
void)
const;
557 CSG_Matrix Get_Inverse (
bool bSilent =
true,
int nSubSquare = 0)
const;
567 void _On_Construction (
void);
599 bool Create (
int maxRadius);
605 int Get_nPoints (
int iRadius) {
return( iRadius >= 0 && iRadius < m_maxRadius ? m_nPoints_R[iRadius] : 0 ); }
609 if( iPoint >= 0 && iPoint < m_nPoints )
611 x = m_Points[iPoint].x;
612 y = m_Points[iPoint].y;
614 return( m_Points[iPoint].d );
620 double Get_Point (
int iPoint,
int xOffset,
int yOffset,
int &x,
int &y)
624 if( (d = Get_Point(iPoint, x, y)) >= 0. )
633 double Get_Point (
int iRadius,
int iPoint,
int &x,
int &y)
635 if( iRadius >= 0 && iRadius <= m_maxRadius && iPoint >= 0 && iPoint < m_nPoints_R[iRadius] )
637 x = m_Points_R[iRadius][iPoint].x;
638 y = m_Points_R[iRadius][iPoint].y;
640 return( m_Points_R[iRadius][iPoint].d );
646 double Get_Point (
int iRadius,
int iPoint,
int xOffset,
int yOffset,
int &x,
int &y)
650 if( (d = Get_Point(iRadius, iPoint, x, y)) >= 0. )
662 int m_maxRadius, m_nPoints, *m_nPoints_R;
664 typedef struct SSG_Grid_Radius
672 TSG_Grid_Radius *m_Points, **m_Points_R;
689 static void Initialize (
void);
690 static void Initialize (
unsigned int Value);
692 static double Get_Uniform (
void);
693 static double Get_Uniform (
double min,
double max);
695 static double Get_Gaussian (
double mean,
double stddev);
716 bool Create (
bool bHoldValues =
false);
718 bool Create (
double Mean,
double StdDev,
sLong Count = 1000);
719 bool Create (
const CSG_Vector &Values,
bool bHoldValues =
false);
721 void Invalidate (
void);
722 bool Evaluate (
void);
726 bool Set_Count (
sLong Count);
731 double Get_Minimum (
void) {
if( m_bEvaluated < 1 ) _Evaluate(1);
return( m_Minimum ); }
732 double Get_Maximum (
void) {
if( m_bEvaluated < 1 ) _Evaluate(1);
return( m_Maximum ); }
733 double Get_Range (
void) {
if( m_bEvaluated < 1 ) _Evaluate(1);
return( m_Range ); }
734 double Get_Sum (
void) {
if( m_bEvaluated < 1 ) _Evaluate(1);
return( m_Sum ); }
736 double Get_Mean (
void) {
if( m_bEvaluated < 1 ) _Evaluate(1);
return( m_Mean ); }
737 double Get_Variance (
void) {
if( m_bEvaluated < 1 ) _Evaluate(1);
return( m_Variance ); }
738 double Get_StdDev (
void) {
if( m_bEvaluated < 1 ) _Evaluate(1);
return( m_StdDev ); }
740 double Get_Kurtosis (
void) {
if( m_bEvaluated < 2 ) _Evaluate(2);
return( m_Kurtosis ); }
741 double Get_Skewness (
void) {
if( m_bEvaluated < 2 ) _Evaluate(2);
return( m_Skewness ); }
742 double Get_SkewnessPearson (
void);
744 double Get_Quantile (
double Quantile);
745 double Get_Percentile (
double Percentile);
746 double Get_Median (
void);
747 double Get_Gini (
void);
749 sLong Get_IndexOfMinimum (
void);
750 sLong Get_IndexOfMaximum (
void);
752 sLong Get_nValues_Above (
double Threshold,
bool bEquals =
false);
753 sLong Get_nValues_Below (
double Threshold,
bool bEquals =
false);
757 void Add_Value (
double Value,
double Weight = 1.);
759 double *
Get_Values (
void)
const {
return( (
double *)m_Values.Get_Array() ); }
760 double Get_Value (
sLong i)
const {
return( i >= 0 && i < (
sLong)m_Values.Get_Size() ? Get_Values()[i] : m_Mean ); }
761 double operator [] (
sLong i)
const {
return( i >= 0 && i < (
sLong)m_Values.Get_Size() ? Get_Values()[i] : m_Mean ); }
777 double m_Weights, m_Sum, m_Sum2, m_Minimum, m_Maximum, m_Range, m_Mean, m_Variance, m_StdDev, m_Kurtosis, m_Skewness, m_Gini;
782 void _Evaluate (
int Level = 1);
800 virtual void Create (
bool bWeights =
false) { m_bWeights = bWeights; }
802 int Get_Count (
void)
const {
return( (
int)m_Count.Get_Size() ); }
804 double Get_Weight (
int i)
const {
return( m_bWeights ? m_Weight[i] : m_Count[i] ); }
806 virtual int Get_Majority (
bool bWeighted =
false)
const;
807 virtual int Get_Minority (
bool bWeighted =
false)
const;
812 bool m_bWeights{
false};
827 virtual void Create (
bool bWeights =
false);
829 void operator += (
double Value) { Add_Value(Value); }
830 void Add_Value (
double Value,
double Weight = 1.);
831 double Get_Value (
int Index)
const {
return( m_Value[Index] ); }
832 int Get_Class_Index (
double Value)
const;
833 bool Get_Class (
int Index,
double &Value,
int &Count)
const
835 if( Index < 0 || Index >=
Get_Count() )
return(
false );
837 Count = m_Count[Index];
838 Value = m_Value[Index];
862 virtual void Create (
bool bWeights =
false);
864 void operator += (
const CSG_String &Value) { Add_Value(Value); }
865 void Add_Value (
const CSG_String &Value,
double Weight = 1.);
867 int Get_Class_Index (
const CSG_String &Value)
const;
870 if( Index < 0 || Index >=
Get_Count() )
return(
false );
872 Count = m_Count[Index];
873 Value = m_Value[Index];
909 int Add_Value (
int Value);
910 int Add_Value (
double Value);
913 void operator += (
int Value) { Add_Value(Value); }
914 void operator += (
double Value) { Add_Value(Value); }
915 void operator += (
const CSG_String &Value) { Add_Value(Value); }
919 int Get_Count (
void )
const;
920 int Get_Count (
int iCategory)
const;
922 int asInt (
int iCategory)
const;
923 double asDouble (
int iCategory)
const;
926 int Get_Category (
int Value)
const;
927 int Get_Category (
double Value)
const;
928 int Get_Category (
const CSG_String &Value)
const;
932 Count = Get_Count(iCategory);
933 Value = asInt (iCategory);
935 return( iCategory >= 0 && iCategory < Get_Count() );
940 Count = Get_Count(iCategory);
941 Value = asDouble (iCategory);
943 return( iCategory >= 0 && iCategory < Get_Count() );
948 Count = Get_Count(iCategory);
949 Value = asString (iCategory);
951 return( iCategory >= 0 && iCategory < Get_Count() );
954 int Get_Majority (
void);
962 int Get_Minority (
void);
996 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum);
997 bool Create (
size_t nClasses,
double Minimum,
double Maximum);
999 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
const CSG_Vector &Values ,
size_t maxSamples = 0);
1000 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
const CSG_Vector &Values ,
size_t maxSamples = 0);
1002 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Table *pTable,
int Field,
size_t maxSamples = 0);
1003 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Table *pTable,
int Field,
size_t maxSamples = 0);
1005 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grid *pGrid ,
size_t maxSamples = 0);
1006 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grid *pGrid ,
size_t maxSamples = 0);
1008 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grids *pGrids ,
size_t maxSamples = 0);
1009 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grids *pGrids ,
size_t maxSamples = 0);
1012 void Add_Value (
double Value);
1014 bool Scale_Element_Count (
double Scale);
1020 size_t Get_Element_Count (
void)
const {
return( m_nClasses > 0 ? m_Cumulative[m_nClasses - 1] : 0 ); }
1024 size_t Get_Elements (
size_t i)
const {
return( i < m_nClasses ? m_Elements[i] : 0 ); }
1027 size_t Get_Cumulative (
size_t i)
const {
return( i < m_nClasses ? m_Cumulative[i] : 0 ); }
1029 double Get_Value (
double i)
const {
return( m_nClasses < 1 ? m_Minimum : m_Minimum + i * m_ClassWidth ); }
1031 double Get_Break (
int i)
const {
return( Get_Value((
double)(i)) ); }
1032 double Get_Break (
size_t i)
const {
return( Get_Value((
double)(i)) ); }
1034 double Get_Center (
int i)
const {
return( Get_Value((
double)(i + 0.5)) ); }
1035 double Get_Center (
size_t i)
const {
return( Get_Value((
double)(i + 0.5)) ); }
1040 void operator += (
double Value) { Add_Value(Value); }
1042 size_t operator [] (
int i)
const {
return( Get_Elements(i) ); }
1043 size_t operator [] (
size_t i)
const {
return( Get_Elements(i) ); }
1045 double Get_Quantile (
double Quantile)
const;
1046 double Get_Quantile_Value (
double Value)
const;
1048 double Get_Percentile (
double Percentile)
const;
1049 double Get_Percentile_Value(
double Value)
const;
1056 size_t m_nClasses, m_nMaximum, *m_Elements, *m_Cumulative;
1058 double m_Minimum, m_Maximum, m_ClassWidth;
1063 void _On_Construction (
void);
1065 bool _Create (
size_t nClasses,
double Minimum,
double Maximum);
1067 bool _Update (
sLong nElements);
1086 bool Create (
class CSG_Table *pTable,
int Field,
int nClasses,
int Histogram = 0);
1089 bool Create (
class CSG_Grid *pGrid ,
int nClasses,
int Histogram = 0);
1092 bool Create (
class CSG_Grids *pGrids ,
int nClasses,
int Histogram = 0);
1095 bool Create (
const CSG_Vector &Values ,
int nClasses,
int Histogram = 0);
1100 double operator [] (
int i)
const {
return( m_Breaks[i] ); }
1110 bool _Histogram (
int nClasses);
1112 double _Get_Value (
int i);
1114 bool _Calculate (
int nClasses);
1140 bool Create (
int nFeatures);
1141 bool Destroy (
void);
1143 bool Add_Element (
void);
1144 bool Set_Feature (
sLong iElement,
int iFeature,
double Value);
1146 sLong Get_Cluster (
sLong iElement)
const {
return( iElement >= 0 && iElement < Get_nElements() ? m_Clusters[iElement] : -1 ); }
1148 bool Execute (
int Method,
int nClusters,
int nMaxIterations = 0,
int Initialization = 0);
1156 double Get_SP (
void)
const {
return( m_SP ); }
1159 double Get_Variance (
int iCluster)
const {
return( m_Variance[iCluster] ); }
1160 double Get_Centroid (
int iCluster,
int iFeature)
const {
return( m_Centroid[iCluster][iFeature] ); }
1165 int m_Iteration, m_nFeatures;
1178 bool _Minimum_Distance (
bool bInitialize,
int nMaxIterations);
1180 bool _Hill_Climbing (
bool bInitialize,
int nMaxIterations);
1212 void Create (
int nFeatures);
1213 void Destroy (
void);
1218 bool Train_Clr_Samples (
void);
1220 bool Train (
bool bClr_Samples =
false);
1232 double Get_Class_Mean (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Mean[iFeature] ); }
1233 double Get_Class_Minimum (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Min [iFeature] ); }
1234 double Get_Class_Maximum (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Max [iFeature] ); }
1237 bool Get_Class (
const CSG_Vector &Features,
int &Class,
double &Quality,
int Method);
1240 void Set_Threshold_Distance (
double Value);
1241 double Get_Threshold_Distance (
void);
1243 void Set_Threshold_Angle (
double Value);
1244 double Get_Threshold_Angle (
void);
1246 void Set_Threshold_Probability (
double Value);
1247 double Get_Threshold_Probability (
void);
1249 void Set_Probability_Relative (
bool Value);
1250 bool Get_Probability_Relative (
void);
1252 void Set_WTA (
int Method,
bool bOn);
1253 bool Get_WTA (
int Method);
1255 static CSG_String Get_Name_of_Method (
int Method);
1256 static CSG_String Get_Name_of_Quality (
int Method);
1269 double m_Cov_Det, m_Mean_Spectral;
1283 int m_nFeatures, m_nClasses;
1285 double m_Threshold_Distance, m_Threshold_Probability, m_Threshold_Angle;
1289 CClass **m_pClasses;
1292 void _Get_Binary_Encoding (
const CSG_Vector &Features,
int &Class,
double &Quality);
1293 void _Get_Parallel_Epiped (
const CSG_Vector &Features,
int &Class,
double &Quality);
1294 void _Get_Minimum_Distance (
const CSG_Vector &Features,
int &Class,
double &Quality);
1295 void _Get_Mahalanobis_Distance (
const CSG_Vector &Features,
int &Class,
double &Quality);
1296 void _Get_Maximum_Likelihood (
const CSG_Vector &Features,
int &Class,
double &Quality);
1297 void _Get_Spectral_Angle_Mapping (
const CSG_Vector &Features,
int &Class,
double &Quality);
1298 void _Get_Spectral_Divergence (
const CSG_Vector &Features,
int &Class,
double &Quality);
1299 void _Get_Winner_Takes_All (
const CSG_Vector &Features,
int &Class,
double &Quality);
1314 enum ESG_mRMR_Method
1316 SG_mRMR_Method_MID = 0,
1326 virtual ~CSG_mRMR(
void);
1328 void Destroy (
void);
1335 void Set_Verbose (
bool bOn =
true) { m_bVerbose = bOn; }
1339 bool Set_Data (
CSG_Table &Data,
int ClassField = 0,
double Threshold = -1.);
1340 bool Set_Data (
CSG_Matrix &Data,
int ClassField = 0,
double Threshold = -1.);
1343 bool Get_Selection (
int nFeatures,
int Method);
1345 int Get_Count (
void)
const;
1346 int Get_Index (
int i)
const;
1348 double Get_Score (
int i)
const;
1353 bool m_bDiscretized, m_bVerbose;
1355 long m_nSamples, m_nVars;
1364 bool Get_Memory (
int nVars,
int nSamples);
1366 bool Discretize (
double Threshold);
1368 double Get_MutualInfo (
long v1,
long v2);
1369 double Get_MutualInfo (
double *pab,
long pabhei,
long pabwid);
1371 template <
class T>
double * Get_JointProb (T *img1, T *img2,
long len,
long maxstatenum,
int &nstate1,
int &nstate2);
1372 template <
class T>
void Copy_Vector (T *srcdata,
long len,
int *desdata,
int &nstate);
1375 typedef struct SPool
1383 static int Pool_Compare (
const void *a,
const void *b);
1404 void Destroy (
void);
1406 bool Create (
double *xValues,
double *yValues,
int nValues,
double yA = 1.0e30,
double yB = 1.0e30);
1407 bool Create (
double yA = 1.0e30,
double yB = 1.0e30);
1409 void Add (
double x,
double y);
1412 double Get_xMin (
void)
const {
return( m_x.Get_N() > 0 ? m_x(0 ) : 0. ); }
1413 double Get_xMax (
void)
const {
return( m_x.Get_N() > 0 ? m_x(m_x.Get_Size() - 1) : 0. ); }
1414 double Get_x (
int i)
const {
return( i >= 0 && i < m_x.Get_N() ? m_x(i) : 0. ); }
1415 double Get_y (
int i)
const {
return( i >= 0 && i < m_y.Get_N() ? m_y(i) : 0. ); }
1417 bool Get_Value (
double x,
double &y);
1418 double Get_Value (
double x);
1428 bool _Create (
double yA,
double yB);
1439 bool Destroy (
void);
1446 bool Add_Point (
double x,
double y,
double z) {
return( m_Points.Add( x, y, z) ); }
1451 if( Index >= 0 && Index < m_Points.Get_Count() )
1453 m_Points[Index].x = x;
1454 m_Points[Index].y = y;
1455 m_Points[Index].z = z;
1465 bool Create (
double Regularization = 0.,
bool bSilent =
true);
1467 bool is_Okay (
void) {
return( m_V.Get_N() > 0 ); }
1469 double Get_Value (
double x,
double y);
1480 double _Get_Base_Funtion (
double x);
1481 double _Get_Base_Funtion (
TSG_Point_3D A,
double x,
double y);
1515 static double Get_Norm_P (
double Z);
1516 static double Get_Norm_Z (
double P);
1521 static double Get_Gamma (
double F,
double dfn,
double dfd);
1522 static double Get_Log_Gamma (
double a);
1524 static double Get_T_P (
double T,
int df);
1525 static double Get_T_Z (
double T,
int df);
1526 static double Get_T_Inv (
double p,
int df);
1590 void Destroy (
void);
1592 bool Set_Values (
int nValues,
double *x,
double *y);
1593 bool Add_Values (
double x,
double y);
1595 int Get_Count (
void)
const {
return( (
int)m_x.Get_Size() ); }
1597 double Get_xValue (
int i)
const {
return( i >= 0 && i < Get_Count() ? m_x[i] : 0. ); }
1598 double Get_yValue (
int i)
const {
return( i >= 0 && i < Get_Count() ? m_y[i] : 0. ); }
1601 if( i >= 0 && i < Get_Count() )
1616 double Get_x (
double y)
const;
1622 double Get_y (
double x)
const;
1626 double Get_R (
void)
const {
return( m_R ); }
1627 double Get_R2 (
void)
const {
return( m_R2 ); }
1629 double Get_P (
void)
const {
return( m_P ); }
1632 const SG_Char * asString (
void);
1642 double m_RConst, m_RCoeff, m_R, m_R2, m_R2_Adj, m_P,
m_SE,
1651 double _Y_Transform (
double x);
1652 double _X_Transform (
double y);
1683 void Destroy (
void);
1693 bool Get_Model_Stepwise (
const CSG_Matrix &Samples,
double P_in,
double P_out,
CSG_Strings *pNames = NULL);
1695 bool Get_Model (
void);
1696 bool Get_Model_Forward (
double P_in);
1697 bool Get_Model_Backward (
double P_out);
1698 bool Get_Model_Stepwise (
double P_in,
double P_out);
1700 bool Get_CrossValidation (
int nSubSamples = 0);
1707 double Get_R2 (
void)
const;
1708 double Get_R2_Adj (
void)
const;
1709 double Get_StdError (
void)
const;
1710 double Get_F (
void)
const;
1711 double Get_P (
void)
const;
1712 double Get_CV_RMSE (
void)
const;
1713 double Get_CV_NRMSE (
void)
const;
1714 double Get_CV_R2 (
void)
const;
1715 int Get_CV_nSamples (
void)
const;
1716 int Get_DegFreedom (
void)
const;
1717 int Get_nSamples (
void)
const;
1718 int Get_nPredictors (
void)
const;
1719 int Get_Predictor (
int i)
const {
return( i >= 0 && i < Get_nPredictors() ? m_Predictor[i] : -1 ); }
1721 double Get_RConst (
void)
const;
1728 double Get_T (
int iVariable)
const {
return( Get_Parameter(iVariable,
MLR_VAR_T ) ); }
1731 double Get_Parameter (
int iVariable,
int Parameter)
const;
1736 double Get_Residual (
int iSample)
const;
1737 bool Get_Residual (
int iSample,
double &Residual)
const;
1739 bool Get_Residuals (
CSG_Vector &Residuals)
const;
1755 bool _Initialize (
bool bInclude);
1757 double _Get_F (
int nPredictors,
int nSamples,
double r2_full,
double r2_reduced);
1758 double _Get_P (
int nPredictors,
int nSamples,
double r2_full,
double r2_reduced);
1760 bool _Get_Regression (
const class CSG_Matrix &Samples);
1763 int _Get_Step_Out (
CSG_Matrix &X,
double P_out,
double &R2);
1766 bool _Set_Step_Info (
const CSG_Matrix &X,
double R2_prev,
int iVariable,
bool bIn);
1782 bool Destroy (
void);
1784 bool Add_Sample (
double Weight,
double Dependent,
const CSG_Vector &Predictors);
1789 bool Calculate (
bool bLogistic =
false);
1791 double Get_R2 (
void)
const {
return( m_r2 ); }
1794 double operator [] (
int i)
const {
return( m_b[i] ); }
1801 bool Set_Log_maxIter (
int maxIter );
1802 bool Set_Log_Epsilon (
double Epsilon );
1803 bool Set_Log_Difference (
double Difference);
1806 bool Get_CrossValidation (
int nSubSamples = 0);
1816 int m_Log_maxIter, m_CV_nSamples;
1818 double m_r2, m_Log_Epsilon, m_Log_Difference, m_CV_RMSE, m_CV_NRMSE, m_CV_R2;
1855 bool Destroy (
void);
1857 static CSG_String Get_Help_Operators (
bool bHTML =
true,
const CSG_String Additional[][2] = NULL);
1861 bool Add_Function (
const char *Name,
TSG_Formula_Function_1 Function,
int nParameters,
bool bVarying =
false);
1863 bool Set_Formula (
const CSG_String &Formula);
1866 void Set_Variable (
char Variable,
double Value);
1868 double Get_Value (
void )
const;
1869 double Get_Value (
double x )
const;
1870 double Get_Value (
const CSG_Vector &Values )
const;
1871 double Get_Value (
double *Values,
int nValues)
const;
1872 double Get_Value (
const char *Arguments, ... )
const;
1874 const char * Get_Used_Variables (
void);
1894 typedef struct SSG_Formula
1904 bool m_bError, m_Vars_Used[256];
1906 int m_Error_Position, m_Length;
1908 TSG_Formula m_Formula;
1910 TSG_Function *m_Functions;
1915 const char *m_error;
1919 double m_Parameters[32], *m_ctable;
1922 void _Set_Error (
const CSG_String &Error =
"");
1924 double _Get_Value (
const double *Parameters, TSG_Formula Function)
const;
1926 int _is_Operand (
char c);
1927 int _is_Operand_Code (
char c);
1928 int _is_Number (
char c);
1930 int _Get_Function (
int i,
char *Name,
int *nParameters,
int *bVarying);
1931 int _Get_Function (
const char *Name);
1933 TSG_Formula _Translate (
const char *source,
const char *args,
int *length,
int *error);
1935 char * _i_trans (
char *
function,
char *begin,
char *end);
1936 char * _comp_time (
char *
function,
char *fend,
int npars);
1937 int _max_size (
const char *source);
1938 char * _my_strtok (
char *s);
1965 bool Set_Formula (
const CSG_String &Formula);
1970 bool Init_Parameter (
const SG_Char &Variable,
double Value);
1972 void Clr_Data (
void);
1973 bool Add_Data (
double x,
double y);
1974 void Set_Data (
double *x,
double *y,
int n,
bool bAdd =
false);
1975 void Set_Data (
const CSG_Points &Data ,
bool bAdd =
false);
1986 bool Set_Max_Iterations (
int Iterations);
1988 bool Set_Max_Lambda (
double Lambda);
1991 bool Get_Trend (
double *x,
double *y,
int n,
const CSG_String &Formula);
1994 bool Get_Trend (
void);
2001 double Get_R2 (
void)
const {
return( m_bOkay ? m_ChiSqr_o : 0. ); }
2003 double Get_Value (
double x)
const {
return( m_bOkay ? m_Formula.Get_Value(x) : 0. ); }
2015 bool Destroy (
void);
2017 int Get_Count (
void)
const {
return( (
int)m_Variables.Length() ); }
2034 double m_ChiSqr, m_ChiSqr_o, m_Lambda, m_Lambda_Max;
2043 bool _Fit_Function (
void);
2044 bool _Get_Gaussj (
void);
2047 void _Get_Function (
double &y,
double *dy_da,
double x,
const double *Parameters);
2064 bool Destroy (
void);
2066 bool Set_Order (
int Order = 1);
2068 bool Clr_Data (
void);
2069 bool Set_Data (
double *x,
double *y,
int n,
bool bAdd =
false);
2070 bool Add_Data (
double x,
double y);
2075 bool Get_Trend (
void);
2080 double Get_R2 (
void)
const {
return( m_r2 ); }
2082 double Get_Value (
double x)
const;
2103 #endif // #ifndef HEADER_INCLUDED__SAGA_API__mat_tools_H
double Get_StdError(int iVariable) const
bool Get_Majority(CSG_String &Value, int &Count)
double Get_Max_Lambda(void) const
double Get_RCoeff(int iVariable) const
size_t Get_Cumulative(int i) const
TSG_Regression_Type Get_Type(void) const
sLong Get_Cluster(sLong iElement) const
size_t Get_Cumulative(size_t i) const
int Get_Parameter_Count(void) const
double Get_Data_Y(int i) const
bool Get_Minority(int &Value)
double Get_Class_Minimum(int iClass, int iFeature)
CSG_Simple_Statistics & Get_Data_YStats(void)
bool Get_Class(int Index, double &Value, int &Count) const
int Get_Predictor_Count(void) const
bool Get_Category(int iCategory, CSG_String &Value, int &Count) const
virtual ~CSG_Unique_Value_Statistics(void)
CSG_Matrix m_Samples_Model
const_iterator cend(void) const
int Get_nMembers(int iCluster) const
double * Get_Data(void) const
virtual int Compare(CSG_PriorityQueueItem *pItem)=0
double Get_Point(int iRadius, int iPoint, int xOffset, int yOffset, int &x, int &y)
bool Add_Point(const TSG_Point &p, double z)
double Get_R2_Partial(int iVariable) const
double Get_Sum_Of_Squares(void)
bool Set_Point_Count(int Count)
int Get_Predictor(int i) const
double Get_Data_X(int i) const
sLong Get_NRows(void) const
double Get_y(int i) const
double Get_Variance(void)
double Get_Break(int i) const
const CSG_Vector & Get_RCoeff(void) const
int Get_Count(int i) const
int Get_Count(void) const
double Get_Data_Y(int i) const
virtual bool Get_Value(sLong Index, int iField, CSG_String &Value) const
sLong Get_Index(sLong Position, bool Ascending=true) const
CSG_PriorityQueueItem * Get_Item(size_t i) const
double Get_xVariance(void) const
virtual int Get_Minority(bool bWeighted=false) const
size_t Get_uSize(void) const
size_t Get_Elements(size_t i) const
double Get_R2(void) const
bool Get_Minority(double &Value, int &Count) const
bool Get_Minority(CSG_String &Value, int &Count) const
int Get_Log_maxIter(void) const
int Get_Feature_Count(void)
virtual int Compare(const sLong a, const sLong b)=0
double Get_R2_Partial_Adj(int iVariable) const
const SG_Char * Get_Name(void) const
int Get_Iteration(void) const
double Get_xMax(void) const
double Get_R2(void) const
double Get_yMin(void) const
bool Get_Minority(double &Value, int &Count)
double Get_Break(int i) const
double Get_P(int iVariable) const
double Get_xMean(void) const
double Get_yVariance(void) const
bool Get_Minority(int &Value, int &Count)
double Get_Kurtosis(void)
double Get_R2_Adj(void) const
int Get_Point_Count(void)
bool Get_Minority(CSG_String &Value)
bool Get_Majority(double &Value, int &Count) const
double Get_R2(void) const
double ** Get_Data(void) const
size_t Get_Element_Count(void) const
double Get_ID(int iVariable) const
double Get_Center(int i) const
double Get_Data_YMax(void)
bool Get_Minority(CSG_String &Value, int &Count)
double Get_R2(void) const
double Get_Coefficient(int i) const
sLong Get_NCols(void) const
bool Get_Majority(int &Value)
double Get_x(int i) const
class CSG_Table * Get_Info_Steps(void) const
double Get_Center(size_t i) const
virtual ~CSG_Unique_String_Statistics(void)
double Get_Data_XMax(void)
bool Get_Majority(int &Value, int &Count)
sLong Get_Count(void) const
int Get_Count(void) const
sLong Get_nElements(void) const
double Get_Data_X(int i) const
const CSG_String & Get_Class_ID(int iClass)
double Get_T(int iVariable) const
double Get_RCoeff(int i) const
double * Get_Parameters(void) const
double Get_Weights(void) const
double Get_Log_Difference(void) const
CSG_Unique_Number_Statistics(bool bWeights=false)
double Get_CV_RMSE(void) const
double Get_xMax(void) const
bool Get_Majority(double &Value)
double Get_CV_R2(void) const
bool Get_Majority(double &Value) const
double Get_Break(size_t i) const
bool Get_Values(int i, double &x, double &y) const
int Get_Class_Count(void)
CSG_PriorityQueueItem * Peek(void) const
double Get_Variance(int iCluster) const
double Get_yValue(int i) const
TSG_Regression_Type m_Type
int Get_nCoefficients(void) const
double Get_Data_XMin(void)
int is_Evaluated(void) const
#define SAGA_API_DLL_EXPORT
const_iterator cbegin(void) const
double Get_Class_Maximum(int iClass, int iFeature)
double Get_Constant(void) const
const_iterator end(void) const
virtual ~CSG_Unique_Number_Statistics(void)
int Get_nPoints(int iRadius)
double Get_Skewness(void)
double Get_CV_NRMSE(void) const
int Get_Count(void) const
bool Get_Minority(double &Value)
size_t Get_Class_Count(void) const
bool Get_With_Intercept(void) const
double Get_Value(int Index) const
double Get_Data(sLong x) const
void Set_With_Intercept(bool bOn=true)
double Get_SP(void) const
bool is_Square(void) const
int Get_nFeatures(void) const
sLong Get_Size(void) const
double Get_xMin(void) const
int Get_CV_nSamples(void) const
size_t Get_Size(void) const
bool Get_Minority(double &Value) const
bool Get_Majority(CSG_String &Value, int &Count) const
CSG_Points_3D & Get_Points(void)
double Get_xMin(void) const
double Get_Class_Mean(int iClass, int iFeature)
CSG_PriorityQueueItem * Minimum(void) const
double Get_Weight(int i) const
double * Get_Values(void) const
double Get_Value(sLong i) const
class CSG_Table * m_pSteps
double Get_Coefficient(void) const
bool is_Empty(void) const
bool Get_Majority(double &Value, int &Count)
class CSG_Table * Get_Info_Model(void) const
virtual int Get_Majority(bool bWeighted=false) const
int Get_nClusters(void) const
bool Get_Category(int iCategory, double &Value, int &Count) const
double Get_Centroid(int iCluster, int iFeature) const
bool Get_Majority(CSG_String &Value) const
virtual void Create(bool bWeights=false)
double Get_Point(int iPoint, int &x, int &y)
int Get_Data_Count(void) const
double Get_StdError(void) const
double Get_Value(double x) const
int Get_Data_Count(void) const
CSG_PriorityQueueItem(void)
bool Get_Minority(CSG_String &Value) const
double Get_Data_YMin(void)
const SG_Char * Get_Value(int Index) const
CSG_Unique_Value_Statistics(void)
double Get_Point(int iPoint, int xOffset, int yOffset, int &x, int &y)
const_iterator begin(void) const
bool Get_Class(int Index, CSG_String &Value, int &Count) const
bool Set_Point(int Index, double x, double y, double z)
bool Get_Majority(CSG_String &Value)
double Get_Point(int iRadius, int iPoint, int &x, int &y)
CSG_PriorityQueueItem * Maximum(void) const
double Get_Log_Epsilon(void) const
int Get_Count(void) const
sLong Get_Count(void) const
CSG_Simple_Statistics & Get_Data_XStats(void)
size_t Get_Element_Maximum(void) const
bool Set_Point(int Index, const TSG_Point &p, double z)
bool Get_Category(int iCategory, int &Value, int &Count) const
virtual ~CSG_Index_Compare(void)
int Get_Max_Iterations(void) const
size_t Get_Elements(int i) const
double Get_ChiSquare(void) const
double Get_Value(double i) const
CSG_Unique_String_Statistics(bool bWeights=false)
class CSG_Table * Get_Info_Regression(void) const
double Get_yMax(void) const
sLong Get_Row_Count(void) const
const CSG_Simple_Statistics & Get_Statistics(void) const
double Get_yMean(void) const
bool Add_Point(double x, double y, double z)
int Get_Sample_Count(void) const
double const * const_iterator
int Get_Order(void) const
double Get_xValue(int i) const
SAGA_API_DLL_EXPORT CSG_String operator+(const char *A, const CSG_String &B)