|
SAGA API
v9.6
|
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;
827 bool m_bWeights{
false};
842 virtual void Create (
bool bWeights =
false);
844 void operator += (
double Value) { Add_Value(Value); }
845 void Add_Value (
double Value,
double Weight = 1.);
846 double Get_Value (
int Index)
const {
return( m_Value[Index] ); }
847 int Get_Class_Index (
double Value)
const;
848 bool Get_Class (
int Index,
double &Value,
int &Count)
const
850 if( Index < 0 || Index >=
Get_Count() )
return(
false );
852 Count = m_Count[Index];
853 Value = m_Value[Index];
877 virtual void Create (
bool bWeights =
false);
879 void operator += (
const CSG_String &Value) { Add_Value(Value); }
880 void Add_Value (
const CSG_String &Value,
double Weight = 1.);
882 int Get_Class_Index (
const CSG_String &Value)
const;
885 if( Index < 0 || Index >=
Get_Count() )
return(
false );
887 Count = m_Count[Index];
888 Value = m_Value[Index];
924 int Add_Value (
int Value);
925 int Add_Value (
double Value);
928 void operator += (
int Value) { Add_Value(Value); }
929 void operator += (
double Value) { Add_Value(Value); }
930 void operator += (
const CSG_String &Value) { Add_Value(Value); }
934 int Get_Count (
void )
const;
935 int Get_Count (
int iCategory)
const;
937 int asInt (
int iCategory)
const;
938 double asDouble (
int iCategory)
const;
941 int Get_Category (
int Value)
const;
942 int Get_Category (
double Value)
const;
943 int Get_Category (
const CSG_String &Value)
const;
947 Count = Get_Count(iCategory);
948 Value = asInt (iCategory);
950 return( iCategory >= 0 && iCategory < Get_Count() );
955 Count = Get_Count(iCategory);
956 Value = asDouble (iCategory);
958 return( iCategory >= 0 && iCategory < Get_Count() );
963 Count = Get_Count(iCategory);
964 Value = asString (iCategory);
966 return( iCategory >= 0 && iCategory < Get_Count() );
969 int Get_Majority (
void);
977 int Get_Minority (
void);
1006 bool Destroy (
void);
1011 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum);
1012 bool Create (
size_t nClasses,
double Minimum,
double Maximum);
1014 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
const CSG_Vector &Values ,
size_t maxSamples = 0);
1015 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
const CSG_Vector &Values ,
size_t maxSamples = 0);
1017 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Table *pTable,
int Field,
size_t maxSamples = 0);
1018 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Table *pTable,
int Field,
size_t maxSamples = 0);
1020 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grid *pGrid ,
size_t maxSamples = 0);
1021 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grid *pGrid ,
size_t maxSamples = 0);
1023 CSG_Histogram (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grids *pGrids ,
size_t maxSamples = 0);
1024 bool Create (
size_t nClasses,
double Minimum,
double Maximum,
class CSG_Grids *pGrids ,
size_t maxSamples = 0);
1027 void Add_Value (
double Value);
1029 bool Scale_Element_Count (
double Scale);
1035 size_t Get_Element_Count (
void)
const {
return( m_nClasses > 0 ? m_Cumulative[m_nClasses - 1] : 0 ); }
1039 size_t Get_Elements (
size_t i)
const {
return( i < m_nClasses ? m_Elements[i] : 0 ); }
1042 size_t Get_Cumulative (
size_t i)
const {
return( i < m_nClasses ? m_Cumulative[i] : 0 ); }
1044 double Get_Value (
double i)
const {
return( m_nClasses < 1 ? m_Minimum : m_Minimum + i * m_ClassWidth ); }
1046 double Get_Break (
int i)
const {
return( Get_Value((
double)(i)) ); }
1047 double Get_Break (
size_t i)
const {
return( Get_Value((
double)(i)) ); }
1049 double Get_Center (
int i)
const {
return( Get_Value((
double)(i + 0.5)) ); }
1050 double Get_Center (
size_t i)
const {
return( Get_Value((
double)(i + 0.5)) ); }
1055 void operator += (
double Value) { Add_Value(Value); }
1057 size_t operator [] (
int i)
const {
return( Get_Elements(i) ); }
1058 size_t operator [] (
size_t i)
const {
return( Get_Elements(i) ); }
1060 double Get_Quantile (
double Quantile)
const;
1061 double Get_Quantile_Value (
double Value)
const;
1063 double Get_Percentile (
double Percentile)
const;
1064 double Get_Percentile_Value(
double Value)
const;
1071 size_t m_nClasses, m_nMaximum, *m_Elements, *m_Cumulative;
1073 double m_Minimum, m_Maximum, m_ClassWidth;
1078 void _On_Construction (
void);
1080 bool _Create (
size_t nClasses,
double Minimum,
double Maximum);
1082 bool _Update (
sLong nElements);
1101 bool Create (
class CSG_Table *pTable,
int Field,
int nClasses,
int Histogram = 0);
1104 bool Create (
class CSG_Grid *pGrid ,
int nClasses,
int Histogram = 0);
1107 bool Create (
class CSG_Grids *pGrids ,
int nClasses,
int Histogram = 0);
1110 bool Create (
const CSG_Vector &Values ,
int nClasses,
int Histogram = 0);
1115 double operator [] (
int i)
const {
return( m_Breaks[i] ); }
1125 bool _Histogram (
int nClasses);
1127 double _Get_Value (
int i);
1129 bool _Calculate (
int nClasses);
1155 bool Create (
int nFeatures);
1156 bool Destroy (
void);
1158 bool Add_Element (
void);
1159 bool Set_Feature (
sLong iElement,
int iFeature,
double Value);
1161 sLong Get_Cluster (
sLong iElement)
const {
return( iElement >= 0 && iElement < Get_nElements() ? m_Clusters[iElement] : -1 ); }
1163 bool Execute (
int Method,
int nClusters,
int nMaxIterations = 0,
int Initialization = 0);
1171 double Get_SP (
void)
const {
return( m_SP ); }
1174 double Get_Variance (
int iCluster)
const {
return( m_Variance[iCluster] ); }
1175 double Get_Centroid (
int iCluster,
int iFeature)
const {
return( m_Centroid[iCluster][iFeature] ); }
1180 int m_Iteration, m_nFeatures;
1193 bool _Minimum_Distance (
bool bInitialize,
int nMaxIterations);
1195 bool _Hill_Climbing (
bool bInitialize,
int nMaxIterations);
1227 void Create (
int nFeatures);
1228 void Destroy (
void);
1233 bool Train_Clr_Samples (
void);
1235 bool Train (
bool bClr_Samples =
false);
1247 double Get_Class_Mean (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Mean[iFeature] ); }
1248 double Get_Class_Minimum (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Min [iFeature] ); }
1249 double Get_Class_Maximum (
int iClass,
int iFeature) {
return( m_pClasses[iClass]->m_Max [iFeature] ); }
1252 bool Get_Class (
const CSG_Vector &Features,
int &Class,
double &Quality,
int Method);
1255 void Set_Threshold_Distance (
double Value);
1256 double Get_Threshold_Distance (
void);
1258 void Set_Threshold_Angle (
double Value);
1259 double Get_Threshold_Angle (
void);
1261 void Set_Threshold_Probability (
double Value);
1262 double Get_Threshold_Probability (
void);
1264 void Set_Probability_Relative (
bool Value);
1265 bool Get_Probability_Relative (
void);
1267 void Set_WTA (
int Method,
bool bOn);
1268 bool Get_WTA (
int Method);
1270 static CSG_String Get_Name_of_Method (
int Method);
1271 static CSG_String Get_Name_of_Quality (
int Method);
1284 double m_Cov_Det, m_Mean_Spectral;
1298 int m_nFeatures, m_nClasses;
1300 double m_Threshold_Distance, m_Threshold_Probability, m_Threshold_Angle;
1304 CClass **m_pClasses;
1307 void _Get_Binary_Encoding (
const CSG_Vector &Features,
int &Class,
double &Quality);
1308 void _Get_Parallel_Epiped (
const CSG_Vector &Features,
int &Class,
double &Quality);
1309 void _Get_Minimum_Distance (
const CSG_Vector &Features,
int &Class,
double &Quality);
1310 void _Get_Mahalanobis_Distance (
const CSG_Vector &Features,
int &Class,
double &Quality);
1311 void _Get_Maximum_Likelihood (
const CSG_Vector &Features,
int &Class,
double &Quality);
1312 void _Get_Spectral_Angle_Mapping (
const CSG_Vector &Features,
int &Class,
double &Quality);
1313 void _Get_Spectral_Divergence (
const CSG_Vector &Features,
int &Class,
double &Quality);
1314 void _Get_Winner_Takes_All (
const CSG_Vector &Features,
int &Class,
double &Quality);
1329 enum ESG_mRMR_Method
1331 SG_mRMR_Method_MID = 0,
1341 virtual ~CSG_mRMR(
void);
1343 void Destroy (
void);
1350 void Set_Verbose (
bool bOn =
true) { m_bVerbose = bOn; }
1354 bool Set_Data (
CSG_Table &Data,
int ClassField = 0,
double Threshold = -1.);
1355 bool Set_Data (
CSG_Matrix &Data,
int ClassField = 0,
double Threshold = -1.);
1358 bool Get_Selection (
int nFeatures,
int Method);
1360 int Get_Count (
void)
const;
1361 int Get_Index (
int i)
const;
1363 double Get_Score (
int i)
const;
1368 bool m_bDiscretized, m_bVerbose;
1370 long m_nSamples, m_nVars;
1379 bool Get_Memory (
int nVars,
int nSamples);
1381 bool Discretize (
double Threshold);
1383 double Get_MutualInfo (
long v1,
long v2);
1384 double Get_MutualInfo (
double *pab,
long pabhei,
long pabwid);
1386 template <
class T>
double * Get_JointProb (T *img1, T *img2,
long len,
long maxstatenum,
int &nstate1,
int &nstate2);
1387 template <
class T>
void Copy_Vector (T *srcdata,
long len,
int *desdata,
int &nstate);
1390 typedef struct SPool
1398 static int Pool_Compare (
const void *a,
const void *b);
1419 void Destroy (
void);
1421 bool Create (
double *xValues,
double *yValues,
int nValues,
double yA = 1.0e30,
double yB = 1.0e30);
1422 bool Create (
double yA = 1.0e30,
double yB = 1.0e30);
1424 void Add (
double x,
double y);
1427 double Get_xMin (
void)
const {
return( m_x.Get_N() > 0 ? m_x(0 ) : 0. ); }
1428 double Get_xMax (
void)
const {
return( m_x.Get_N() > 0 ? m_x(m_x.Get_Size() - 1) : 0. ); }
1429 double Get_x (
int i)
const {
return( i >= 0 && i < m_x.Get_N() ? m_x(i) : 0. ); }
1430 double Get_y (
int i)
const {
return( i >= 0 && i < m_y.Get_N() ? m_y(i) : 0. ); }
1432 bool Get_Value (
double x,
double &y);
1433 double Get_Value (
double x);
1443 bool _Create (
double yA,
double yB);
1454 bool Destroy (
void);
1461 bool Add_Point (
double x,
double y,
double z) {
return( m_Points.Add( x, y, z) ); }
1466 if( Index >= 0 && Index < m_Points.Get_Count() )
1468 m_Points[Index].x = x;
1469 m_Points[Index].y = y;
1470 m_Points[Index].z = z;
1480 bool Create (
double Regularization = 0.,
bool bSilent =
true);
1482 bool is_Okay (
void) {
return( m_V.Get_N() > 0 ); }
1484 double Get_Value (
double x,
double y);
1495 double _Get_Base_Funtion (
double x);
1496 double _Get_Base_Funtion (
TSG_Point_3D A,
double x,
double y);
1530 static double Get_Norm_P (
double Z);
1531 static double Get_Norm_Z (
double P);
1536 static double Get_Gamma (
double F,
double dfn,
double dfd);
1537 static double Get_Log_Gamma (
double a);
1539 static double Get_T_P (
double T,
int df);
1540 static double Get_T_Z (
double T,
int df);
1541 static double Get_T_Inv (
double p,
int df);
1605 void Destroy (
void);
1607 bool Set_Values (
int nValues,
double *x,
double *y);
1608 bool Add_Values (
double x,
double y);
1610 int Get_Count (
void)
const {
return( (
int)m_x.Get_Size() ); }
1612 double Get_xValue (
int i)
const {
return( i >= 0 && i < Get_Count() ? m_x[i] : 0. ); }
1613 double Get_yValue (
int i)
const {
return( i >= 0 && i < Get_Count() ? m_y[i] : 0. ); }
1616 if( i >= 0 && i < Get_Count() )
1631 double Get_x (
double y)
const;
1637 double Get_y (
double x)
const;
1641 double Get_R (
void)
const {
return( m_R ); }
1642 double Get_R2 (
void)
const {
return( m_R2 ); }
1644 double Get_P (
void)
const {
return( m_P ); }
1647 const SG_Char * asString (
void);
1657 double m_RConst, m_RCoeff, m_R, m_R2, m_R2_Adj, m_P,
m_SE,
1666 double _Y_Transform (
double x);
1667 double _X_Transform (
double y);
1698 void Destroy (
void);
1708 bool Get_Model_Stepwise (
const CSG_Matrix &Samples,
double P_in,
double P_out,
CSG_Strings *pNames = NULL);
1710 bool Get_Model (
void);
1711 bool Get_Model_Forward (
double P_in);
1712 bool Get_Model_Backward (
double P_out);
1713 bool Get_Model_Stepwise (
double P_in,
double P_out);
1715 bool Get_CrossValidation (
int nSubSamples = 0);
1722 double Get_R2 (
void)
const;
1723 double Get_R2_Adj (
void)
const;
1724 double Get_StdError (
void)
const;
1725 double Get_F (
void)
const;
1726 double Get_P (
void)
const;
1727 double Get_CV_RMSE (
void)
const;
1728 double Get_CV_NRMSE (
void)
const;
1729 double Get_CV_R2 (
void)
const;
1730 int Get_CV_nSamples (
void)
const;
1731 int Get_DegFreedom (
void)
const;
1732 int Get_nSamples (
void)
const;
1733 int Get_nPredictors (
void)
const;
1734 int Get_Predictor (
int i)
const {
return( i >= 0 && i < Get_nPredictors() ? m_Predictor[i] : -1 ); }
1736 double Get_RConst (
void)
const;
1743 double Get_T (
int iVariable)
const {
return( Get_Parameter(iVariable,
MLR_VAR_T ) ); }
1746 double Get_Parameter (
int iVariable,
int Parameter)
const;
1751 double Get_Residual (
int iSample)
const;
1752 bool Get_Residual (
int iSample,
double &Residual)
const;
1754 bool Get_Residuals (
CSG_Vector &Residuals)
const;
1770 bool _Initialize (
bool bInclude);
1772 double _Get_F (
int nPredictors,
int nSamples,
double r2_full,
double r2_reduced);
1773 double _Get_P (
int nPredictors,
int nSamples,
double r2_full,
double r2_reduced);
1775 bool _Get_Regression (
const class CSG_Matrix &Samples);
1778 int _Get_Step_Out (
CSG_Matrix &X,
double P_out,
double &R2);
1781 bool _Set_Step_Info (
const CSG_Matrix &X,
double R2_prev,
int iVariable,
bool bIn);
1797 bool Destroy (
void);
1799 bool Add_Sample (
double Weight,
double Dependent,
const CSG_Vector &Predictors);
1804 bool Calculate (
bool bLogistic =
false);
1806 double Get_R2 (
void)
const {
return( m_r2 ); }
1809 double operator [] (
int i)
const {
return( m_b[i] ); }
1816 bool Set_Log_maxIter (
int maxIter );
1817 bool Set_Log_Epsilon (
double Epsilon );
1818 bool Set_Log_Difference (
double Difference);
1821 bool Get_CrossValidation (
int nSubSamples = 0);
1831 int m_Log_maxIter, m_CV_nSamples;
1833 double m_r2, m_Log_Epsilon, m_Log_Difference, m_CV_RMSE, m_CV_NRMSE, m_CV_R2;
1870 bool Destroy (
void);
1872 static CSG_String Get_Help_Operators (
bool bHTML =
true,
const CSG_String Additional[][2] = NULL);
1876 bool Add_Function (
const char *Name,
TSG_Formula_Function_1 Function,
int nParameters,
bool bVarying =
false);
1878 bool Set_Formula (
const CSG_String &Formula);
1881 void Set_Variable (
char Variable,
double Value);
1883 double Get_Value (
void )
const;
1884 double Get_Value (
double x )
const;
1885 double Get_Value (
const CSG_Vector &Values )
const;
1886 double Get_Value (
double *Values,
int nValues)
const;
1887 double Get_Value (
const char *Arguments, ... )
const;
1889 const char * Get_Used_Variables (
void);
1909 typedef struct SSG_Formula
1919 bool m_bError, m_Vars_Used[256];
1921 int m_Error_Position, m_Length;
1923 TSG_Formula m_Formula;
1925 TSG_Function *m_Functions;
1930 const char *m_error;
1934 double m_Parameters[32], *m_ctable;
1937 void _Set_Error (
const CSG_String &Error =
"");
1939 double _Get_Value (
const double *Parameters, TSG_Formula Function)
const;
1941 int _is_Operand (
char c);
1942 int _is_Operand_Code (
char c);
1943 int _is_Number (
char c);
1945 int _Get_Function (
int i,
char *Name,
int *nParameters,
int *bVarying);
1946 int _Get_Function (
const char *Name);
1948 TSG_Formula _Translate (
const char *source,
const char *args,
int *length,
int *error);
1950 char * _i_trans (
char *
function,
char *begin,
char *end);
1951 char * _comp_time (
char *
function,
char *fend,
int npars);
1952 int _max_size (
const char *source);
1953 char * _my_strtok (
char *s);
1980 bool Set_Formula (
const CSG_String &Formula);
1985 bool Init_Parameter (
const SG_Char &Variable,
double Value);
1987 void Clr_Data (
void);
1988 bool Add_Data (
double x,
double y);
1989 void Set_Data (
double *x,
double *y,
int n,
bool bAdd =
false);
1990 void Set_Data (
const CSG_Points &Data ,
bool bAdd =
false);
2001 bool Set_Max_Iterations (
int Iterations);
2003 bool Set_Max_Lambda (
double Lambda);
2006 bool Get_Trend (
double *x,
double *y,
int n,
const CSG_String &Formula);
2009 bool Get_Trend (
void);
2016 double Get_R2 (
void)
const {
return( m_bOkay ? m_ChiSqr_o : 0. ); }
2018 double Get_Value (
double x)
const {
return( m_bOkay ? m_Formula.Get_Value(x) : 0. ); }
2030 bool Destroy (
void);
2032 int Get_Count (
void)
const {
return( (
int)m_Variables.Length() ); }
2049 double m_ChiSqr, m_ChiSqr_o, m_Lambda, m_Lambda_Max;
2058 bool _Fit_Function (
void);
2059 bool _Get_Gaussj (
void);
2062 void _Get_Function (
double &y,
double *dy_da,
double x,
const double *Parameters);
2079 bool Destroy (
void);
2081 bool Set_Order (
int Order = 1);
2083 bool Clr_Data (
void);
2084 bool Set_Data (
double *x,
double *y,
int n,
bool bAdd =
false);
2085 bool Add_Data (
double x,
double y);
2090 bool Get_Trend (
void);
2095 double Get_R2 (
void)
const {
return( m_r2 ); }
2097 double Get_Value (
double x)
const;
2118 #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)