#include <cstdio>
#include "cluster.h"
#include "serialis.h"
Go to the source code of this file.
◆ ReadParamDesc()
This routine reads textual descriptions of sets of parameters which describe the characteristics of feature dimensions.
- Parameters
-
fp | open text file to read N parameter descriptions from |
N | number of parameter descriptions to read |
- Returns
- Pointer to an array of parameter descriptors.
- Note
- Globals: None
Definition at line 140 of file clusttool.cpp.
144 for (
int i = 0; i < N; i++) {
146 char line[kMaxLineSize];
148 std::istringstream stream(line);
150 stream.imbue(std::locale::classic());
151 std::string linear_token;
152 stream >> linear_token;
153 std::string essential_token;
154 stream >> essential_token;
155 stream >> ParamDesc[i].
Min;
156 stream >> ParamDesc[i].
Max;
158 ParamDesc[i].
Circular = (linear_token[0] ==
'c');
159 ParamDesc[i].
NonEssential = (essential_token[0] !=
'e');
160 ParamDesc[i].
Range = ParamDesc[i].
Max - ParamDesc[i].
Min;
162 ParamDesc[i].
MidRange = (ParamDesc[i].
Max + ParamDesc[i].
Min) / 2;
#define TOKENSIZE
max size of tokens read from an input file
char * FGets(char *buffer, int buffer_size)
◆ ReadPrototype()
This routine reads a textual description of a prototype from the specified file.
- Parameters
-
fp | open text file to read prototype from |
N | number of dimensions used in prototype |
- Returns
- List of prototypes
- Note
- Globals: None
Definition at line 176 of file clusttool.cpp.
183 char line[kMaxLineSize];
184 if (fp->
FGets(line, kMaxLineSize) ==
nullptr ||
186 sig_token, shape_token, &SampleCount) != 3) {
187 tprintf(
"Invalid prototype: %s\n", line);
194 switch (shape_token[0]) {
205 tprintf(
"Invalid prototype style specification:%s\n", shape_token);
212 Proto->
Mean = ReadNFloats(fp, N,
nullptr);
215 switch (Proto->
Style) {
231 for (i = 0; i < N; i++) {
242 tprintf(
"Invalid prototype style\n");
DLLSYM void tprintf(const char *format,...)
#define TOKENSIZE
max size of tokens read from an input file
char * FGets(char *buffer, int buffer_size)
◆ ReadSampleSize()
uint16_t ReadSampleSize |
( |
TFile * |
fp | ) |
|
This routine reads a single integer from the specified file and checks to ensure that it is between 0 and MAXSAMPLESIZE.
- Parameters
-
fp | open text file to read sample size from |
- Returns
- Sample size
- Note
- Globals: None
Definition at line 120 of file clusttool.cpp.
123 const int kMaxLineSize = 100;
124 char line[kMaxLineSize];
#define MAXSAMPLESIZE
max num of dimensions in feature space
char * FGets(char *buffer, int buffer_size)
◆ WriteParamDesc()
void WriteParamDesc |
( |
FILE * |
File, |
|
|
uint16_t |
N, |
|
|
const PARAM_DESC |
ParamDesc[] |
|
) |
| |
This routine writes an array of dimension descriptors to the specified text file.
- Parameters
-
File | open text file to write param descriptors to |
N | number of param descriptors to write |
ParamDesc | array of param descriptors to write |
Definition at line 255 of file clusttool.cpp.
258 for (i = 0; i < N; i++) {
259 if (ParamDesc[i].Circular)
260 fprintf (File,
"circular ");
262 fprintf (File,
"linear ");
264 if (ParamDesc[i].NonEssential)
265 fprintf (File,
"non-essential ");
267 fprintf (File,
"essential ");
269 fprintf (File,
"%10.6f %10.6f\n", ParamDesc[i].Min, ParamDesc[i].Max);
◆ WritePrototype()
void WritePrototype |
( |
FILE * |
File, |
|
|
uint16_t |
N, |
|
|
PROTOTYPE * |
Proto |
|
) |
| |
This routine writes a textual description of a prototype to the specified text file.
- Parameters
-
File | open text file to write prototype to |
N | number of dimensions in feature space |
Proto | prototype to write out |
Definition at line 280 of file clusttool.cpp.
284 fprintf (File,
"significant ");
286 fprintf (File,
"insignificant ");
287 WriteProtoStyle (File, static_cast<PROTOSTYLE>(Proto->
Style));
289 WriteNFloats (File, N, Proto->
Mean);
290 fprintf (File,
"\t");
292 switch (Proto->
Style) {
300 for (i = 0; i < N; i++)
303 fprintf (File,
" %9s",
"normal");
306 fprintf (File,
" %9s",
"uniform");
309 fprintf (File,
" %9s",
"random");
314 fprintf (File,
"\n\t");