 |
SAGA API
v9.7
|
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
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);
233 void Show_Progress (
bool bProgress =
true);
235 bool Add_Entry (
sLong Position = -1);
236 bool Del_Entry (
sLong Position = -1);
238 bool is_Okay (
void)
const {
return( m_nValues > 0 ); }
243 return( Position < 0 || Position >= m_nValues ? -1 : m_Index[Ascending ? Position : m_nValues - 1 - Position] );
248 return( Position < 0 || Position >= m_nValues ? -1 : m_Index[Position] );
256 sLong m_nValues, *m_Index;
259 void _On_Construction (
void);
261 bool _Set_Array (
sLong nValues);
262 bool _Set_Index (CSG_Index_Compare *pCompare);
293 void Create (
size_t maxSize = 256);
297 bool is_Empty (
void)
const {
return( m_nItems == 0 ); }
298 size_t Get_Size (
void)
const {
return( m_nItems ); }
301 void Add (CSG_PriorityQueueItem *pItem);
304 CSG_PriorityQueueItem * Poll (
void);
313 return( m_pLeaf[0]->Minimum() );
316 return( m_Items[0] );
328 return( m_pLeaf[1]->Maximum() );
331 return( m_Items[m_nItems - 1] );
340 size_t m_nItems, m_maxSize;
344 CSG_PriorityQueueItem **m_Items;
347 size_t _Insert_Position (CSG_PriorityQueueItem *pItem);
369 bool Create (
sLong n,
const double *Data = NULL);
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);
381 size_t Get_uSize (
void)
const {
return( m_Array.Get_uSize() ); }
382 int Get_N (
void)
const {
return( (
int)m_Array.Get_Size() ); }
384 double *
Get_Data (
void)
const {
return( (
double *)m_Array.Get_Array() ); }
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() ); }
395 CSG_String to_String (
int Width = -1,
int Precision = -1,
bool bScientific =
false,
const SG_Char *Separator = NULL)
const;
398 bool is_Null (
void)
const;
399 bool is_Equal (
const CSG_Vector &Vector)
const;
400 bool is_Collinear (
const CSG_Vector &Vector)
const;
402 bool Assign (
double Scalar);
404 bool Add (
double Scalar);
407 bool Multiply (
double Scalar);
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);
413 bool operator == (
const CSG_Vector &Vector)
const {
return( is_Equal(Vector) ); }
414 bool operator != (
const CSG_Vector &Vector)
const {
return( !is_Equal(Vector) ); }
431 bool Set_Zero (
void);
432 bool Set_Unity (
void);
434 bool Flip_Values (
void);
436 bool Sort (
bool bAscending =
true);
438 double Get_Length (
void)
const;
441 double Get_Angle (
const CSG_Vector &Vector)
const;
487 bool Create (
sLong nCols,
sLong nRows,
const double *Data = NULL);
490 bool Create (
sLong nCols,
sLong nRows,
const double **Data);
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);
503 bool Add_Row (
const double *Data = NULL);
505 bool Ins_Col (
sLong Col,
const double *Data = NULL);
507 bool Ins_Row (
sLong Row,
const double *Data = NULL);
509 bool Set_Col (
sLong Col,
const double *Data);
512 bool Set_Row (
sLong Row,
const double *Data);
515 bool Del_Col (
sLong Col);
516 bool Del_Row (
sLong Row);
520 int Get_NX (
void)
const {
return( (
int)m_nx ); }
521 int Get_NY (
void)
const {
return( (
int)m_ny ); }
525 operator const double ** (void)
const {
return( (
const double **)m_z ); }
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] ); }
533 CSG_String to_String (
int Width = -1,
int Precision = -1,
bool bScientific =
false,
const SG_Char *Separator = NULL)
const;
536 bool is_Square (
void)
const {
return( m_nx > 0 && m_nx == m_ny ); }
537 bool is_Equal (
const CSG_Matrix &Matrix)
const;
539 bool Assign (
double Scalar);
541 bool Add (
double Scalar);
544 bool Multiply (
double Scalar);
548 bool operator == (
const CSG_Matrix &Matrix)
const;
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);
570 double Get_Determinant (
void)
const;
572 CSG_Matrix Get_Inverse (
bool bSilent =
true,
int nSubSquare = 0)
const;
582 void _On_Construction (
void);
614 bool Create (
int maxRadius);
620 int Get_nPoints (
int iRadius) {
return( iRadius >= 0 && iRadius < m_maxRadius ? m_nPoints_R[iRadius] : 0 ); }
624 if( iPoint >= 0 && iPoint < m_nPoints )
626 x = m_Points[iPoint].x;
627 y = m_Points[iPoint].y;
629 return( m_Points[iPoint].d );
635 double Get_Point (
int iPoint,
int xOffset,
int yOffset,
int &x,
int &y)
639 if( (d = Get_Point(iPoint, x, y)) >= 0. )
648 double Get_Point (
int iRadius,
int iPoint,
int &x,
int &y)
650 if( iRadius >= 0 && iRadius <= m_maxRadius && iPoint >= 0 && iPoint < m_nPoints_R[iRadius] )
652 x = m_Points_R[iRadius][iPoint].x;
653 y = m_Points_R[iRadius][iPoint].y;
655 return( m_Points_R[iRadius][iPoint].d );
661 double Get_Point (
int iRadius,
int iPoint,
int xOffset,
int yOffset,
int &x,
int &y)
665 if( (d = Get_Point(iRadius, iPoint, x, y)) >= 0. )
677 int m_maxRadius, m_nPoints, *m_nPoints_R;
679 typedef struct SSG_Grid_Radius
687 TSG_Grid_Radius *m_Points, **m_Points_R;
704 static void Initialize (
void);
705 static void Initialize (
unsigned int Value);
707 static double Get_Uniform (
void);
708 static double Get_Uniform (
double min,
double max);
710 static double Get_Gaussian (
double mean,
double stddev);
731 bool Create (
bool bHoldValues =
false);
733 bool Create (
double Mean,
double StdDev,
sLong Count = 1000);
734 bool Create (
const CSG_Vector &Values,
bool bHoldValues =
false);
736 void Invalidate (
void);
737 bool Evaluate (
void);
741 bool Set_Count (
sLong Count);
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 ); }
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 ); }
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);
759 double Get_Quantile (
double Quantile);
760 double Get_Percentile (
double Percentile);
761 double Get_Median (
void);
762 double Get_Gini (
void);
764 sLong Get_IndexOfMinimum (
void);
765 sLong Get_IndexOfMaximum (
void);
767 sLong Get_nValues_Above (
double Threshold,
bool bEquals =
false);
768 sLong Get_nValues_Below (
double Threshold,
bool bEquals =
false);
772 void Add_Value (
double Value,
double Weight = 1.);
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 ); }
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;
797 void _Evaluate (
int Level = 1);
815 virtual void Create (
bool bWeights =
false) { m_bWeights = bWeights; }
817 int Get_Count (
void)
const {
return( (
int)m_Count.Get_Size() ); }
819 double Get_Weight (
int i)
const {
return( m_bWeights ? m_Weight[i] : m_Count[i] ); }
821 virtual int Get_Majority (
bool bWeighted =
false)
const;
822 virtual int Get_Minority (
bool bWeighted =
false)
const;
825 virtual bool Get_Majority (
double &Value,
int &Count)
const {
return(
false ); }
827 virtual bool Get_Minority (
double &Value,
int &Count)
const {
return(
false ); }
837 bool m_bWeights{
false};
852 virtual void Create (
bool bWeights =
false);
854 void operator += (
double Value) { Add_Value(Value); }
855 void Add_Value (
double Value,
double Weight = 1.);
856 double Get_Value (
int Index)
const {
return( m_Value[Index] ); }
857 int Get_Class_Index (
double Value)
const;
858 bool Get_Class (
int Index,
double &Value,
int &Count)
const
860 if( Index < 0 || Index >=
Get_Count() )
return(
false );
862 Count = m_Count[Index];
863 Value = m_Value[Index];
887 virtual void Create (
bool bWeights =
false);
889 void operator += (
const CSG_String &Value) { Add_Value(Value); }
890 void Add_Value (
const CSG_String &Value,
double Weight = 1.);
892 int Get_Class_Index (
const CSG_String &Value)
const;
895 if( Index < 0 || Index >=
Get_Count() )
return(
false );
897 Count = m_Count[Index];
898 Value = m_Value[Index];
934 int Add_Value (
int Value);
935 int Add_Value (
double Value);
938 void operator += (
int Value) { Add_Value(Value); }
939 void operator += (
double Value) { Add_Value(Value); }
940 void operator += (
const CSG_String &Value) { Add_Value(Value); }
944 int Get_Count (
void )
const;
945 int Get_Count (
int iCategory)
const;
947 int asInt (
int iCategory)
const;
948 double asDouble (
int iCategory)
const;
951 int Get_Category (
int Value)
const;
952 int Get_Category (
double Value)
const;
953 int Get_Category (
const CSG_String &Value)
const;
957 Count = Get_Count(iCategory);
958 Value = asInt (iCategory);
960 return( iCategory >= 0 && iCategory < Get_Count() );
965 Count = Get_Count(iCategory);
966 Value = asDouble (iCategory);
968 return( iCategory >= 0 && iCategory < Get_Count() );
973 Count = Get_Count(iCategory);
974 Value = asString (iCategory);
976 return( iCategory >= 0 && iCategory < Get_Count() );
979 int Get_Majority (
void);
987 int Get_Minority (
void);
1016 bool Destroy (
void);
1021 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum);
1022 bool Create (
size_t nClasses,
double Minimum,
double Maximum);
1024 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
const CSG_Vector &Values ,
size_t maxSamples = 0);
1025 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
const CSG_Vector &Values ,
size_t maxSamples = 0);
1027 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Table *pTable,
int Field,
size_t maxSamples = 0);
1028 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Table *pTable,
int Field,
size_t maxSamples = 0);
1030 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grid *pGrid ,
size_t maxSamples = 0);
1031 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grid *pGrid ,
size_t maxSamples = 0);
1033 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grids *pGrids ,
size_t maxSamples = 0);
1034 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grids *pGrids ,
size_t maxSamples = 0);
1037 void Add_Value (
double Value);
1039 bool Scale_Element_Count (
double Scale);
1045 size_t Get_Element_Count (
void)
const {
return( m_nClasses > 0 ? m_Cumulative[m_nClasses - 1] : 0 ); }
1049 size_t Get_Elements (
size_t i)
const {
return( i < m_nClasses ? m_Elements[i] : 0 ); }
1052 size_t Get_Cumulative (
size_t i)
const {
return( i < m_nClasses ? m_Cumulative[i] : 0 ); }
1054 double Get_Value (
double i)
const {
return( m_nClasses < 1 ? m_Minimum : m_Minimum + i * m_ClassWidth ); }
1056 double Get_Break (
int i)
const {
return( Get_Value((
double)(i)) ); }
1057 double Get_Break (
size_t i)
const {
return( Get_Value((
double)(i)) ); }
1059 double Get_Center (
int i)
const {
return( Get_Value((
double)(i + 0.5)) ); }
1060 double Get_Center (
size_t i)
const {
return( Get_Value((
double)(i + 0.5)) ); }
1065 void operator += (
double Value) { Add_Value(Value); }
1067 size_t operator [] (
int i)
const {
return( Get_Elements(i) ); }
1068 size_t operator [] (
size_t i)
const {
return( Get_Elements(i) ); }
1070 double Get_Quantile (
double Quantile)
const;
1071 double Get_Quantile_Value (
double Value)
const;
1073 double Get_Percentile (
double Percentile)
const;
1074 double Get_Percentile_Value(
double Value)
const;
1081 size_t m_nClasses, m_nMaximum, *m_Elements, *m_Cumulative;
1083 double m_Minimum, m_Maximum, m_ClassWidth;
1088 void _On_Construction (
void);
1090 bool _Create (
size_t nClasses,
double Minimum,
double Maximum);
1092 bool _Update (
sLong nElements);
1111 bool Create (
class CSG_Table *pTable,
int Field,
int nClasses,
int Histogram = 0);
1114 bool Create (
class CSG_Grid *pGrid ,
int nClasses,
int Histogram = 0);
1117 bool Create (
class CSG_Grids *pGrids ,
int nClasses,
int Histogram = 0);
1120 bool Create (
const CSG_Vector &Values ,
int nClasses,
int Histogram = 0);
1125 double operator [] (
int i)
const {
return( m_Breaks[i] ); }
1135 bool _Histogram (
int nClasses);
1137 double _Get_Value (
int i);
1139 bool _Calculate (
int nClasses);
1165 bool Create (
int nFeatures);
1166 bool Destroy (
void);
1168 bool Add_Element (
void);
1169 bool Set_Feature (
sLong iElement,
int iFeature,
double Value);
1171 sLong Get_Cluster (
sLong iElement)
const {
return( iElement >= 0 && iElement < Get_nElements() ? m_Clusters[iElement] : -1 ); }
1173 bool Execute (
int Method,
int nClusters,
int nMaxIterations = 0,
int Initialization = 0);
1181 double Get_SP (
void)
const {
return( m_SP ); }
1184 double Get_Variance (
int iCluster)
const {
return( m_Variance[iCluster] ); }
1185 double Get_Centroid (
int iCluster,
int iFeature)
const {
return( m_Centroid[iCluster][iFeature] ); }
1190 int m_Iteration, m_nFeatures;
1203 bool _Minimum_Distance (
bool bInitialize,
int nMaxIterations);
1205 bool _Hill_Climbing (
bool bInitialize,
int nMaxIterations);
1237 void Create (
int nFeatures);
1238 void Destroy (
void);
1243 bool Train_Clr_Samples (
void);
1245 bool Train (
bool bClr_Samples =
false);
1257 double Get_Class_Mean (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Mean[iFeature] ); }
1258 double Get_Class_Minimum (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Min [iFeature] ); }
1259 double Get_Class_Maximum (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Max [iFeature] ); }
1262 bool Get_Class (
const CSG_Vector &Features,
int &Class,
double &Quality,
int Method);
1265 void Set_Threshold_Distance (
double Value);
1266 double Get_Threshold_Distance (
void);
1268 void Set_Threshold_Angle (
double Value);
1269 double Get_Threshold_Angle (
void);
1271 void Set_Threshold_Probability (
double Value);
1272 double Get_Threshold_Probability (
void);
1274 void Set_Probability_Relative (
bool Value);
1275 bool Get_Probability_Relative (
void);
1277 void Set_WTA (
int Method,
bool bOn);
1278 bool Get_WTA (
int Method);
1280 static CSG_String Get_Name_of_Method (
int Method);
1281 static CSG_String Get_Name_of_Quality (
int Method);
1294 double m_Cov_Det, m_Mean_Spectral;
1308 int m_nFeatures, m_nClasses;
1310 double m_Threshold_Distance, m_Threshold_Probability, m_Threshold_Angle;
1314 CClass **m_pClasses;
1317 void _Get_Binary_Encoding (
const CSG_Vector &Features,
int &Class,
double &Quality);
1318 void _Get_Parallel_Epiped (
const CSG_Vector &Features,
int &Class,
double &Quality);
1319 void _Get_Minimum_Distance (
const CSG_Vector &Features,
int &Class,
double &Quality);
1320 void _Get_Mahalanobis_Distance (
const CSG_Vector &Features,
int &Class,
double &Quality);
1321 void _Get_Maximum_Likelihood (
const CSG_Vector &Features,
int &Class,
double &Quality);
1322 void _Get_Spectral_Angle_Mapping (
const CSG_Vector &Features,
int &Class,
double &Quality);
1323 void _Get_Spectral_Divergence (
const CSG_Vector &Features,
int &Class,
double &Quality);
1324 void _Get_Winner_Takes_All (
const CSG_Vector &Features,
int &Class,
double &Quality);
1339 enum ESG_mRMR_Method
1341 SG_mRMR_Method_MID = 0,
1351 virtual ~CSG_mRMR(
void);
1353 void Destroy (
void);
1360 void Set_Verbose (
bool bOn =
true) { m_bVerbose = bOn; }
1364 bool Set_Data (
CSG_Table &Data,
int ClassField = 0,
double Threshold = -1.);
1365 bool Set_Data (
CSG_Matrix &Data,
int ClassField = 0,
double Threshold = -1.);
1368 bool Get_Selection (
int nFeatures,
int Method);
1370 int Get_Count (
void)
const;
1371 int Get_Index (
int i)
const;
1373 double Get_Score (
int i)
const;
1378 bool m_bDiscretized, m_bVerbose;
1380 long m_nSamples, m_nVars;
1389 bool Get_Memory (
int nVars,
int nSamples);
1391 bool Discretize (
double Threshold);
1393 double Get_MutualInfo (
long v1,
long v2);
1394 double Get_MutualInfo (
double *pab,
long pabhei,
long pabwid);
1396 template <
class T>
double * Get_JointProb (T *img1, T *img2,
long len,
long maxstatenum,
int &nstate1,
int &nstate2);
1397 template <
class T>
void Copy_Vector (T *srcdata,
long len,
int *desdata,
int &nstate);
1400 typedef struct SPool
1408 static int Pool_Compare (
const void *a,
const void *b);
1429 void Destroy (
void);
1431 bool Create (
double *xValues,
double *yValues,
int nValues,
double yA = 1.0e30,
double yB = 1.0e30);
1432 bool Create (
double yA = 1.0e30,
double yB = 1.0e30);
1434 void Add (
double x,
double y);
1437 double Get_xMin (
void)
const {
return( m_x.Get_N() > 0 ? m_x(0 ) : 0. ); }
1438 double Get_xMax (
void)
const {
return( m_x.Get_N() > 0 ? m_x(m_x.Get_Size() - 1) : 0. ); }
1439 double Get_x (
int i)
const {
return( i >= 0 && i < m_x.Get_N() ? m_x(i) : 0. ); }
1440 double Get_y (
int i)
const {
return( i >= 0 && i < m_y.Get_N() ? m_y(i) : 0. ); }
1442 bool Get_Value (
double x,
double &y);
1443 double Get_Value (
double x);
1453 bool _Create (
double yA,
double yB);
1464 bool Destroy (
void);
1471 bool Add_Point (
double x,
double y,
double z) {
return( m_Points.Add( x, y, z) ); }
1476 if( Index >= 0 && Index < m_Points.Get_Count() )
1478 m_Points[Index].x = x;
1479 m_Points[Index].y = y;
1480 m_Points[Index].z = z;
1490 bool Create (
double Regularization = 0.,
bool bSilent =
true);
1492 bool is_Okay (
void) {
return( m_V.Get_N() > 0 ); }
1494 double Get_Value (
double x,
double y);
1505 double _Get_Base_Funtion (
double x);
1506 double _Get_Base_Funtion (
TSG_Point_3D A,
double x,
double y);
1540 static double Get_Norm_P (
double Z);
1541 static double Get_Norm_Z (
double P);
1546 static double Get_Gamma (
double F,
double dfn,
double dfd);
1547 static double Get_Log_Gamma (
double a);
1549 static double Get_T_P (
double T,
int df);
1550 static double Get_T_Z (
double T,
int df);
1551 static double Get_T_Inv (
double p,
int df);
1615 void Destroy (
void);
1617 bool Set_Values (
int nValues,
double *x,
double *y);
1618 bool Add_Values (
double x,
double y);
1620 int Get_Count (
void)
const {
return( (
int)m_x.Get_Size() ); }
1622 double Get_xValue (
int i)
const {
return( i >= 0 && i < Get_Count() ? m_x[i] : 0. ); }
1623 double Get_yValue (
int i)
const {
return( i >= 0 && i < Get_Count() ? m_y[i] : 0. ); }
1626 if( i >= 0 && i < Get_Count() )
1641 double Get_x (
double y)
const;
1647 double Get_y (
double x)
const;
1651 double Get_R (
void)
const {
return( m_R ); }
1652 double Get_R2 (
void)
const {
return( m_R2 ); }
1654 double Get_P (
void)
const {
return( m_P ); }
1657 const SG_Char * asString (
void);
1667 double m_RConst, m_RCoeff, m_R, m_R2, m_R2_Adj, m_P,
m_SE,
1676 double _Y_Transform (
double x);
1677 double _X_Transform (
double y);
1708 void Destroy (
void);
1718 bool Get_Model_Stepwise (
const CSG_Matrix &Samples,
double P_in,
double P_out,
CSG_Strings *pNames = NULL);
1720 bool Get_Model (
void);
1721 bool Get_Model_Forward (
double P_in);
1722 bool Get_Model_Backward (
double P_out);
1723 bool Get_Model_Stepwise (
double P_in,
double P_out);
1725 bool Get_CrossValidation (
int nSubSamples = 0);
1732 double Get_R2 (
void)
const;
1733 double Get_R2_Adj (
void)
const;
1734 double Get_StdError (
void)
const;
1735 double Get_F (
void)
const;
1736 double Get_P (
void)
const;
1737 double Get_CV_RMSE (
void)
const;
1738 double Get_CV_NRMSE (
void)
const;
1739 double Get_CV_R2 (
void)
const;
1740 int Get_CV_nSamples (
void)
const;
1741 int Get_DegFreedom (
void)
const;
1742 int Get_nSamples (
void)
const;
1743 int Get_nPredictors (
void)
const;
1744 int Get_Predictor (
int i)
const {
return( i >= 0 && i < Get_nPredictors() ? m_Predictor[i] : -1 ); }
1746 double Get_RConst (
void)
const;
1753 double Get_T (
int iVariable)
const {
return( Get_Parameter(iVariable,
MLR_VAR_T ) ); }
1756 double Get_Parameter (
int iVariable,
int Parameter)
const;
1761 double Get_Residual (
int iSample)
const;
1762 bool Get_Residual (
int iSample,
double &Residual)
const;
1764 bool Get_Residuals (
CSG_Vector &Residuals)
const;
1780 bool _Initialize (
bool bInclude);
1782 double _Get_F (
int nPredictors,
int nSamples,
double r2_full,
double r2_reduced);
1783 double _Get_P (
int nPredictors,
int nSamples,
double r2_full,
double r2_reduced);
1785 bool _Get_Regression (
const class CSG_Matrix &Samples);
1788 int _Get_Step_Out (
CSG_Matrix &X,
double P_out,
double &R2);
1791 bool _Set_Step_Info (
const CSG_Matrix &X,
double R2_prev,
int iVariable,
bool bIn);
1807 bool Destroy (
void);
1809 bool Add_Sample (
double Weight,
double Dependent,
const CSG_Vector &Predictors);
1814 bool Calculate (
bool bLogistic =
false);
1816 double Get_R2 (
void)
const {
return( m_r2 ); }
1819 double operator [] (
int i)
const {
return( m_b[i] ); }
1826 bool Set_Log_maxIter (
int maxIter );
1827 bool Set_Log_Epsilon (
double Epsilon );
1828 bool Set_Log_Difference (
double Difference);
1831 bool Get_CrossValidation (
int nSubSamples = 0);
1841 int m_Log_maxIter, m_CV_nSamples;
1843 double m_r2, m_Log_Epsilon, m_Log_Difference, m_CV_RMSE, m_CV_NRMSE, m_CV_R2;
1880 bool Destroy (
void);
1882 static CSG_String Get_Help_Operators (
bool bHTML =
true,
const CSG_String Additional[][2] = NULL);
1886 bool Add_Function (
const char *Name,
TSG_Formula_Function_1 Function,
int nParameters,
bool bVarying =
false);
1888 bool Set_Formula (
const CSG_String &Formula);
1891 void Set_Variable (
char Variable,
double Value);
1893 double Get_Value (
void )
const;
1894 double Get_Value (
double x )
const;
1895 double Get_Value (
const CSG_Vector &Values )
const;
1896 double Get_Value (
double *Values,
int nValues)
const;
1897 double Get_Value (
const char *Arguments, ... )
const;
1899 const char * Get_Used_Variables (
void);
1919 typedef struct SSG_Formula
1929 bool m_bError, m_Vars_Used[256];
1931 int m_Error_Position, m_Length;
1933 TSG_Formula m_Formula;
1935 TSG_Function *m_Functions;
1940 const char *m_error;
1944 double m_Parameters[32], *m_ctable;
1947 void _Set_Error (
const CSG_String &Error =
"");
1949 double _Get_Value (
const double *Parameters, TSG_Formula Function)
const;
1951 int _is_Operand (
char c);
1952 int _is_Operand_Code (
char c);
1953 int _is_Number (
char c);
1955 int _Get_Function (
int i,
char *Name,
int *nParameters,
int *bVarying);
1956 int _Get_Function (
const char *Name);
1958 TSG_Formula _Translate (
const char *source,
const char *args,
int *length,
int *error);
1960 char * _i_trans (
char *
function,
char *begin,
char *end);
1961 char * _comp_time (
char *
function,
char *fend,
int npars);
1962 int _max_size (
const char *source);
1963 char * _my_strtok (
char *s);
1990 bool Set_Formula (
const CSG_String &Formula);
1995 bool Init_Parameter (
const SG_Char &Variable,
double Value);
1997 void Clr_Data (
void);
1998 bool Add_Data (
double x,
double y);
1999 void Set_Data (
double *x,
double *y,
int n,
bool bAdd =
false);
2000 void Set_Data (
const CSG_Points &Data ,
bool bAdd =
false);
2011 bool Set_Max_Iterations (
int Iterations);
2013 bool Set_Max_Lambda (
double Lambda);
2016 bool Get_Trend (
double *x,
double *y,
int n,
const CSG_String &Formula);
2019 bool Get_Trend (
void);
2026 double Get_R2 (
void)
const {
return( m_bOkay ? m_ChiSqr_o : 0. ); }
2028 double Get_Value (
double x)
const {
return( m_bOkay ? m_Formula.Get_Value(x) : 0. ); }
2040 bool Destroy (
void);
2042 int Get_Count (
void)
const {
return( (
int)m_Variables.Length() ); }
2059 double m_ChiSqr, m_ChiSqr_o, m_Lambda, m_Lambda_Max;
2068 bool _Fit_Function (
void);
2069 bool _Get_Gaussj (
void);
2072 void _Get_Function (
double &y,
double *dy_da,
double x,
const double *Parameters);
2089 bool Destroy (
void);
2091 bool Set_Order (
int Order = 1);
2093 bool Clr_Data (
void);
2094 bool Set_Data (
double *x,
double *y,
int n,
bool bAdd =
false);
2095 bool Add_Data (
double x,
double y);
2100 bool Get_Trend (
void);
2105 double Get_R2 (
void)
const {
return( m_r2 ); }
2107 double Get_Value (
double x)
const;
2128 #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)
virtual bool Get_Majority(CSG_String &Value, int &Count) const
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)
virtual bool Get_Minority(CSG_String &Value, int &Count) const
int Get_Predictor(int i) const
double Get_Data_X(int i) const
sLong Get_NRows(void) const
double Get_y(int i) const
virtual bool Get_Minority(double &Value) const
double Get_Variance(void)
double Get_Break(int i) const
const CSG_Vector & Get_RCoeff(void) const
virtual bool Get_Minority(CSG_String &Value) 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
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
virtual bool Get_Majority(double &Value) const
double Get_xMax(void) const
double Get_R2(void) const
double Get_yMin(void) const
virtual bool Get_Majority(CSG_String &Value) 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
virtual bool Get_Minority(CSG_String &Value, int &Count) 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)
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
virtual bool Get_Majority(double &Value) const
const CSG_String & Get_Class_ID(int iClass)
double Get_T(int iVariable) const
virtual bool Get_Minority(double &Value, int &Count) 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
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
virtual bool Get_Minority(double &Value, int &Count) 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
virtual bool Get_Majority(double &Value, int &Count) const
virtual bool Get_Majority(CSG_String &Value, int &Count) const
double Get_xMin(void) const
int Get_CV_nSamples(void) const
size_t Get_Size(void) 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)
virtual bool Get_Minority(double &Value) const
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
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
virtual bool Get_Majority(CSG_String &Value) const
virtual bool Get_Majority(double &Value, int &Count) const
virtual bool Get_Minority(CSG_String &Value) const
double Get_Value(double x) const
int Get_Data_Count(void) const
CSG_PriorityQueueItem(void)
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)