File: lfstr.c

package info (click to toggle)
cufflinks 1.3.0-2
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 3,864 kB
  • sloc: cpp: 48,999; ansic: 12,297; sh: 3,381; python: 432; makefile: 209
file content (150 lines) | stat: -rw-r--r-- 4,169 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 *   Copyright (c) 1996-2001 Lucent Technologies.
 *   See README file for details.
 *
 *
 *
 *  setstrval() is a  function for converting string arguments to Locfit's
 *    numeric values.  A typical call will be setstrval(lf.mi,MKER,"gauss").
 *
 *  components that can be set in this manner are
 *    MKER  (weight function)
 *    MKT   (kernel type -- spherical or product)
 *    MTG   (local likelihood family)
 *    MLINK (link function)
 *    MIT   (integration type for density estimation)
 *    MEV   (evaluation structure)
 *    MACRI (adaptive criterion)
 *
 *  INT ppwhat(str) interprets the preplot what argument.
 *  INT restyp(str) interprets the residual type argument.
 *
 */

#include "local.h"

static char *famil[17] =
  { "density", "ate",   "hazard",    "gaussian", "binomial",
    "poisson", "gamma", "geometric", "circular", "obust", "huber",
    "weibull", "cauchy","probab",    "logistic", "nbinomial", "vonmises" };
static int   fvals[17] = 
  { TDEN,  TRAT,  THAZ,  TGAUS, TLOGT,
    TPOIS, TGAMM, TGEOM, TCIRC, TROBT, TROBT,
    TWEIB, TCAUC, TPROB, TLOGT, TGEOM, TCIRC };

INT lffamily(z)
char *z;
{ INT quasi, robu, f;
  quasi = robu = 0;
  while ((z[0]=='q') | (z[0]=='r'))
  { quasi |= (z[0]=='q');
    robu  |= (z[0]=='r');
    z++;
  }
  f = pmatch(z,famil,fvals,16,-1);
  if ((z[0]=='o') | (z[0]=='a')) robu = 0;
  if (f==-1)
  { WARN(("unknown family %s",z));
    f = TGAUS;
  }
  if (quasi) f += 64;
  if (robu)  f += 128;
  return(f);
}

void getlffam(z,x)
char **z;
INT *x;
{ *x = lffamily(z[0]);
}

static char *wfuns[13] = {
  "rectangular", "epanechnikov", "bisquare",    "tricube",
  "triweight",   "gaussian",     "triangular",  "ququ",
  "6cub",        "minimax",      "exponential", "maclean", "parametric" };
static int wvals[13] = { WRECT, WEPAN, WBISQ, WTCUB,
  WTRWT, WGAUS, WTRIA, WQUQU, W6CUB, WMINM, WEXPL, WMACL, WPARM };

static char *ktype[3] = { "spherical", "product", "center" };
static int   kvals[3] = { KSPH, KPROD, KCE };

static char *ltype[8] = { "default", "canonical", "identity", "log",
                          "logi",    "inverse",   "sqrt",     "arcsin" };
static int   lvals[8] = { LDEFAU, LCANON, LIDENT, LLOG,
                          LLOGIT, LINVER, LSQRT,  LASIN };

static char *etype[9] = { "tree",     "phull", "data", "grid", "kdtree",
                          "kdcenter", "cross", "xbar", "none" };
static int   evals[9] = { ETREE, EPHULL, EDATA, EGRID, EKDTR,
                          EKDCE, ECROS,  EXBAR, ENONE };

static char *itype[6] = { "default", "multi", "product", "mlinear",
                          "hazard",  "monte" };
static int   ivals[6] = { IDEFA, IMULT, IPROD, IMLIN, IHAZD, IMONT };

static char *atype[5] = { "none", "cp", "ici", "mindex", "ok" };
static int   avals[5] = { ANONE, ACP, AKAT, AMDI, AOK };

void setstrval(mi,v,z)
INT *mi, v;
char *z;
{ 
  switch(v)
  { case MKER:
      mi[v] = pmatch(z, wfuns, wvals, 13, WTCUB);
      return;

    case MKT:
      mi[v] = pmatch(z, ktype, kvals, 3, KSPH);
      return;

    case MTG:
      mi[v] = lffamily(z);
      return;

    case MLINK:
      mi[v] = pmatch(z, ltype, lvals, 8, LDEFAU);
      return;

    case MIT:
      mi[v] = pmatch(z, itype, ivals, 6, IDEFA);
      return;

    case MEV:
      mi[v] = pmatch(z, etype, evals, 9, ETREE);
      return;

    case MACRI:
      mi[v] = pmatch(z, atype, avals, 5, ANONE);
      return;
  }

  WARN(("setstrval: invalid value %d",v));
  return;
}

static char *rtype[8] = { "deviance", "d2",    "pearson", "raw",
                          "ldot",     "lddot", "fit",     "mean" };
static int   rvals[8] = { RDEV, RDEV2, RPEAR, RRAW, RLDOT, RLDDT, RFIT, RMEAN};

static char *whtyp[8] = { "coef", "nlx", "infl", "band",
                          "degr", "like", "rdf", "vari" };
static int   whval[8] = { PCOEF, PNLX, PT0, PBAND, PDEGR, PLIK, PRDF, PVARI };

INT restyp(z)
char *z;
{ int val;
  
  val = pmatch(z, rtype, rvals, 8, -1);
  if (val==-1) ERROR(("Unknown type = %s",z));
  return((INT)val);
}

INT ppwhat(z)
char *z;
{ int val;
  
  val = pmatch(z, whtyp, whval, 8, -1);
  if (val==-1) ERROR(("Unknown what = %s",z));
  return((INT)val);
}