TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcmodels
optcrit.c
Go to the documentation of this file.
1
4
/*****************************************************************************/
5
#include "tpcclibConfig.h"
6
/*****************************************************************************/
7
#include <stdio.h>
8
#include <stdlib.h>
9
#include <math.h>
10
#include <time.h>
11
#include <string.h>
12
/*****************************************************************************/
13
#include "
tpcextensions.h
"
14
/*****************************************************************************/
15
#include "
tpcmodels.h
"
16
/*****************************************************************************/
17
18
/*****************************************************************************/
21
typedef
struct
TPC_OPTCRIT {
23
char
*code;
25
optimality_criterion
id;
27
char
*desc;
28
} TPC_OPTCRIT;
29
/*****************************************************************************/
31
static
TPC_OPTCRIT tpc_optcrit[]={
32
{
"unknown"
,
OPTCRIT_UNKNOWN
,
"Unknown optimality criterion"
},
33
{
"OLS"
,
OPTCRIT_OLS
,
"Ordinary Least Squares"
},
34
{
"LMS"
,
OPTCRIT_LMS
,
"Least Median of Squares"
},
35
{
"LAD"
,
OPTCRIT_LAD
,
"Least Absolute Deviations"
},
36
{
"MAD"
,
OPTCRIT_MAD
,
"Median Absolute Deviation"
},
37
{
"ODR"
,
OPTCRIT_ODR
,
"Orthogonal deviations"
},
38
{
""
, 0,
""
}
39
};
41
/*****************************************************************************/
42
43
/*****************************************************************************/
47
unsigned
int
optcritNr
()
48
{
49
unsigned
int
i=0;
50
while
(tpc_optcrit[i].code[0]!=
'\0'
) i++;
51
return
(i);
52
}
53
/*****************************************************************************/
54
55
/*****************************************************************************/
60
char
*
optcritCode
(
62
optimality_criterion
id
63
) {
64
for
(
unsigned
int
i=0; i<
optcritNr
(); i++)
if
(
id
==tpc_optcrit[i].
id
)
return
(tpc_optcrit[i].code);
65
return
((
char
*)NULL);
66
}
67
/*****************************************************************************/
68
69
/*****************************************************************************/
74
char
*
optcritDesc
(
76
optimality_criterion
id
77
) {
78
for
(
unsigned
int
i=0; i<
optcritNr
(); i++)
if
(
id
==tpc_optcrit[i].
id
)
return
(tpc_optcrit[i].desc);
79
return
((
char
*)NULL);
80
}
81
/*****************************************************************************/
82
83
/*****************************************************************************/
88
optimality_criterion
optcritId
(
91
const
char
*s
92
) {
93
if
(s==NULL || *s==
'\0'
)
return
(
OPTCRIT_UNKNOWN
);
94
for
(
unsigned
int
i=0; i<
optcritNr
(); i++)
95
if
(!strcasecmp(tpc_optcrit[i].code, s))
return
(tpc_optcrit[i].
id
);
96
/* Try also some alternative names */
97
if
(!strcasecmp(
"SS"
, s))
return
(
OPTCRIT_OLS
);
98
if
(!strcasecmp(
"WSS"
, s))
return
(
OPTCRIT_OLS
);
99
if
(!strcasecmp(
"SUMSQR"
, s))
return
(
OPTCRIT_OLS
);
100
if
(!strcasecmp(
"LAE"
, s))
return
(
OPTCRIT_LAD
);
101
if
(!strcasecmp(
"LAV"
, s))
return
(
OPTCRIT_LAD
);
102
if
(!strcasecmp(
"LAR"
, s))
return
(
OPTCRIT_LAD
);
103
if
(!strcasecmp(
"Deming"
, s))
return
(
OPTCRIT_ODR
);
104
return
(
OPTCRIT_UNKNOWN
);
105
}
106
/*****************************************************************************/
107
108
/*****************************************************************************/
optcritCode
char * optcritCode(optimality_criterion id)
Definition
optcrit.c:60
optcritId
optimality_criterion optcritId(const char *s)
Definition
optcrit.c:88
optcritDesc
char * optcritDesc(optimality_criterion id)
Definition
optcrit.c:74
optcritNr
unsigned int optcritNr()
Definition
optcrit.c:47
tpcextensions.h
Header file for library libtpcextensions.
tpcmodels.h
Header file for libtpcmodels.
optimality_criterion
optimality_criterion
Optimality Criterion for statistical optimizations.
Definition
tpcmodels.h:67
OPTCRIT_OLS
@ OPTCRIT_OLS
Ordinary Least Squares (sum-of-squares, SS).
Definition
tpcmodels.h:69
OPTCRIT_LAD
@ OPTCRIT_LAD
Least Absolute Deviations (sum of absolute deviations, LAE, LAV, LAR).
Definition
tpcmodels.h:71
OPTCRIT_ODR
@ OPTCRIT_ODR
Orthogonal Distance Regression (sum of perpendicular distances).
Definition
tpcmodels.h:73
OPTCRIT_MAD
@ OPTCRIT_MAD
Median Absolute Deviation.
Definition
tpcmodels.h:72
OPTCRIT_UNKNOWN
@ OPTCRIT_UNKNOWN
Unknown optimality criterion.
Definition
tpcmodels.h:68
OPTCRIT_LMS
@ OPTCRIT_LMS
Least Median of Squares.
Definition
tpcmodels.h:70
Generated on
for TPCCLIB by
1.17.0