TPCCLIB
Loading...
Searching...
No Matches
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/*****************************************************************************/
21typedef struct TPC_OPTCRIT {
23 char *code;
27 char *desc;
28} TPC_OPTCRIT;
29/*****************************************************************************/
31static 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/*****************************************************************************/
47unsigned int optcritNr()
48{
49 unsigned int i=0;
50 while(tpc_optcrit[i].code[0]!='\0') i++;
51 return(i);
52}
53/*****************************************************************************/
54
55/*****************************************************************************/
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/*****************************************************************************/
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/*****************************************************************************/
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/*****************************************************************************/
char * optcritCode(optimality_criterion id)
Definition optcrit.c:60
optimality_criterion optcritId(const char *s)
Definition optcrit.c:88
char * optcritDesc(optimality_criterion id)
Definition optcrit.c:74
unsigned int optcritNr()
Definition optcrit.c:47
Header file for library libtpcextensions.
Header file for libtpcmodels.
optimality_criterion
Optimality Criterion for statistical optimizations.
Definition tpcmodels.h:66
@ OPTCRIT_OLS
Ordinary Least Squares (sum-of-squares, SS).
Definition tpcmodels.h:68
@ OPTCRIT_LAD
Least Absolute Deviations (sum of absolute deviations, LAE, LAV, LAR).
Definition tpcmodels.h:70
@ OPTCRIT_ODR
Orthogonal Distance Regression (sum of perpendicular distances).
Definition tpcmodels.h:72
@ OPTCRIT_MAD
Median Absolute Deviation.
Definition tpcmodels.h:71
@ OPTCRIT_UNKNOWN
Unknown optimality criterion.
Definition tpcmodels.h:67
@ OPTCRIT_LMS
Least Median of Squares.
Definition tpcmodels.h:69