53#ifndef HEADER_INCLUDED__SAGA_API__mat_tools_H
54#define HEADER_INCLUDED__SAGA_API__mat_tools_H
96#define M_PI 3.141592653589793
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.)
108#define M_RAD_TO_DEG (180. / M_PI)
109#define M_DEG_TO_RAD (M_PI / 180.)
112#define M_EULER 2.718281828459045
115#define N_MEGABYTE_BYTES 0x100000
119 #define M_FLT_EPSILON FLT_EPSILON
121 #define M_FLT_EPSILON 1.192092896e-07F
125 #define M_DBL_EPSILON DBL_EPSILON
127 #define M_DBL_EPSILON 2.2204460492503131e-016
131#define M_ALMOST_ZERO (1.e-03)
132#define M_TINY (1.e-20)
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)))
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; }
145#define M_SET_SIGN(x, sign) ((sign) < 0 ? (x < 0 ? x : -x) : (x > 0 ? x : -x))
147#define M_HAS_DECIMALS(x) (x - floor(x) > 0.)
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))
223 bool Create (
sLong nValues,
int *Values,
bool bAscending =
true);
225 CSG_Index (
sLong nValues,
double *Values,
bool bAscending =
true);
226 bool Create (
sLong nValues,
double *Values,
bool bAscending =
true);
240 bool is_Okay (
void)
const {
return( m_nValues > 0 ); }
245 return( Position < 0 || Position >= m_nValues ? -1 : m_Index[Ascending ? Position : m_nValues - 1 - Position] );
250 return( Position < 0 || Position >= m_nValues ? -1 : m_Index[Position] );
258 sLong m_nValues, *m_Index;
261 void _On_Construction (
void);
263 bool _Set_Array (
sLong nValues);
264 bool _Set_Index (CSG_Index_Compare *pCompare);
295 void Create (
size_t maxSize = 256);
299 bool is_Empty (
void)
const {
return( m_nItems == 0 ); }
300 size_t Get_Size (
void)
const {
return( m_nItems ); }
303 void Add (CSG_PriorityQueueItem *pItem);
306 CSG_PriorityQueueItem * Poll (
void);
315 return( m_pLeaf[0]->
Minimum() );
318 return( m_Items[0] );
330 return( m_pLeaf[1]->
Maximum() );
333 return( m_Items[m_nItems - 1] );
342 size_t m_nItems, m_maxSize;
346 CSG_PriorityQueueItem **m_Items;
349 size_t _Insert_Position (CSG_PriorityQueueItem *pItem);
378 bool Add_Row (
double Value = 0.);
383 size_t Get_uSize (
void)
const {
return( m_Array.Get_uSize() ); }
384 int Get_N (
void)
const {
return( (
int)m_Array.Get_Size() ); }
386 double *
Get_Data (
void)
const {
return( (
double *)m_Array.Get_Array() ); }
390 double & operator [] (
size_t x) {
return(
Get_Data()[x] ); }
391 double & operator [] (
int x) {
return(
Get_Data()[x] ); }
393 const double & operator [] (
size_t x)
const {
return(
Get_Data()[x] ); }
394 const double & operator [] (
int x)
const {
return(
Get_Data()[x] ); }
395 operator const double * (void)
const {
return(
Get_Data() ); }
397 CSG_String to_String (
int Width = -1,
int Precision = -1,
bool bScientific =
false,
const SG_Char *Separator = NULL)
const;
400 bool is_Null (
void)
const;
401 bool is_Equal (
const CSG_Vector &Vector)
const;
402 bool is_Collinear (
const CSG_Vector &Vector)
const;
404 bool Assign (
double Scalar);
406 bool Add (
double Scalar);
409 bool Multiply (
double Scalar);
411 bool Multiply_Cross (
const CSG_Vector &Vector);
412 double Multiply_Scalar (
const CSG_Vector &Vector)
const;
413 bool Multiply (
const class CSG_Matrix &Matrix);
433 bool Set_Zero (
void);
434 bool Set_Unity (
void);
436 bool Flip_Values (
void);
438 bool Sort (
bool bAscending =
true);
440 double Get_Length (
void)
const;
443 double Get_Angle (
const CSG_Vector &Vector)
const;
503 bool Add_Col (
const double *Data = NULL);
505 bool Add_Row (
const double *Data = NULL);
522 int Get_NX (
void)
const {
return( (
int)m_nx ); }
523 int Get_NY (
void)
const {
return( (
int)m_ny ); }
527 operator const double ** (void)
const {
return( (
const double **)m_z ); }
530 double operator () (
sLong Row,
sLong Col)
const {
return( m_z[Row][Col] ); }
531 double * operator [] (
sLong Row)
const {
return( m_z[Row] ); }
532 double * operator [] (
size_t Row)
const {
return( m_z[Row] ); }
533 double * operator [] (
int Row)
const {
return( m_z[Row] ); }
535 CSG_String to_String (
int Width = -1,
int Precision = -1,
bool bScientific =
false,
const SG_Char *Separator = NULL)
const;
538 bool is_Square (
void)
const {
return( m_nx > 0 && m_nx == m_ny ); }
539 bool is_Equal (
const CSG_Matrix &Matrix)
const;
541 bool Assign (
double Scalar);
543 bool Add (
double Scalar);
546 bool Multiply (
double Scalar);
550 bool operator == (
const CSG_Matrix &Matrix)
const;
567 bool Set_Zero (
void);
568 bool Set_Identity (
void);
569 bool Set_Transpose (
void);
570 bool Set_Inverse (
bool bSilent =
true,
int nSubSquare = 0);
572 double Get_Determinant (
void)
const;
574 CSG_Matrix Get_Inverse (
bool bSilent =
true,
int nSubSquare = 0)
const;
584 void _On_Construction (
void);
616 bool Create (
int maxRadius);
622 int Get_nPoints (
int iRadius) {
return( iRadius >= 0 && iRadius < m_maxRadius ? m_nPoints_R[iRadius] : 0 ); }
626 if( iPoint >= 0 && iPoint < m_nPoints )
628 x = m_Points[iPoint].x;
629 y = m_Points[iPoint].y;
631 return( m_Points[iPoint].d );
637 double Get_Point (
int iPoint,
int xOffset,
int yOffset,
int &x,
int &y)
641 if( (d =
Get_Point(iPoint, x, y)) >= 0. )
650 double Get_Point (
int iRadius,
int iPoint,
int &x,
int &y)
652 if( iRadius >= 0 && iRadius <= m_maxRadius && iPoint >= 0 && iPoint < m_nPoints_R[iRadius] )
654 x = m_Points_R[iRadius][iPoint].x;
655 y = m_Points_R[iRadius][iPoint].y;
657 return( m_Points_R[iRadius][iPoint].d );
663 double Get_Point (
int iRadius,
int iPoint,
int xOffset,
int yOffset,
int &x,
int &y)
667 if( (d =
Get_Point(iRadius, iPoint, x, y)) >= 0. )
679 int m_maxRadius, m_nPoints, *m_nPoints_R;
681 typedef struct SSG_Grid_Radius
689 TSG_Grid_Radius *m_Points, **m_Points_R;
710 static double Get_Uniform (
double min,
double max);
712 static double Get_Gaussian (
double mean,
double stddev);
733 bool Create (
bool bHoldValues =
false);
735 bool Create (
double Mean,
double StdDev,
sLong Count = 1000);
743 bool Set_Count (
sLong Count);
759 double Get_SkewnessPearson (
void);
761 double Get_Quantile (
double Quantile);
762 double Get_Percentile (
double Percentile);
763 double Get_Median (
void);
764 double Get_Gini (
void);
766 sLong Get_IndexOfMinimum (
void);
767 sLong Get_IndexOfMaximum (
void);
769 sLong Get_nValues_Above (
double Threshold,
bool bEquals =
false);
770 sLong Get_nValues_Below (
double Threshold,
bool bEquals =
false);
774 void Add_Value (
double Value,
double Weight = 1.);
794 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;
823 virtual int Get_Majority (
bool bWeighted =
false)
const;
824 virtual int Get_Minority (
bool bWeighted =
false)
const;
827 virtual bool Get_Majority (
double &Value,
int &Count)
const {
return(
false ); }
829 virtual bool Get_Minority (
double &Value,
int &Count)
const {
return(
false ); }
854 virtual void Create (
bool bWeights =
false);
857 void Add_Value (
double Value,
double Weight = 1.);
858 double Get_Value (
int Index)
const {
return( m_Value[Index] ); }
859 int Get_Class_Index (
double Value)
const;
860 bool Get_Class (
int Index,
double &Value,
int &Count)
const
862 if( Index < 0 || Index >=
Get_Count() )
return(
false );
865 Value = m_Value[Index];
889 virtual void Create (
bool bWeights =
false);
892 void Add_Value (
const CSG_String &Value,
double Weight = 1.);
894 int Get_Class_Index (
const CSG_String &Value)
const;
897 if( Index < 0 || Index >=
Get_Count() )
return(
false );
900 Value = m_Value[Index];
946 int Get_Count (
void )
const;
947 int Get_Count (
int iCategory)
const;
949 int asInt (
int iCategory)
const;
950 double asDouble (
int iCategory)
const;
953 int Get_Category (
int Value)
const;
954 int Get_Category (
double Value)
const;
955 int Get_Category (
const CSG_String &Value)
const;
960 Value =
asInt (iCategory);
962 return( iCategory >= 0 && iCategory <
Get_Count() );
970 return( iCategory >= 0 && iCategory <
Get_Count() );
978 return( iCategory >= 0 && iCategory <
Get_Count() );
981 int Get_Majority (
void);
989 int Get_Minority (
void);
1030 bool Create (
size_t nClasses,
class CSG_Table *pTable,
int Field,
double Minimum = 0.,
double Maximum = 0.,
size_t maxSamples = 0,
int Normalize = -1,
double Scale = 1.);
1055 size_t Get_Elements (
size_t i)
const {
return( i < m_nClasses ? m_Elements [i] : 0 ); }
1058 size_t Get_Cumulative (
size_t i)
const {
return( i < m_nClasses ? m_Cumulative[i] : 0 ); }
1060 double Get_Value (
double i)
const {
return( m_nClasses < 1 ? m_Minimum : m_Minimum + i * m_ClassWidth ); }
1076 double Get_Quantile (
double Quantile)
const;
1077 double Get_Quantile_Value (
double Value)
const;
1079 double Get_Percentile (
double Percentile)
const;
1080 double Get_Percentile_Value(
double Value)
const;
1087 size_t m_nClasses = 0, m_nMaximum = 0, *m_Elements = NULL, *m_Cumulative = NULL;
1089 double m_Minimum = 0., m_Maximum = 0., m_ClassWidth = 1.;
1094 void _On_Construction (
void);
1098 bool _Update (
sLong nElements);
1117 bool Create (
class CSG_Table *pTable,
int Field,
int nClasses,
int Histogram = 0);
1120 bool Create (
class CSG_Grid *pGrid ,
int nClasses,
int Histogram = 0);
1123 bool Create (
class CSG_Grids *pGrids ,
int nClasses,
int Histogram = 0);
1131 double operator [] (
int i)
const {
return( m_Breaks[i] ); }
1141 bool _Histogram (
int nClasses);
1143 double _Get_Value (
int i);
1145 bool _Calculate (
int nClasses);
1171 bool Create (
int nFeatures);
1179 bool Execute (
int Method,
int nClusters,
int nMaxIterations = 0,
int Initialization = 0);
1187 double Get_SP (
void)
const {
return( m_SP ); }
1190 double Get_Variance (
int iCluster)
const {
return( m_Variance[iCluster] ); }
1191 double Get_Centroid (
int iCluster,
int iFeature)
const {
return( m_Centroid[iCluster][iFeature] ); }
1196 int m_Iteration, m_nFeatures;
1209 bool _Minimum_Distance (
bool bInitialize,
int nMaxIterations);
1211 bool _Hill_Climbing (
bool bInitialize,
int nMaxIterations);
1243 void Create (
int nFeatures);
1251 bool Train (
bool bClr_Samples =
false);
1263 double Get_Class_Mean (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Mean[iFeature] ); }
1264 double Get_Class_Minimum (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Min [iFeature] ); }
1265 double Get_Class_Maximum (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Max [iFeature] ); }
1268 bool Get_Class (
const CSG_Vector &Features,
int &Class,
double &Quality,
int Method);
1271 void Set_Threshold_Distance (
double Value);
1272 double Get_Threshold_Distance (
void);
1274 void Set_Threshold_Angle (
double Value);
1275 double Get_Threshold_Angle (
void);
1277 void Set_Threshold_Probability (
double Value);
1278 double Get_Threshold_Probability (
void);
1280 void Set_Probability_Relative (
bool Value);
1281 bool Get_Probability_Relative (
void);
1283 void Set_WTA (
int Method,
bool bOn);
1284 bool Get_WTA (
int Method);
1286 static CSG_String Get_Name_of_Method (
int Method);
1287 static CSG_String Get_Name_of_Quality (
int Method);
1300 double m_Cov_Det, m_Mean_Spectral;
1302 CSG_Vector m_Mean, m_Min, m_Max;
1304 CSG_Matrix m_Cov, m_Cov_Inv, m_Samples;
1314 int m_nFeatures, m_nClasses;
1316 double m_Threshold_Distance, m_Threshold_Probability, m_Threshold_Angle;
1320 CClass **m_pClasses;
1323 void _Get_Binary_Encoding (
const CSG_Vector &Features,
int &Class,
double &Quality);
1324 void _Get_Parallel_Epiped (
const CSG_Vector &Features,
int &Class,
double &Quality);
1325 void _Get_Minimum_Distance (
const CSG_Vector &Features,
int &Class,
double &Quality);
1326 void _Get_Mahalanobis_Distance (
const CSG_Vector &Features,
int &Class,
double &Quality);
1327 void _Get_Maximum_Likelihood (
const CSG_Vector &Features,
int &Class,
double &Quality);
1328 void _Get_Spectral_Angle_Mapping (
const CSG_Vector &Features,
int &Class,
double &Quality);
1329 void _Get_Spectral_Divergence (
const CSG_Vector &Features,
int &Class,
double &Quality);
1330 void _Get_Winner_Takes_All (
const CSG_Vector &Features,
int &Class,
double &Quality);
1347 SG_mRMR_Method_MID = 0,
1357 virtual ~CSG_mRMR(
void);
1359 void Destroy (
void);
1361 static CSG_String Get_Description (
void);
1363 static bool Parameters_Add (
class CSG_Parameters *pParameters,
class CSG_Parameter *pNode = NULL);
1364 static int Parameters_Enable (
class CSG_Parameters *pParameters,
class CSG_Parameter *pParameter);
1366 void Set_Verbose (
bool bOn =
true) { m_bVerbose = bOn; }
1368 bool Set_Data (CSG_Table &Data,
int ClassField,
class CSG_Parameters *pParameters);
1369 bool Set_Data (CSG_Matrix &Data,
int ClassField,
class CSG_Parameters *pParameters);
1370 bool Set_Data (CSG_Table &Data,
int ClassField = 0,
double Threshold = -1.);
1371 bool Set_Data (CSG_Matrix &Data,
int ClassField = 0,
double Threshold = -1.);
1373 bool Get_Selection (
class CSG_Parameters *pParameters);
1374 bool Get_Selection (
int nFeatures,
int Method);
1376 int Get_Count (
void)
const;
1377 int Get_Index (
int i)
const;
1378 CSG_String Get_Name (
int i)
const;
1379 double Get_Score (
int i)
const;
1384 bool m_bDiscretized, m_bVerbose;
1386 long m_nSamples, m_nVars;
1390 CSG_Strings m_VarNames;
1392 class CSG_Table *m_pSelection;
1395 bool Get_Memory (
int nVars,
int nSamples);
1397 bool Discretize (
double Threshold);
1399 double Get_MutualInfo (
long v1,
long v2);
1400 double Get_MutualInfo (
double *pab,
long pabhei,
long pabwid);
1402 template <
class T>
double * Get_JointProb (T *img1, T *img2,
long len,
long maxstatenum,
int &nstate1,
int &nstate2);
1403 template <
class T>
void Copy_Vector (T *srcdata,
long len,
int *desdata,
int &nstate);
1406 typedef struct SPool
1414 static int Pool_Compare (
const void *a,
const void *b);
1437 bool Create (
double *xValues,
double *yValues,
int nValues,
double yA = 1.0e30,
double yB = 1.0e30);
1438 bool Create (
double yA = 1.0e30,
double yB = 1.0e30);
1440 void Add (
double x,
double y);
1445 double Get_x (
int i)
const {
return( i >= 0 && i <
m_x.Get_N() ?
m_x(i) : 0. ); }
1446 double Get_y (
int i)
const {
return( i >= 0 && i <
m_y.Get_N() ?
m_y(i) : 0. ); }
1448 bool Get_Value (
double x,
double &y);
1449 double Get_Value (
double x);
1459 bool _Create (
double yA,
double yB);
1477 bool Add_Point (
double x,
double y,
double z) {
return( m_Points.Add( x, y, z) ); }
1482 if( Index >= 0 && Index < m_Points.Get_Count() )
1484 m_Points[Index].x = x;
1485 m_Points[Index].y = y;
1486 m_Points[Index].z = z;
1496 bool Create (
double Regularization = 0.,
bool bSilent =
true);
1498 bool is_Okay (
void) {
return( m_V.Get_N() > 0 ); }
1500 double Get_Value (
double x,
double y);
1511 double _Get_Base_Funtion (
double x);
1512 double _Get_Base_Funtion (
TSG_Point_3D A,
double x,
double y);
1552 static double Get_Gamma (
double F,
double dfn,
double dfd);
1553 static double Get_Log_Gamma (
double a);
1555 static double Get_T_P (
double T,
int df);
1556 static double Get_T_Z (
double T,
int df);
1557 static double Get_T_Inv (
double p,
int df);
1623 bool Set_Values (
int nValues,
double *x,
double *y);
1647 double Get_x (
double y)
const;
1653 double Get_y (
double x)
const;
1663 const SG_Char * asString (
void);
1724 bool Get_Model_Stepwise (
const CSG_Matrix &Samples,
double P_in,
double P_out,
CSG_Strings *pNames = NULL);
1726 bool Get_Model (
void);
1727 bool Get_Model_Forward (
double P_in);
1728 bool Get_Model_Backward (
double P_out);
1729 bool Get_Model_Stepwise (
double P_in,
double P_out);
1731 bool Get_CrossValidation (
int nSubSamples = 0);
1738 double Get_R2 (
void)
const;
1739 double Get_R2_Adj (
void)
const;
1740 double Get_StdError (
void)
const;
1741 double Get_F (
void)
const;
1742 double Get_P (
void)
const;
1743 double Get_CV_RMSE (
void)
const;
1744 double Get_CV_NRMSE (
void)
const;
1745 double Get_CV_R2 (
void)
const;
1746 int Get_CV_nSamples (
void)
const;
1747 int Get_DegFreedom (
void)
const;
1748 int Get_nSamples (
void)
const;
1749 int Get_nPredictors (
void)
const;
1752 double Get_RConst (
void)
const;
1753 const SG_Char * Get_Name (
int iVariable)
const;
1762 double Get_Parameter (
int iVariable,
int Parameter)
const;
1764 double Get_Value (
const CSG_Vector &Predictors)
const;
1765 bool Get_Value (
const CSG_Vector &Predictors,
double &Value)
const;
1767 double Get_Residual (
int iSample)
const;
1768 bool Get_Residual (
int iSample,
double &Residual)
const;
1770 bool Get_Residuals (
CSG_Vector &Residuals)
const;
1788 double _Get_F (
int nPredictors,
int nSamples,
double r2_full,
double r2_reduced);
1789 double _Get_P (
int nPredictors,
int nSamples,
double r2_full,
double r2_reduced);
1820 bool Calculate (
bool bLogistic =
false);
1822 double Get_R2 (
void)
const {
return( m_r2 ); }
1825 double operator [] (
int i)
const {
return( m_b[i] ); }
1832 bool Set_Log_maxIter (
int maxIter );
1833 bool Set_Log_Epsilon (
double Epsilon );
1834 bool Set_Log_Difference (
double Difference);
1837 bool Get_CrossValidation (
int nSubSamples = 0);
1847 int m_Log_maxIter, m_CV_nSamples;
1849 double m_r2, m_Log_Epsilon, m_Log_Difference, m_CV_RMSE, m_CV_NRMSE, m_CV_R2;
1897 void Set_Variable (
char Variable,
double Value);
1899 double Get_Value (
void )
const;
1900 double Get_Value (
double x )
const;
1901 double Get_Value (
const CSG_Vector &Values )
const;
1902 double Get_Value (
double *Values,
int nValues)
const;
1903 double Get_Value (
const char *Arguments, ... )
const;
1905 const char * Get_Used_Variables (
void);
1925 typedef struct SSG_Formula
1935 bool m_bError, m_Vars_Used[256];
1937 int m_Error_Position, m_Length;
1939 TSG_Formula m_Formula;
1941 TSG_Function *m_Functions;
1946 const char *m_error;
1950 double m_Parameters[32], *m_ctable;
1953 void _Set_Error (
const CSG_String &Error =
"");
1955 double _Get_Value (
const double *Parameters, TSG_Formula Function)
const;
1957 int _is_Operand (
char c);
1958 int _is_Operand_Code (
char c);
1959 int _is_Number (
char c);
1961 int _Get_Function (
int i,
char *Name,
int *nParameters,
int *bVarying);
1962 int _Get_Function (
const char *Name);
1964 TSG_Formula _Translate (
const char *source,
const char *args,
int *length,
int *error);
1966 char * _i_trans (
char *function,
char *begin,
char *end);
1967 char * _comp_time (
char *function,
char *fend,
int npars);
1968 int _max_size (
const char *source);
1969 char * _my_strtok (
char *s);
2001 bool Init_Parameter (
const SG_Char &Variable,
double Value);
2003 void Clr_Data (
void);
2004 bool Add_Data (
double x,
double y);
2005 void Set_Data (
double *x,
double *y,
int n,
bool bAdd =
false);
2006 void Set_Data (
const CSG_Points &Data ,
bool bAdd =
false);
2017 bool Set_Max_Iterations (
int Iterations);
2019 bool Set_Max_Lambda (
double Lambda);
2022 bool Get_Trend (
double *x,
double *y,
int n,
const CSG_String &Formula);
2025 bool Get_Trend (
void);
2032 double Get_R2 (
void)
const {
return( m_bOkay ? m_ChiSqr_o : 0. ); }
2034 double Get_Value (
double x)
const {
return( m_bOkay ? m_Formula.Get_Value(x) : 0. ); }
2045 bool Create (
const CSG_String &Variables);
2046 bool Destroy (
void);
2048 int Get_Count (
void)
const {
return( (
int)m_Variables.Length() ); }
2051 CSG_String m_Variables;
2053 CSG_Vector m_A, m_Atry, m_dA, m_dA2, m_Beta;
2055 CSG_Matrix m_Alpha, m_Covar;
2065 double m_ChiSqr, m_ChiSqr_o, m_Lambda, m_Lambda_Max;
2069 CSG_Simple_Statistics m_Data[2];
2071 CSG_Formula m_Formula;
2074 bool _Fit_Function (
void);
2075 bool _Get_Gaussj (
void);
2076 bool _Get_mrqcof (CSG_Vector &Parameters, CSG_Matrix &Alpha, CSG_Vector &Beta);
2078 void _Get_Function (
double &y,
double *dy_da,
double x,
const double *Parameters);
2100 bool Set_Data (
double *x,
double *y,
int n,
bool bAdd =
false);
2101 bool Add_Data (
double x,
double y);
2106 bool Get_Trend (
void);
2111 double Get_R2 (
void)
const {
return( m_r2 ); }
2113 double Get_Value (
double x)
const;
#define SAGA_API_DLL_EXPORT
SAGA_API_DLL_EXPORT CSG_String operator+(const char *A, const CSG_String &B)
void Create(TSG_Data_Type Type=SG_DATATYPE_String)
bool Get_Majority(CSG_String &Value, int &Count)
bool Get_Minority(int &Value, int &Count)
bool Get_Majority(int &Value, int &Count)
bool Get_Minority(double &Value)
bool Get_Category(int iCategory, int &Value, int &Count) const
int Get_Category(int Value) const
bool Get_Majority(CSG_String &Value)
bool Get_Minority(CSG_String &Value)
bool Get_Category(int iCategory, double &Value, int &Count) const
bool Get_Minority(int &Value)
bool Get_Majority(double &Value, int &Count)
bool Get_Majority(double &Value)
int asInt(int iCategory) const
double asDouble(int iCategory) const
bool Get_Minority(CSG_String &Value, int &Count)
bool Get_Minority(double &Value, int &Count)
int Get_Count(void) const
CSG_Category_Statistics(TSG_Data_Type Type=SG_DATATYPE_String)
bool Get_Category(int iCategory, CSG_String &Value, int &Count) const
CSG_String asString(int iCategory) const
TSG_Data_Type Get_Category_Type(void) const
bool Get_Majority(int &Value)
CSG_Classifier_Supervised(void)
void Create(int nFeatures)
int Get_Class_Count(void)
double Get_Class_Minimum(int iClass, int iFeature)
int Get_Feature_Count(void)
bool Add_Class(const CSG_String &Class_ID, const CSG_Vector &Mean, const CSG_Vector &Min, const CSG_Vector &Max, const CSG_Matrix &Cov)
bool Train(bool bClr_Samples=false)
const CSG_String & Get_Class_ID(int iClass)
bool Train_Add_Sample(const CSG_String &Class_ID, const CSG_Vector &Features)
bool Train_Clr_Samples(void)
bool Save(const CSG_String &File, const SG_Char *Feature_Info=NULL)
double Get_Class_Mean(int iClass, int iFeature)
bool Load(const CSG_String &File)
double Get_Class_Maximum(int iClass, int iFeature)
bool Create(int nFeatures)
int Get_nClusters(void) const
int Get_nFeatures(void) const
double Get_SP(void) const
sLong Get_Cluster(sLong iElement) const
double Get_Centroid(int iCluster, int iFeature) const
int Get_nMembers(int iCluster) const
double Get_Variance(int iCluster) const
bool Set_Feature(sLong iElement, int iFeature, double Value)
sLong Get_nElements(void) const
int Get_Iteration(void) const
CSG_Cluster_Analysis(void)
int Get_nPoints(int iRadius)
CSG_Grid_Radius(int maxRadius=0)
double Get_Point(int iRadius, int iPoint, int xOffset, int yOffset, int &x, int &y)
double Get_Point(int iRadius, int iPoint, int &x, int &y)
double Get_Point(int iPoint, int &x, int &y)
double Get_Point(int iPoint, int xOffset, int yOffset, int &x, int &y)
bool Create(int maxRadius)
size_t Get_Elements(size_t i) const
size_t Get_Element_Maximum(void) const
bool Scale_Element_Count(double Scale)
const CSG_Simple_Statistics & Get_Statistics(void) const
double Get_Break(size_t i) const
double Get_Center(int i) const
void Add_Value(double Value)
double Get_Value(double i) const
size_t Get_Class_Count(void) const
double Get_Center(size_t i) const
size_t Get_Cumulative(int i) const
bool Create(const CSG_Histogram &Histogram)
size_t Get_Cumulative(size_t i) const
size_t Get_Elements(int i) const
bool Add_Histogram(const CSG_Histogram &Histogram)
double Get_Break(int i) const
size_t Get_Element_Count(void) const
virtual ~CSG_Index_Compare(void)
virtual int Compare(const sLong a, const sLong b)=0
sLong Get_Index(sLong Position, bool Ascending=true) const
bool Del_Entry(sLong Position=-1)
void Show_Progress(bool bProgress=true)
sLong Get_Count(void) const
bool Create(sLong nValues, CSG_Index_Compare &Compare)
bool Add_Entry(sLong Position=-1)
sLong Get_NRows(void) const
double ** Get_Data(void) const
bool Del_Rows(sLong nRows)
bool Add_Row(const double *Data=NULL)
bool Ins_Row(sLong Row, const double *Data=NULL)
sLong Get_NCols(void) const
bool Set_Rows(sLong nRows)
bool Create(const CSG_Matrix &Matrix)
bool Set_Size(sLong nRows, sLong nCols)
bool Set_Cols(sLong nCols)
bool Ins_Col(sLong Col, const double *Data=NULL)
CSG_Vector Get_Col(sLong Col) const
bool is_Square(void) const
bool Del_Cols(sLong nCols)
bool Add_Rows(sLong nRows)
bool Set_Col(sLong Col, const double *Data)
bool Add_Cols(sLong nCols)
bool Add_Col(const double *Data=NULL)
bool Set_Row(sLong Row, const double *Data)
CSG_Vector Get_Row(sLong Row) const
bool Create(class CSG_Table *pTable, int Field, int nClasses, int Histogram=0)
int Get_Count(void) const
double Get_Break(int i) const
virtual int Compare(CSG_PriorityQueueItem *pItem)=0
CSG_PriorityQueueItem(void)
size_t Get_Size(void) const
void Create(size_t maxSize=256)
CSG_PriorityQueueItem * Get_Item(size_t i) const
CSG_PriorityQueueItem * Minimum(void) const
CSG_PriorityQueue(size_t maxSize=256)
CSG_PriorityQueueItem * Peek(void) const
CSG_PriorityQueueItem * Maximum(void) const
bool is_Empty(void) const
static double Get_Gaussian(double mean, double stddev)
static void Initialize(void)
static double Get_Uniform(void)
CSG_Regression_Multiple(bool bIntercept=true)
class CSG_Table * Get_Info_Steps(void) const
class CSG_Table * m_pModel
double _Get_P(int nPredictors, int nSamples, double r2_full, double r2_reduced)
double Get_T(int iVariable) const
double Get_Parameter(int iVariable, int Parameter) const
class CSG_Table * Get_Info_Regression(void) const
double Get_StdError(int iVariable) const
CSG_Matrix m_Samples_Model
bool _Set_Step_Info(const CSG_Matrix &X)
int Get_nPredictors(void) const
int _Get_Step_Out(CSG_Matrix &X, double P_out, double &R2)
void Set_With_Intercept(bool bOn=true)
double Get_RCoeff(int iVariable) const
double Get_R2_Partial(int iVariable) const
int Get_Predictor(int i) const
bool Set_Data(const CSG_Matrix &Samples, CSG_Strings *pNames=NULL)
double Get_P(int iVariable) const
double Get_ID(int iVariable) const
bool _Initialize(bool bInclude)
int _Get_Step_In(CSG_Matrix &X, double P_in, double &R2, const CSG_Matrix &Samples)
double Get_R2_Partial_Adj(int iVariable) const
bool _Get_Regression(const class CSG_Matrix &Samples)
bool Get_With_Intercept(void) const
class CSG_Table * m_pSteps
double _Get_F(int nPredictors, int nSamples, double r2_full, double r2_reduced)
class CSG_Table * Get_Info_Model(void) const
class CSG_Table * m_pRegression
double Get_R2(void) const
int Get_Log_maxIter(void) const
double Get_CV_R2(void) const
double Get_Log_Epsilon(void) const
int Get_Predictor_Count(void) const
double Get_Log_Difference(void) const
const CSG_Vector & Get_RCoeff(void) const
CSG_Regression_Weighted(void)
double Get_RCoeff(int i) const
double Get_CV_RMSE(void) const
double Get_CV_NRMSE(void) const
int Get_CV_nSamples(void) const
int Get_Sample_Count(void) const
bool Add_Sample(double Weight, double Dependent, const CSG_Vector &Predictors)
double _X_Transform(double y)
TSG_Regression_Type Get_Type(void) const
double Get_xValue(int i) const
double Get_Coefficient(void) const
bool Set_Values(int nValues, double *x, double *y)
double _Y_Transform(double x)
double Get_Constant(void) const
double Get_R2(void) const
bool Add_Values(double x, double y)
double Get_yValue(int i) const
TSG_Regression_Type m_Type
int Get_Count(void) const
double Get_xMin(void) const
double Get_R2_Adj(void) const
bool Get_Values(int i, double &x, double &y) const
double Get_StdError(void) const
double Get_yMean(void) const
double Get_xVariance(void) const
double Get_xMean(void) const
double Get_yMin(void) const
double Get_xMax(void) const
double Get_yMax(void) const
double Get_yVariance(void) const
void Add(const CSG_Simple_Statistics &Statistics)
double Get_Value(sLong i) const
CSG_Simple_Statistics(void)
double Get_Weights(void) const
int is_Evaluated(void) const
double * Get_Values(void) const
double Get_Sum_Of_Squares(void)
void _Evaluate(int Level=1)
double Get_Kurtosis(void)
bool Create(bool bHoldValues=false)
double Get_Skewness(void)
sLong Get_Count(void) const
double Get_Variance(void)
void Add_Value(double Value, double Weight=1.)
double Get_y(int i) const
int Get_Count(void) const
double Get_xMin(void) const
double Get_xMax(void) const
double Get_x(int i) const
bool Create(double *xValues, double *yValues, int nValues, double yA=1.0e30, double yB=1.0e30)
void Add(double x, double y)
bool _Create(double yA, double yB)
static double Get_Norm_P(double Z)
static double Get_F_Inverse(double alpha, int dfn, int dfd, TSG_Test_Distribution_Type Type=TESTDIST_TYPE_Right)
static double Get_F_Tail_from_R2(double R2, int nPredictors, int nSamples, TSG_Test_Distribution_Type Type=TESTDIST_TYPE_Right)
static double Get_T_Tail(double T, int df, TSG_Test_Distribution_Type Type=TESTDIST_TYPE_Right)
static double Get_F_Tail(double F, int dfn, int dfd, TSG_Test_Distribution_Type Type=TESTDIST_TYPE_Right)
static double Get_Norm_Z(double P)
static double Get_T_Inverse(double alpha, int df, TSG_Test_Distribution_Type Type=TESTDIST_TYPE_Right)
bool Set_Point_Count(int Count)
int Get_Point_Count(void)
CSG_Thin_Plate_Spline(void)
bool Set_Point(int Index, double x, double y, double z)
CSG_Points_3D & Get_Points(void)
bool Add_Point(double x, double y, double z)
bool Set_Point(int Index, const TSG_Point &p, double z)
bool Add_Point(const TSG_Point &p, double z)
bool Add_Data(double x, double y)
double Get_Data_Y(int i) const
bool Set_Data(double *x, double *y, int n, bool bAdd=false)
double Get_Coefficient(int i) const
int Get_nCoefficients(void) const
bool Set_Order(int Order=1)
int Get_Data_Count(void) const
double Get_R2(void) const
int Get_Order(void) const
double Get_Data_X(int i) const
double Get_Data_X(int i) const
double Get_Data_XMin(void)
double Get_ChiSquare(void) const
int Get_Parameter_Count(void) const
CSG_Simple_Statistics & Get_Data_YStats(void)
bool Set_Formula(const CSG_String &Formula)
int Get_Data_Count(void) const
double Get_R2(void) const
double Get_Data_YMin(void)
double Get_Data_XMax(void)
double Get_Data_YMax(void)
CSG_Simple_Statistics & Get_Data_XStats(void)
double * Get_Parameters(void) const
double Get_Value(double x) const
double Get_Data_Y(int i) const
double Get_Max_Lambda(void) const
CSG_String Get_Formula(int Type=SG_TREND_STRING_Complete)
int Get_Max_Iterations(void) const
void Add_Value(double Value, double Weight=1.)
virtual void Create(bool bWeights=false)
virtual bool Get_Minority(double &Value) const
CSG_Unique_Number_Statistics(bool bWeights=false)
virtual bool Get_Majority(double &Value, int &Count) const
virtual bool Get_Minority(double &Value, int &Count) const
virtual bool Get_Majority(double &Value) const
virtual ~CSG_Unique_Number_Statistics(void)
double Get_Value(int Index) const
bool Get_Class(int Index, double &Value, int &Count) const
void Add_Value(const CSG_String &Value, double Weight=1.)
bool Get_Class(int Index, CSG_String &Value, int &Count) const
virtual void Create(bool bWeights=false)
virtual bool Get_Minority(CSG_String &Value, int &Count) const
const SG_Char * Get_Value(int Index) const
virtual ~CSG_Unique_String_Statistics(void)
virtual bool Get_Minority(CSG_String &Value) const
virtual bool Get_Majority(CSG_String &Value, int &Count) const
virtual bool Get_Majority(CSG_String &Value) const
CSG_Unique_String_Statistics(bool bWeights=false)
virtual bool Get_Majority(double &Value) const
virtual bool Get_Majority(CSG_String &Value, int &Count) const
virtual bool Get_Minority(double &Value) const
CSG_Unique_Value_Statistics(void)
double Get_Weight(int i) const
virtual bool Get_Majority(CSG_String &Value) const
virtual bool Get_Minority(double &Value, int &Count) const
virtual bool Get_Minority(CSG_String &Value, int &Count) const
virtual bool Get_Majority(double &Value, int &Count) const
virtual int Get_Minority(bool bWeighted=false) const
virtual void Create(bool bWeights=false)
virtual bool Get_Minority(CSG_String &Value) const
int Get_Count(int i) const
virtual ~CSG_Unique_Value_Statistics(void)
int Get_Count(void) const
virtual int Get_Majority(bool bWeighted=false) const
size_t Get_uSize(void) const
bool Add_Rows(sLong nRows)
double const * const_iterator
bool Add_Row(double Value=0.)
bool Create(const CSG_Vector &Vector)
bool Del_Row(sLong Row=-1)
bool Set_Rows(sLong nRows)
double Get_Data(sLong x) const
const_iterator cend(void) const
sLong Get_Size(void) const
const_iterator begin(void) const
const_iterator cbegin(void) const
bool is_Equal(const CSG_Vector &Vector) const
sLong Get_Row_Count(void) const
double * Get_Data(void) const
const_iterator end(void) const
bool Del_Rows(sLong nRows)
CSG_Vector operator*(double Scalar, const CSG_Vector &Vector)