27 #define TOKENSIZE 80 //< max size of tokens read from an input file 28 #define QUOTED_TOKENSIZE "79" 29 #define MAXSAMPLESIZE 65535 //< max num of dimensions in feature space 44 const int kMaxLineSize = 100;
45 char line[kMaxLineSize];
66 for (
int i = 0; i < N; i++) {
68 char line[kMaxLineSize];
72 linear_token, essential_token, &ParamDesc[i].Min,
73 &ParamDesc[i].Max) == 4);
74 if (linear_token[0] ==
'c')
79 if (linear_token[0] ==
'e')
83 ParamDesc[i].
Range = ParamDesc[i].
Max - ParamDesc[i].
Min;
106 char line[kMaxLineSize];
107 if (fp->
FGets(line, kMaxLineSize) ==
nullptr ||
109 sig_token, shape_token, &SampleCount) != 3) {
110 tprintf(
"Invalid prototype: %s\n", line);
115 if (sig_token[0] ==
's')
120 switch (shape_token[0]) {
131 tprintf(
"Invalid prototype style specification:%s\n", shape_token);
141 switch (Proto->
Style) {
157 for (i = 0; i < N; i++) {
168 tprintf(
"Invalid prototype style\n");
187 const int kMaxLineSize = 1024;
188 char line[kMaxLineSize];
189 if (fp->
FGets(line, kMaxLineSize) ==
nullptr) {
190 tprintf(
"Hit EOF in ReadNFloats!\n");
193 bool needs_free =
false;
195 if (Buffer ==
nullptr) {
196 Buffer =
static_cast<float *
>(
Emalloc(N *
sizeof(
float)));
200 char *startptr = line;
201 for (
int i = 0; i < N; i++) {
203 Buffer[i] = strtof(startptr, &endptr);
204 if (endptr == startptr) {
205 tprintf(
"Read of %d floats failed!\n", N);
206 if (needs_free)
Efree(Buffer);
226 for (i = 0; i < N; i++) {
227 if (ParamDesc[i].Circular)
228 fprintf (File,
"circular ");
230 fprintf (File,
"linear ");
232 if (ParamDesc[i].NonEssential)
233 fprintf (File,
"non-essential ");
235 fprintf (File,
"essential ");
237 fprintf (File,
"%10.6f %10.6f\n", ParamDesc[i].Min, ParamDesc[i].Max);
254 fprintf (File,
"significant ");
256 fprintf (File,
"insignificant ");
260 fprintf (File,
"\t");
262 switch (Proto->
Style) {
270 for (i = 0; i < N; i++)
273 fprintf (File,
" %9s",
"normal");
276 fprintf (File,
" %9s",
"uniform");
279 fprintf (File,
" %9s",
"random");
284 fprintf (File,
"\n\t");
299 for (
int i = 0; i < N; i++)
300 fprintf(File,
" %9.6f", Array[i]);
314 switch (ProtoStyle) {
316 fprintf (File,
"spherical");
319 fprintf (File,
"elliptical");
322 fprintf (File,
"mixed");
325 fprintf (File,
"automatic");
346 LIST ProtoList,
bool WriteSigProtos,
347 bool WriteInsigProtos) {
351 fprintf(File,
"%0d\n",N);
uint16_t ReadSampleSize(TFile *fp)
char * FGets(char *buffer, int buffer_size)
void WritePrototype(FILE *File, uint16_t N, PROTOTYPE *Proto)
PROTOTYPE * ReadPrototype(TFile *fp, uint16_t N)
void WriteParamDesc(FILE *File, uint16_t N, const PARAM_DESC ParamDesc[])
float * ReadNFloats(TFile *fp, uint16_t N, float Buffer[])
void WriteProtoList(FILE *File, uint16_t N, PARAM_DESC *ParamDesc, LIST ProtoList, bool WriteSigProtos, bool WriteInsigProtos)
DLLSYM void tprintf(const char *format,...)
void WriteProtoStyle(FILE *File, PROTOSTYLE ProtoStyle)
PARAM_DESC * ReadParamDesc(TFile *fp, uint16_t N)
void WriteNFloats(FILE *File, uint16_t N, float Array[])