w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Function.h
Go to the documentation of this file.
1 //========================================================================
2 //
3 // Function.h
4 //
5 // Copyright 2001-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 #ifndef FUNCTION_H
10 #define FUNCTION_H
11 
12 #include <aconf.h>
13 
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17 
18 #include "gtypes.h"
19 #include "Object.h"
20 
21 class GList;
22 class Dict;
23 class Stream;
24 struct PSCode;
25 
26 //------------------------------------------------------------------------
27 // Function
28 //------------------------------------------------------------------------
29 
30 #define funcMaxInputs 32
31 #define funcMaxOutputs 32
32 #define sampledFuncMaxInputs 16
33 
34 class Function {
35 public:
36 
37  Function();
38 
39  virtual ~Function();
40 
41  // Construct a function, with [expectedInputs] inputs and
42  // [expectedOutputs] outputs. [expectedOutputs] can be -1 to
43  // indicate unknown. Returns NULL if unsuccessful.
44  static Function *parse(Object *funcObj, int expectedInputs,
45  int expectedOutputs, int recursion = 0);
46 
47  // Initialize the entries common to all function types.
48  GBool init(Dict *dict);
49 
50  virtual Function *copy() = 0;
51 
52  // Return the function type:
53  // -1 : identity
54  // 0 : sampled
55  // 2 : exponential
56  // 3 : stitching
57  // 4 : PostScript
58  virtual int getType() = 0;
59 
60  // Return size of input and output tuples.
61  int getInputSize() { return m; }
62  int getOutputSize() { return n; }
63 
64  double getDomainMin(int i) { return domain[i][0]; }
65  double getDomainMax(int i) { return domain[i][1]; }
66  double getRangeMin(int i) { return range[i][0]; }
67  double getRangeMax(int i) { return range[i][1]; }
68  GBool getHasRange() { return hasRange; }
69 
70  // Transform an input tuple into an output tuple.
71  virtual void transform(double *in, double *out) = 0;
72 
73  virtual GBool isOk() = 0;
74 
75 protected:
76 
77  int m, n; // size of input and output tuples
78  double // min and max values for function domain
80  double // min and max values for function range
82  GBool hasRange; // set if range is defined
83 };
84 
85 //------------------------------------------------------------------------
86 // IdentityFunction
87 //------------------------------------------------------------------------
88 
89 class IdentityFunction: public Function {
90 public:
91 
92  IdentityFunction(int nInputs);
93  virtual ~IdentityFunction();
94  virtual Function *copy() { return new IdentityFunction(m); }
95  virtual int getType() { return -1; }
96  virtual void transform(double *in, double *out);
97  virtual GBool isOk() { return gTrue; }
98 
99 private:
100 };
101 
102 //------------------------------------------------------------------------
103 // SampledFunction
104 //------------------------------------------------------------------------
105 
106 class SampledFunction: public Function {
107 public:
108 
109  SampledFunction(Object *funcObj, Dict *dict);
110  virtual ~SampledFunction();
111  virtual Function *copy() { return new SampledFunction(this); }
112  virtual int getType() { return 0; }
113  virtual void transform(double *in, double *out);
114  virtual GBool isOk() { return ok; }
115 
116  int getSampleSize(int i) { return sampleSize[i]; }
117  double getEncodeMin(int i) { return encode[i][0]; }
118  double getEncodeMax(int i) { return encode[i][1]; }
119  double getDecodeMin(int i) { return decode[i][0]; }
120  double getDecodeMax(int i) { return decode[i][1]; }
121  double *getSamples() { return samples; }
122 
123 private:
124 
126 
127  int // number of samples for each domain element
129  double // min and max values for domain encoder
131  double // min and max values for range decoder
133  double // input multipliers
135  int *idxOffset;
136  double *samples; // the samples
137  int nSamples; // size of the samples array
138  double *sBuf; // buffer for the transform function
142 };
143 
144 //------------------------------------------------------------------------
145 // ExponentialFunction
146 //------------------------------------------------------------------------
147 
149 public:
150 
151  ExponentialFunction(Object *funcObj, Dict *dict);
152  virtual ~ExponentialFunction();
153  virtual Function *copy() { return new ExponentialFunction(this); }
154  virtual int getType() { return 2; }
155  virtual void transform(double *in, double *out);
156  virtual GBool isOk() { return ok; }
157 
158  double *getC0() { return c0; }
159  double *getC1() { return c1; }
160  double getE() { return e; }
161 
162 private:
163 
165 
168  double e;
170 };
171 
172 //------------------------------------------------------------------------
173 // StitchingFunction
174 //------------------------------------------------------------------------
175 
177 public:
178 
179  StitchingFunction(Object *funcObj, Dict *dict, int expectedInputs,
180  int expectedOutputs, int recursion);
181  virtual ~StitchingFunction();
182  virtual Function *copy() { return new StitchingFunction(this); }
183  virtual int getType() { return 3; }
184  virtual void transform(double *in, double *out);
185  virtual GBool isOk() { return ok; }
186 
187  int getNumFuncs() { return k; }
188  Function *getFunc(int i) { return funcs[i]; }
189  double *getBounds() { return bounds; }
190  double *getEncode() { return encode; }
191  double *getScale() { return scale; }
192 
193 private:
194 
196 
197  int k;
199  double *bounds;
200  double *encode;
201  double *scale;
203 };
204 
205 //------------------------------------------------------------------------
206 // PostScriptFunction
207 //------------------------------------------------------------------------
208 
210 public:
211 
212  PostScriptFunction(Object *funcObj, Dict *dict);
213  virtual ~PostScriptFunction();
214  virtual Function *copy() { return new PostScriptFunction(this); }
215  virtual int getType() { return 4; }
216  virtual void transform(double *in, double *out);
217  virtual GBool isOk() { return ok; }
218 
220 
221 private:
222 
224  GBool parseCode(GList *tokens, int *tokPtr, int *codePtr);
225  void addCode(int *codePtr, int op);
226  void addCodeI(int *codePtr, int op, int x);
227  void addCodeD(int *codePtr, int op, double x);
229  int exec(double *stack, int sp0);
230 
233  int codeLen;
234  int codeSize;
238 };
239 
240 #endif
Definition: Dict.h:29
virtual Function * copy()
Definition: Function.h:153
double c0[32]
Definition: Function.h:166
double c1[32]
Definition: Function.h:167
ExponentialFunction(Object *funcObj, Dict *dict)
Definition: Function.cc:517
virtual ~ExponentialFunction()
Definition: Function.cc:607
double * getC0()
Definition: Function.h:158
double * getC1()
Definition: Function.h:159
virtual GBool isOk()
Definition: Function.h:156
virtual int getType()
Definition: Function.h:154
virtual void transform(double *in, double *out)
Definition: Function.cc:614
double getRangeMin(int i)
Definition: Function.h:66
static Function * parse(Object *funcObj, int expectedInputs, int expectedOutputs, int recursion=0)
Definition: Function.cc:44
GBool getHasRange()
Definition: Function.h:68
int n
Definition: Function.h:77
double getDomainMax(int i)
Definition: Function.h:65
virtual ~Function()
Definition: Function.cc:41
virtual GBool isOk()=0
virtual int getType()=0
double getDomainMin(int i)
Definition: Function.h:64
int getOutputSize()
Definition: Function.h:62
virtual Function * copy()=0
double getRangeMax(int i)
Definition: Function.h:67
GBool hasRange
Definition: Function.h:82
double range[32][2]
Definition: Function.h:81
GBool init(Dict *dict)
Definition: Function.cc:108
virtual void transform(double *in, double *out)=0
int m
Definition: Function.h:77
int getInputSize()
Definition: Function.h:61
Function()
Definition: Function.cc:38
double domain[32][2]
Definition: Function.h:79
Definition: GList.h:24
virtual Function * copy()
Definition: Function.h:94
virtual void transform(double *in, double *out)
Definition: Function.cc:201
virtual ~IdentityFunction()
Definition: Function.cc:198
virtual int getType()
Definition: Function.h:95
virtual GBool isOk()
Definition: Function.h:97
Definition: Object.h:84
virtual GBool isOk()
Definition: Function.h:217
double cacheOut[32]
Definition: Function.h:236
void addCodeI(int *codePtr, int op, int x)
Definition: Function.cc:1154
GString * codeString
Definition: Function.h:231
GString * getToken(Stream *str)
Definition: Function.cc:1182
double cacheIn[32]
Definition: Function.h:235
virtual void transform(double *in, double *out)
Definition: Function.cc:998
void addCodeD(int *codePtr, int op, double x)
Definition: Function.cc:1168
int exec(double *stack, int sp0)
Definition: Function.cc:1231
GString * getCodeString()
Definition: Function.h:219
PostScriptFunction(Object *funcObj, Dict *dict)
Definition: Function.cc:919
virtual int getType()
Definition: Function.h:215
GBool parseCode(GList *tokens, int *tokPtr, int *codePtr)
Definition: Function.cc:1048
virtual Function * copy()
Definition: Function.h:214
void addCode(int *codePtr, int op)
Definition: Function.cc:1141
virtual ~PostScriptFunction()
Definition: Function.cc:991
SampledFunction(Object *funcObj, Dict *dict)
Definition: Function.cc:213
double cacheOut[32]
Definition: Function.h:140
int * idxOffset
Definition: Function.h:135
int getSampleSize(int i)
Definition: Function.h:116
double * getSamples()
Definition: Function.h:121
virtual void transform(double *in, double *out)
Definition: Function.cc:436
double getEncodeMin(int i)
Definition: Function.h:117
int sampleSize[32]
Definition: Function.h:128
double getDecodeMin(int i)
Definition: Function.h:119
double getDecodeMax(int i)
Definition: Function.h:120
double inputMul[32]
Definition: Function.h:134
virtual GBool isOk()
Definition: Function.h:114
virtual int getType()
Definition: Function.h:112
double encode[32][2]
Definition: Function.h:130
double * samples
Definition: Function.h:136
double cacheIn[32]
Definition: Function.h:139
double decode[32][2]
Definition: Function.h:132
virtual ~SampledFunction()
Definition: Function.cc:415
virtual Function * copy()
Definition: Function.h:111
double getEncodeMax(int i)
Definition: Function.h:118
double * sBuf
Definition: Function.h:138
virtual Function * copy()
Definition: Function.h:182
Function ** funcs
Definition: Function.h:198
double * bounds
Definition: Function.h:199
virtual ~StitchingFunction()
Definition: Function.cc:771
double * scale
Definition: Function.h:201
Function * getFunc(int i)
Definition: Function.h:188
double * getScale()
Definition: Function.h:191
StitchingFunction(Object *funcObj, Dict *dict, int expectedInputs, int expectedOutputs, int recursion)
Definition: Function.cc:642
double * getBounds()
Definition: Function.h:189
virtual void transform(double *in, double *out)
Definition: Function.cc:787
virtual int getType()
Definition: Function.h:183
double * encode
Definition: Function.h:200
virtual GBool isOk()
Definition: Function.h:185
double * getEncode()
Definition: Function.h:190
Definition: Stream.h:67
int GBool
Definition: gtypes.h:16
#define gTrue
Definition: gtypes.h:17
FILE * out
Definition: hbf2gf.c:286
small capitals from c petite p scientific i
Definition: afcover.h:80
#define funcMaxOutputs
Definition: Function.h:31
#define funcMaxInputs
Definition: Function.h:30
static luaL_Reg func[]
Definition: except.c:32
float x
Definition: cordic.py:15
#define str(s)
Definition: sh6.c:399
static FILE * in
Definition: squeeze.c:36
Definition: sh.h:1226
Definition: spc_misc.c:56