Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 50331
Collapse All | Expand All

(-)speech_tools/base_class/EST_TMatrix.cc (-29 / +29 lines)
Lines 101-107 T &EST_TMatrix<T>::a_check(int row, int Link Here
101
{
101
{
102
102
103
  if (!EST_matrix_bounds_check(row, col, num_rows(), num_columns(), FALSE))
103
  if (!EST_matrix_bounds_check(row, col, num_rows(), num_columns(), FALSE))
104
    return *error_return;
104
    return *this->error_return;
105
    
105
    
106
  return a_no_check(row,col);
106
  return a_no_check(row,col);
107
}
107
}
Lines 212-220 void EST_TMatrix<T>::just_resize(int new Link Here
212
{
212
{
213
    T *new_m;
213
    T *new_m;
214
214
215
    if (num_rows() != new_rows || num_columns() != new_cols || p_memory == NULL )
215
    if (num_rows() != new_rows || num_columns() != new_cols || this->p_memory == NULL )
216
      {
216
      {
217
	if (p_sub_matrix)
217
	if (this->p_sub_matrix)
218
	  EST_error("Attempt to resize Sub-Matrix");
218
	  EST_error("Attempt to resize Sub-Matrix");
219
219
220
	if (new_cols < 0 || new_rows < 0)
220
	if (new_cols < 0 || new_rows < 0)
Lines 225-246 void EST_TMatrix<T>::just_resize(int new Link Here
225
	
225
	
226
	new_m = new T[new_rows*new_cols];
226
	new_m = new T[new_rows*new_cols];
227
227
228
	if (p_memory != NULL)
228
	if (this->p_memory != NULL)
229
	  if (old_vals != NULL)
229
	  if (old_vals != NULL)
230
	    *old_vals = p_memory;
230
	    *old_vals = this->p_memory;
231
	  else  if (!p_sub_matrix)
231
	  else  if (!this->p_sub_matrix)
232
	    delete [] (p_memory-p_offset);
232
	    delete [] (this->p_memory-this->p_offset);
233
    
233
    
234
	p_num_rows = new_rows;
234
	p_num_rows = new_rows;
235
	p_num_columns = new_cols;
235
	this->p_num_columns = new_cols;
236
	p_offset=0;
236
	this->p_offset=0;
237
	p_row_step=p_num_columns; 
237
	p_row_step=this->p_num_columns; 
238
	p_column_step=1;
238
	this->p_column_step=1;
239
	
239
	
240
	p_memory = new_m;
240
	this->p_memory = new_m;
241
      }
241
      }
242
    else
242
    else
243
      *old_vals = p_memory;
243
      *old_vals = this->p_memory;
244
	
244
	
245
}
245
}
246
246
Lines 248-259 template<class T> Link Here
248
void EST_TMatrix<T>::resize(int new_rows, int new_cols, int set)
248
void EST_TMatrix<T>::resize(int new_rows, int new_cols, int set)
249
{
249
{
250
  int i,j;
250
  int i,j;
251
  T * old_vals = p_memory;
251
  T * old_vals = this->p_memory;
252
  int old_rows = num_rows();
252
  int old_rows = num_rows();
253
  int old_cols = num_columns();
253
  int old_cols = num_columns();
254
  int old_row_step = p_row_step;
254
  int old_row_step = p_row_step;
255
  int old_offset = p_offset;
255
  int old_offset = this->p_offset;
256
  int old_column_step = p_column_step;
256
  int old_column_step = this->p_column_step;
257
257
258
  if (new_rows<0)
258
  if (new_rows<0)
259
    new_rows = old_rows;
259
    new_rows = old_rows;
Lines 285-311 void EST_TMatrix<T>::resize(int new_rows Link Here
285
      
285
      
286
      for(i=0; i<copy_r; i++)
286
      for(i=0; i<copy_r; i++)
287
	for(j=copy_c; j<new_cols; j++)
287
	for(j=copy_c; j<new_cols; j++)
288
	  a_no_check(i,j) =  *def_val;
288
	  a_no_check(i,j) =  *this->def_val;
289
      
289
      
290
      for(i=copy_r; i<new_rows; i++)
290
      for(i=copy_r; i<new_rows; i++)
291
	for(j=0; j<new_cols; j++)
291
	for(j=0; j<new_cols; j++)
292
	  a_no_check(i,j) =  *def_val;
292
	  a_no_check(i,j) =  *this->def_val;
293
    }
293
    }
294
294
295
  if (old_vals && old_vals != p_memory && !p_sub_matrix)
295
  if (old_vals && old_vals != this->p_memory && !this->p_sub_matrix)
296
    delete [] (old_vals-old_offset);
296
    delete [] (old_vals-old_offset);
297
}
297
}
298
298
299
template<class T>
299
template<class T>
300
bool EST_TMatrix<T>::have_rows_before(int n) const
300
bool EST_TMatrix<T>::have_rows_before(int n) const
301
{
301
{
302
  return p_offset >= n*p_row_step;
302
  return this->p_offset >= n*p_row_step;
303
}
303
}
304
304
305
template<class T>
305
template<class T>
306
bool EST_TMatrix<T>::have_columns_before(int n) const
306
bool EST_TMatrix<T>::have_columns_before(int n) const
307
{
307
{
308
  return p_offset >= n*p_column_step;
308
  return this->p_offset >= n*this->p_column_step;
309
}
309
}
310
310
311
template<class T>
311
template<class T>
Lines 506-517 void EST_TMatrix<T>::row(EST_TVector<T> Link Here
506
506
507
  rv.p_sub_matrix = TRUE;
507
  rv.p_sub_matrix = TRUE;
508
  rv.p_num_columns = len;
508
  rv.p_num_columns = len;
509
  rv.p_offset = p_offset + start_c*p_column_step + r*p_row_step;
509
  rv.p_offset = this->p_offset + start_c*this->p_column_step + r*p_row_step;
510
  rv.p_memory = p_memory - p_offset + rv.p_offset;
510
  rv.p_memory = this->p_memory - this->p_offset + rv.p_offset;
511
//  cout << "mrow: mem: " << rv.p_memory << " (" << (int)rv.p_memory << ")\n";
511
//  cout << "mrow: mem: " << rv.p_memory << " (" << (int)rv.p_memory << ")\n";
512
//  cout << "mrow: ofset: " << rv.p_offset << " (" << (int)rv.p_offset << ")\n";
512
//  cout << "mrow: ofset: " << rv.p_offset << " (" << (int)rv.p_offset << ")\n";
513
513
514
  rv.p_column_step=p_column_step;
514
  rv.p_column_step=this->p_column_step;
515
}
515
}
516
516
517
template<class T>
517
template<class T>
Lines 528-535 void EST_TMatrix<T>::column(EST_TVector< Link Here
528
528
529
  cv.p_sub_matrix = TRUE;
529
  cv.p_sub_matrix = TRUE;
530
  cv.p_num_columns = len;
530
  cv.p_num_columns = len;
531
  cv.p_offset = p_offset + c*p_column_step + start_r*p_row_step;
531
  cv.p_offset = this->p_offset + c*this->p_column_step + start_r*p_row_step;
532
  cv.p_memory = p_memory -p_offset + cv.p_offset;
532
  cv.p_memory = this->p_memory -this->p_offset + cv.p_offset;
533
//  cout << "mcol: mem: " << cv.p_memory << " (" << (int)cv.p_memory << ")\n";
533
//  cout << "mcol: mem: " << cv.p_memory << " (" << (int)cv.p_memory << ")\n";
534
//  cout << "mcol: offset: " << cv.p_offset << " (" << (int)cv.p_offset << ")\n";
534
//  cout << "mcol: offset: " << cv.p_offset << " (" << (int)cv.p_offset << ")\n";
535
535
Lines 552-561 void EST_TMatrix<T>::sub_matrix(EST_TMat Link Here
552
    delete [] (sm.p_memory - sm.p_offset);
552
    delete [] (sm.p_memory - sm.p_offset);
553
553
554
  sm.p_sub_matrix = TRUE;
554
  sm.p_sub_matrix = TRUE;
555
  sm.p_offset =  p_offset + c*p_column_step + r*p_row_step;
555
  sm.p_offset =  this->p_offset + c*this->p_column_step + r*p_row_step;
556
  sm.p_memory = p_memory - p_offset + sm.p_offset;
556
  sm.p_memory = this->p_memory - this->p_offset + sm.p_offset;
557
  sm.p_row_step=p_row_step;
557
  sm.p_row_step=p_row_step;
558
  sm.p_column_step=p_column_step;
558
  sm.p_column_step=this->p_column_step;
559
  sm.p_num_rows = len_r;
559
  sm.p_num_rows = len_r;
560
  sm.p_num_columns = len_c;
560
  sm.p_num_columns = len_c;
561
  
561
  
(-)speech_tools/base_class/EST_TNamedEnum.cc (-27 / +27 lines)
Lines 186-196 EST_read_status EST_TNamedEnum<ENUM>::pr Link Here
186
  if ((file=fopen(name, "rb"))==NULL)
186
  if ((file=fopen(name, "rb"))==NULL)
187
    return misc_read_error;
187
    return misc_read_error;
188
188
189
  if (definitions)
189
  if (this->definitions)
190
    delete[] definitions;
190
    delete[] this->definitions;
191
191
192
  ndefinitions= -1;
192
  this->ndefinitions= -1;
193
  definitions=NULL;
193
  this->definitions=NULL;
194
194
195
  buffer[LINE_LENGTH-1] = 'x';
195
  buffer[LINE_LENGTH-1] = 'x';
196
196
Lines 202-228 EST_read_status EST_TNamedEnum<ENUM>::pr Link Here
202
	  return wrong_format;
202
	  return wrong_format;
203
	}
203
	}
204
204
205
      if (ndefinitions>=0 && quote != '\0' && buffer[0] == '=')
205
      if (this->ndefinitions>=0 && quote != '\0' && buffer[0] == '=')
206
	{
206
	{
207
	  // definition by number
207
	  // definition by number
208
208
209
	  if ( n>= ndefinitions)
209
	  if ( n>= this->ndefinitions)
210
	    {
210
	    {
211
	      cerr << "too many definitions\n";
211
	      cerr << "too many definitions\n";
212
	      return wrong_format;
212
	      return wrong_format;
213
	    }
213
	    }
214
214
215
	  int ntokens = split(line, tokens, NAMED_ENUM_MAX_SYNONYMS+2, RXwhite, '"');
215
	  int ntokens = split(line, tokens, NAMED_ENUM_MAX_SYNONYMS+2, RXwhite, '"');
216
	  definitions[n].token = (ENUM)atoi(tokens[0].after(0,1));
216
	  this->definitions[n].token = (ENUM)atoi(tokens[0].after(0,1));
217
217
218
	  for(int i=1; i<ntokens; i++)
218
	  for(int i=1; i<ntokens; i++)
219
	      definitions[n].values[i-1] = wstrdup(tokens[i].unquote_if_needed(quote));
219
	      this->definitions[n].values[i-1] = wstrdup(tokens[i].unquote_if_needed(quote));
220
	  for(int j=ntokens-1 ; j< NAMED_ENUM_MAX_SYNONYMS; j++)
220
	  for(int j=ntokens-1 ; j< NAMED_ENUM_MAX_SYNONYMS; j++)
221
	    definitions[n].values[j]=NULL;
221
	    this->definitions[n].values[j]=NULL;
222
222
223
	  n++;
223
	  n++;
224
	}
224
	}
225
      else if (have_unknown && ndefinitions>=0 && quote != '\0' && buffer[0] == quote)
225
      else if (have_unknown && this->ndefinitions>=0 && quote != '\0' && buffer[0] == quote)
226
	{
226
	{
227
	  // definition by standard name
227
	  // definition by standard name
228
	  if (!definitive)
228
	  if (!definitive)
Lines 230-236 EST_read_status EST_TNamedEnum<ENUM>::pr Link Here
230
	      cerr << "can't use names in this definition\n";
230
	      cerr << "can't use names in this definition\n";
231
	      return wrong_format;
231
	      return wrong_format;
232
	    }
232
	    }
233
	  if ( n>= ndefinitions)
233
	  if ( n>= this->ndefinitions)
234
	    {
234
	    {
235
	      cerr << "too many definitions\n";
235
	      cerr << "too many definitions\n";
236
	      return wrong_format;
236
	      return wrong_format;
Lines 238-249 EST_read_status EST_TNamedEnum<ENUM>::pr Link Here
238
238
239
	  int ntokens = split(line, tokens, NAMED_ENUM_MAX_SYNONYMS+2, RXwhite, quote);
239
	  int ntokens = split(line, tokens, NAMED_ENUM_MAX_SYNONYMS+2, RXwhite, quote);
240
240
241
	  definitions[n].token = definitive->token(tokens[0].unquote(quote));
241
	  this->definitions[n].token = definitive->token(tokens[0].unquote(quote));
242
242
243
	  for(int i=1; i<ntokens; i++)
243
	  for(int i=1; i<ntokens; i++)
244
	    definitions[n].values[i-1] = wstrdup(tokens[i].unquote_if_needed(quote));
244
	    this->definitions[n].values[i-1] = wstrdup(tokens[i].unquote_if_needed(quote));
245
	  for(int j=ntokens-1 ; j< NAMED_ENUM_MAX_SYNONYMS; j++)
245
	  for(int j=ntokens-1 ; j< NAMED_ENUM_MAX_SYNONYMS; j++)
246
	    definitions[n].values[j]=NULL;
246
	    this->definitions[n].values[j]=NULL;
247
247
248
	  n++;
248
	  n++;
249
	}
249
	}
Lines 269-284 EST_read_status EST_TNamedEnum<ENUM>::pr Link Here
269
	    }
269
	    }
270
	  else if (key == "number")
270
	  else if (key == "number")
271
	    {
271
	    {
272
	      ndefinitions=atoi(line.after(eq,1));
272
	      this->ndefinitions=atoi(line.after(eq,1));
273
	      // cout << "n = '" << ndefinitions << "'\n";
273
	      // cout << "n = '" << ndefinitions << "'\n";
274
	      definitions = new Defn[ndefinitions];
274
	      this->definitions = new Defn[this->ndefinitions];
275
	      for(int i=0; i<ndefinitions; i++)
275
	      for(int i=0; i<this->ndefinitions; i++)
276
		definitions[i].values[0] =NULL;
276
		this->definitions[i].values[0] =NULL;
277
	      n=0;
277
	      n=0;
278
	    }
278
	    }
279
	  else if (key == "unknown")
279
	  else if (key == "unknown")
280
	    {
280
	    {
281
	      p_unknown_enum=(ENUM)atoi(line.after(eq,1));
281
	      this->p_unknown_enum=(ENUM)atoi(line.after(eq,1));
282
	      // cout << "unknown = '" << p_unknown_enum << "'\n";
282
	      // cout << "unknown = '" << p_unknown_enum << "'\n";
283
	      have_unknown=1;
283
	      have_unknown=1;
284
	    }
284
	    }
Lines 305-324 EST_write_status EST_TNamedEnum<ENUM>::p Link Here
305
  if ((file=fopen(name, "wb"))==NULL)
305
  if ((file=fopen(name, "wb"))==NULL)
306
    return write_fail;
306
    return write_fail;
307
307
308
  fprintf(file, "unknown=%d\n", p_unknown_enum);
308
  fprintf(file, "unknown=%d\n", this->p_unknown_enum);
309
  fprintf(file, "quote=%c\n", quote);
309
  fprintf(file, "quote=%c\n", quote);
310
  fprintf(file, "number=%d\n", ndefinitions);
310
  fprintf(file, "number=%d\n", this->ndefinitions);
311
311
312
  for(int i=0; i<ndefinitions; i++)
312
  for(int i=0; i<this->ndefinitions; i++)
313
    if (definitions[i].values[0])
313
    if (this->definitions[i].values[0])
314
      {
314
      {
315
	if (definitive)
315
	if (definitive)
316
	  fprintf(file, "%s ", (const char *)EST_String(definitive->name(definitions[i].token)).quote(quote));
316
	  fprintf(file, "%s ", (const char *)EST_String(definitive->name(this->definitions[i].token)).quote(quote));
317
	else
317
	else
318
	  fprintf(file, "=%d ", (int)definitions[i].token);
318
	  fprintf(file, "=%d ", (int)this->definitions[i].token);
319
319
320
	for(int j=0; j<NAMED_ENUM_MAX_SYNONYMS && definitions[i].values[j] != NULL; j++)
320
	for(int j=0; j<NAMED_ENUM_MAX_SYNONYMS && this->definitions[i].values[j] != NULL; j++)
321
	  fprintf(file, "%s ", (const char *) EST_String(definitions[i].values[j]).quote_if_needed(quote));
321
	  fprintf(file, "%s ", (const char *) EST_String(this->definitions[i].values[j]).quote_if_needed(quote));
322
      
322
      
323
	fputc('\n', file);
323
	fputc('\n', file);
324
      }
324
      }
(-)speech_tools/base_class/EST_TSimpleMatrix.cc (-26 / +26 lines)
Lines 49-71 Link Here
49
template<class T> 
49
template<class T> 
50
void EST_TSimpleMatrix<T>::copy_data(const EST_TSimpleMatrix<T> &a)
50
void EST_TSimpleMatrix<T>::copy_data(const EST_TSimpleMatrix<T> &a)
51
{
51
{
52
  if (!a.p_sub_matrix && !p_sub_matrix)
52
  if (!a.p_sub_matrix && !this->p_sub_matrix)
53
    memcpy((void *)&a_no_check(0,0),
53
    memcpy((void *)&this->a_no_check(0,0),
54
	   (const void *)&a.a_no_check(0,0),
54
	   (const void *)&a.a_no_check(0,0),
55
	   num_rows()*num_columns()*sizeof(T)
55
	   this->num_rows()*this->num_columns()*sizeof(T)
56
	   );
56
	   );
57
  else
57
  else
58
    {
58
    {
59
    for (int i = 0; i < num_rows(); ++i)
59
    for (int i = 0; i < this->num_rows(); ++i)
60
      for (int j = 0; j < num_columns(); ++j)
60
      for (int j = 0; j < this->num_columns(); ++j)
61
	a_no_check(i,j) = a.a_no_check(i,j);
61
	this->a_no_check(i,j) = a.a_no_check(i,j);
62
    }
62
    }
63
}
63
}
64
64
65
template<class T> 
65
template<class T> 
66
void EST_TSimpleMatrix<T>::copy(const EST_TSimpleMatrix<T> &a)
66
void EST_TSimpleMatrix<T>::copy(const EST_TSimpleMatrix<T> &a)
67
{
67
{
68
  if (num_rows() != a.num_rows() || num_columns() != a.num_columns())
68
  if (this->num_rows() != a.num_rows() || this->num_columns() != a.num_columns())
69
    resize(a.num_rows(), a.num_columns(), 0);
69
    resize(a.num_rows(), a.num_columns(), 0);
70
  
70
  
71
  copy_data(a);
71
  copy_data(a);
Lines 83-113 void EST_TSimpleMatrix<T>::resize(int ne Link Here
83
				  int set)
83
				  int set)
84
{
84
{
85
  T* old_vals=NULL;
85
  T* old_vals=NULL;
86
  int old_offset = p_offset;
86
  int old_offset = this->p_offset;
87
87
88
  if (new_rows<0)
88
  if (new_rows<0)
89
    new_rows = num_rows();
89
    new_rows = this->num_rows();
90
  if (new_cols<0)
90
  if (new_cols<0)
91
    new_cols = num_columns();
91
    new_cols = this->num_columns();
92
92
93
  if (set)
93
  if (set)
94
    {
94
    {
95
      if (!p_sub_matrix && new_cols == num_columns() && new_rows != num_rows())
95
      if (!this->p_sub_matrix && new_cols == this->num_columns() && new_rows != this->num_rows())
96
	{
96
	{
97
	  int copy_r = Lof(num_rows(), new_rows);
97
	  int copy_r = Lof(this->num_rows(), new_rows);
98
98
99
	  just_resize(new_rows, new_cols, &old_vals);
99
	  just_resize(new_rows, new_cols, &old_vals);
100
100
101
	  memcpy((void *)p_memory, 
101
	  memcpy((void *)this->p_memory, 
102
		 (const void *)old_vals,
102
		 (const void *)old_vals,
103
		 copy_r*new_cols*sizeof(T));
103
		 copy_r*new_cols*sizeof(T));
104
	  
104
	  
105
	  int i,j;
105
	  int i,j;
106
	  
106
	  
107
	  if (new_rows > copy_r)
107
	  if (new_rows > copy_r)
108
	    if (*def_val == 0)
108
	    if (*this->def_val == 0)
109
	      {
109
	      {
110
		memset((void *)(p_memory + copy_r*p_row_step),
110
		memset((void *)(this->p_memory + copy_r*this->p_row_step),
111
		       0,
111
		       0,
112
		       (new_rows-copy_r)*new_cols*sizeof(T));
112
		       (new_rows-copy_r)*new_cols*sizeof(T));
113
	      }
113
	      }
Lines 115-129 void EST_TSimpleMatrix<T>::resize(int ne Link Here
115
	      {
115
	      {
116
		for(j=0; j<new_cols; j++)
116
		for(j=0; j<new_cols; j++)
117
		  for(i=copy_r; i<new_rows; i++)
117
		  for(i=copy_r; i<new_rows; i++)
118
		    a_no_check(i,j) = *def_val;
118
		    this->a_no_check(i,j) = *this->def_val;
119
	      }
119
	      }
120
	}
120
	}
121
      else if (!p_sub_matrix)
121
      else if (!this->p_sub_matrix)
122
	{
122
	{
123
	  int old_row_step = p_row_step;
123
	  int old_row_step = this->p_row_step;
124
	  int old_column_step = p_column_step;
124
	  int old_column_step = this->p_column_step;
125
	  int copy_r = Lof(num_rows(), new_rows);
125
	  int copy_r = Lof(this->num_rows(), new_rows);
126
	  int copy_c = Lof(num_columns(), new_cols);
126
	  int copy_c = Lof(this->num_columns(), new_cols);
127
	  
127
	  
128
	  just_resize(new_rows, new_cols, &old_vals);
128
	  just_resize(new_rows, new_cols, &old_vals);
129
129
Lines 136-147 void EST_TSimpleMatrix<T>::resize(int ne Link Here
136
	  
136
	  
137
	  for(i=0; i<copy_r; i++)
137
	  for(i=0; i<copy_r; i++)
138
	    for(j=copy_c; j<new_cols; j++)
138
	    for(j=copy_c; j<new_cols; j++)
139
	      a_no_check(i,j) =  *def_val;
139
	      this->a_no_check(i,j) =  *this->def_val;
140
	  
140
	  
141
	  if (new_rows > copy_r)
141
	  if (new_rows > copy_r)
142
	    if (*def_val == 0)
142
	    if (*this->def_val == 0)
143
	      {
143
	      {
144
		memset((void *)(p_memory + copy_r*p_row_step),
144
		memset((void *)(this->p_memory + copy_r*this->p_row_step),
145
		       0,
145
		       0,
146
		       (new_rows-copy_r)*new_cols*sizeof(T));
146
		       (new_rows-copy_r)*new_cols*sizeof(T));
147
	      }
147
	      }
Lines 149-155 void EST_TSimpleMatrix<T>::resize(int ne Link Here
149
	      {
149
	      {
150
		for(j=0; j<new_cols; j++)
150
		for(j=0; j<new_cols; j++)
151
		  for(i=copy_r; i<new_rows; i++)
151
		  for(i=copy_r; i<new_rows; i++)
152
		    a_no_check(i,j) = *def_val;
152
		    this->a_no_check(i,j) = *this->def_val;
153
	      }
153
	      }
154
	}
154
	}
155
      else
155
      else
Lines 158-164 void EST_TSimpleMatrix<T>::resize(int ne Link Here
158
  else
158
  else
159
    EST_TMatrix<T>::resize(new_rows, new_cols, 0);
159
    EST_TMatrix<T>::resize(new_rows, new_cols, 0);
160
160
161
  if (old_vals && old_vals != p_memory)
161
  if (old_vals && old_vals != this->p_memory)
162
    delete [] (old_vals-old_offset);
162
    delete [] (old_vals-old_offset);
163
}
163
}
164
164
(-)speech_tools/base_class/EST_TSimpleVector.cc (-24 / +24 lines)
Lines 46-55 Link Here
46
46
47
template<class T> void EST_TSimpleVector<T>::copy(const EST_TSimpleVector<T> &a)
47
template<class T> void EST_TSimpleVector<T>::copy(const EST_TSimpleVector<T> &a)
48
{
48
{
49
  if (p_column_step==1 && a.p_column_step==1)
49
  if (this->p_column_step==1 && a.p_column_step==1)
50
    {
50
    {
51
    resize(a.n(), FALSE);
51
    resize(a.n(), FALSE);
52
    memcpy((void *)(p_memory), (const void *)(a.p_memory), n() * sizeof(T));
52
    memcpy((void *)(this->p_memory), (const void *)(a.p_memory), this->n() * sizeof(T));
53
    }
53
    }
54
else
54
else
55
  ((EST_TVector<T> *)this)->copy(a);
55
  ((EST_TVector<T> *)this)->copy(a);
Lines 57-89 else Link Here
57
57
58
template<class T> EST_TSimpleVector<T>::EST_TSimpleVector(const EST_TSimpleVector<T> &in)
58
template<class T> EST_TSimpleVector<T>::EST_TSimpleVector(const EST_TSimpleVector<T> &in)
59
{
59
{
60
    default_vals();    
60
    this->default_vals();    
61
    copy(in);
61
    copy(in);
62
}
62
}
63
63
64
// should copy from and delete old version first
64
// should copy from and delete old version first
65
template<class T> void EST_TSimpleVector<T>::resize(int newn, int set)
65
template<class T> void EST_TSimpleVector<T>::resize(int newn, int set)
66
{
66
{
67
  int oldn = n();
67
  int oldn = this->n();
68
  T *old_vals =NULL;
68
  T *old_vals =NULL;
69
  int old_offset = p_offset;
69
  int old_offset = this->p_offset;
70
70
71
  just_resize(newn, &old_vals);
71
  just_resize(newn, &old_vals);
72
72
73
  if (set && old_vals)
73
  if (set && old_vals)
74
    {
74
    {
75
      int copy_c = 0;
75
      int copy_c = 0;
76
      if (p_memory != NULL)
76
      if (this->p_memory != NULL)
77
	{
77
	{
78
	  copy_c = Lof(n(), oldn);
78
	  copy_c = Lof(this->n(), oldn);
79
	  memcpy((void *)p_memory, (const void *)old_vals,  copy_c* sizeof(T));
79
	  memcpy((void *)this->p_memory, (const void *)old_vals,  copy_c* sizeof(T));
80
	}
80
	}
81
      
81
      
82
      for (int i=copy_c; i < n(); ++i)
82
      for (int i=copy_c; i < this->n(); ++i)
83
	p_memory[i] = *def_val;
83
	this->p_memory[i] = *this->def_val;
84
    }
84
    }
85
  
85
  
86
  if (old_vals != NULL && old_vals != p_memory && !p_sub_matrix)
86
  if (old_vals != NULL && old_vals != this->p_memory && !this->p_sub_matrix)
87
    delete [] (old_vals - old_offset);
87
    delete [] (old_vals - old_offset);
88
88
89
}
89
}
Lines 92-123 template<class T> Link Here
92
void EST_TSimpleVector<T>::copy_section(T* dest, int offset, int num) const
92
void EST_TSimpleVector<T>::copy_section(T* dest, int offset, int num) const
93
{
93
{
94
  if (num<0)
94
  if (num<0)
95
    num = num_columns()-offset;
95
    num = this->num_columns()-offset;
96
96
97
  if (!EST_vector_bounds_check(num+offset-1, num_columns(), FALSE))
97
  if (!EST_vector_bounds_check(num+offset-1, this->num_columns(), FALSE))
98
    return;
98
    return;
99
99
100
  if (!p_sub_matrix && p_column_step==1)
100
  if (!this->p_sub_matrix && this->p_column_step==1)
101
    memcpy((void *)dest, (const void *)(p_memory+offset), num*sizeof(T));
101
    memcpy((void *)dest, (const void *)(this->p_memory+offset), num*sizeof(T));
102
  else
102
  else
103
    for(int i=0; i<num; i++)
103
    for(int i=0; i<num; i++)
104
      dest[i] = a_no_check(offset+i);
104
      dest[i] = this->a_no_check(offset+i);
105
}
105
}
106
106
107
template<class T>
107
template<class T>
108
void EST_TSimpleVector<T>::set_section(const T* src, int offset, int num)
108
void EST_TSimpleVector<T>::set_section(const T* src, int offset, int num)
109
{
109
{
110
  if (num<0)
110
  if (num<0)
111
    num = num_columns()-offset;
111
    num = this->num_columns()-offset;
112
112
113
  if (!EST_vector_bounds_check(num+offset-1, num_columns(), FALSE))
113
  if (!EST_vector_bounds_check(num+offset-1, this->num_columns(), FALSE))
114
    return;
114
    return;
115
  
115
  
116
  if (!p_sub_matrix && p_column_step==1)
116
  if (!this->p_sub_matrix && this->p_column_step==1)
117
    memcpy((void *)(p_memory+offset), (void *)src, num*sizeof(T));
117
    memcpy((void *)(this->p_memory+offset), (void *)src, num*sizeof(T));
118
  else
118
  else
119
    for(int i=0; i<num; i++)
119
    for(int i=0; i<num; i++)
120
      a_no_check(offset+i) = src[i];
120
      this->a_no_check(offset+i) = src[i];
121
}
121
}
122
122
123
template<class T> EST_TSimpleVector<T> &EST_TSimpleVector<T>::operator=(const EST_TSimpleVector<T> &in)
123
template<class T> EST_TSimpleVector<T> &EST_TSimpleVector<T>::operator=(const EST_TSimpleVector<T> &in)
Lines 128-136 template<class T> EST_TSimpleVector<T> & Link Here
128
128
129
template<class T> void EST_TSimpleVector<T>::zero()
129
template<class T> void EST_TSimpleVector<T>::zero()
130
{
130
{
131
  if (p_column_step==1)
131
  if (this->p_column_step==1)
132
    memset((void *)(p_memory), 0, n() * sizeof(T));
132
    memset((void *)(this->p_memory), 0, this->n() * sizeof(T));
133
  else
133
  else
134
    ((EST_TVector<T> *)this)->fill(*def_val);
134
    ((EST_TVector<T> *)this)->fill(*this->def_val);
135
}
135
}
136
136
(-)speech_tools/base_class/EST_Tvectlist.cc (+2 lines)
Lines 39-44 Link Here
39
/*=======================================================================*/
39
/*=======================================================================*/
40
#include <fstream.h>
40
#include <fstream.h>
41
#include "EST_TVector.h"
41
#include "EST_TVector.h"
42
#include "EST_TList.h"
42
#include "EST_cutils.h"
43
#include "EST_cutils.h"
43
44
44
template<class T> 
45
template<class T> 
Lines 57-62 template<class T> EST_TVector<T> &copy(E Link Here
57
{
58
{
58
    a.resize(in.length(), FALSE);
59
    a.resize(in.length(), FALSE);
59
    EST_Litem *p;
60
    EST_Litem *p;
61
	int i;
60
    for (i = 0, p = in.head(); p!= 0; p = next(p), ++i)
62
    for (i = 0, p = in.head(); p!= 0; p = next(p), ++i)
61
	a[i] = in.item(p);
63
	a[i] = in.item(p);
62
64
(-)speech_tools/base_class/inst_tmpl/hash_fi_t.cc (-1 / +1 lines)
Lines 38-44 Link Here
38
#include "EST_String.h"
38
#include "EST_String.h"
39
#include "EST_THash.h"
39
#include "EST_THash.h"
40
40
41
Declare_THash(float, int)
41
Declare_THash_Base(float, int, 0.0, 0, NULL)
42
42
43
#if defined(INSTANTIATE_TEMPLATES)
43
#if defined(INSTANTIATE_TEMPLATES)
44
44
(-)speech_tools/base_class/inst_tmpl/hash_ii_t.cc (-1 / +1 lines)
Lines 38-44 Link Here
38
#include "EST_String.h"
38
#include "EST_String.h"
39
#include "EST_THash.h"
39
#include "EST_THash.h"
40
40
41
Declare_THash(int,int)
41
Declare_THash_Base(int,int,0,0,NULL)
42
42
43
#if defined(INSTANTIATE_TEMPLATES)
43
#if defined(INSTANTIATE_TEMPLATES)
44
44
(-)speech_tools/base_class/inst_tmpl/hash_iv_t.cc (-1 / +1 lines)
Lines 42-48 Link Here
42
#include "EST_THash.h"
42
#include "EST_THash.h"
43
#include "EST_Val.h"
43
#include "EST_Val.h"
44
44
45
Declare_THash(int,EST_Val)
45
Declare_THash_Base(int,EST_Val,0,EST_Val(),NULL)
46
46
47
#if defined(INSTANTIATE_TEMPLATES)
47
#if defined(INSTANTIATE_TEMPLATES)
48
48
(-)speech_tools/base_class/inst_tmpl/hash_sd_t.cc (-1 / +1 lines)
Lines 39-45 Link Here
39
#include "EST_String.h"
39
#include "EST_String.h"
40
#include "EST_THash.h"
40
#include "EST_THash.h"
41
41
42
Declare_TStringHash(double)
42
Declare_TStringHash_Base(double, 0.0, NULL)
43
43
44
#if defined(INSTANTIATE_TEMPLATES)
44
#if defined(INSTANTIATE_TEMPLATES)
45
45
(-)speech_tools/base_class/inst_tmpl/hash_sfmp_t.cc (-1 / +1 lines)
Lines 40-46 Link Here
40
#include "EST_FMatrix.h"
40
#include "EST_FMatrix.h"
41
#include "EST_THash.h"
41
#include "EST_THash.h"
42
42
43
Declare_TStringHash_T(EST_FMatrix*,EST_StringFMatrixP)
43
Declare_TStringHash_Base_T(EST_FMatrix*,NULL,NULL,EST_StringFMatrixP)
44
44
45
#if defined(INSTANTIATE_TEMPLATES)
45
#if defined(INSTANTIATE_TEMPLATES)
46
46
(-)speech_tools/base_class/inst_tmpl/hash_sf_t.cc (-1 / +1 lines)
Lines 38-44 Link Here
38
#include "EST_String.h"
38
#include "EST_String.h"
39
#include "EST_THash.h"
39
#include "EST_THash.h"
40
40
41
Declare_TStringHash(float)
41
Declare_TStringHash_Base(float, 0.0, NULL)
42
42
43
#if defined(INSTANTIATE_TEMPLATES)
43
#if defined(INSTANTIATE_TEMPLATES)
44
44
(-)speech_tools/base_class/inst_tmpl/hash_si_t.cc (-1 / +1 lines)
Lines 38-44 Link Here
38
#include "EST_String.h"
38
#include "EST_String.h"
39
#include "EST_THash.h"
39
#include "EST_THash.h"
40
40
41
Declare_TStringHash(int)
41
Declare_TStringHash_Base(int, 0, NULL)
42
42
43
#if defined(INSTANTIATE_TEMPLATES)
43
#if defined(INSTANTIATE_TEMPLATES)
44
44
(-)speech_tools/base_class/inst_tmpl/hash_srp.cc (-1 / +1 lines)
Lines 40-46 Link Here
40
#include "ling_class/EST_Relation.h"
40
#include "ling_class/EST_Relation.h"
41
#include "EST_THash.h"
41
#include "EST_THash.h"
42
42
43
Declare_TStringHash_T(EST_Relation*,EST_StringRelationP)
43
Declare_TStringHash_Base_T(EST_Relation*,NULL,NULL,EST_StringRelationP)
44
44
45
#if defined(INSTANTIATE_TEMPLATES)
45
#if defined(INSTANTIATE_TEMPLATES)
46
46
(-)speech_tools/base_class/inst_tmpl/hash_ss_t.cc (-1 / +1 lines)
Lines 41-47 Link Here
41
#include "EST_String.h"
41
#include "EST_String.h"
42
#include "EST_THash.h"
42
#include "EST_THash.h"
43
43
44
Declare_TStringHash(EST_String)
44
Declare_TStringHash_Base(EST_String, "", NULL)
45
45
46
#if defined(INSTANTIATE_TEMPLATES)
46
#if defined(INSTANTIATE_TEMPLATES)
47
47
(-)speech_tools/base_class/inst_tmpl/hash_sv_t.cc (-1 / +1 lines)
Lines 42-48 Link Here
42
#include "EST_String.h"
42
#include "EST_String.h"
43
#include "EST_Val.h"
43
#include "EST_Val.h"
44
44
45
Declare_TStringHash(EST_Val)
45
Declare_TStringHash_Base(EST_Val, EST_Val(), NULL)
46
46
47
#if defined(INSTANTIATE_TEMPLATES)
47
#if defined(INSTANTIATE_TEMPLATES)
48
48
(-)speech_tools/base_class/inst_tmpl/vector_dmatrix_t.cc (-2 / +2 lines)
Lines 52-59 template ostream& operator << (ostream & Link Here
52
#endif
52
#endif
53
static const EST_DMatrix def_val_DMatrix;
53
static const EST_DMatrix def_val_DMatrix;
54
static EST_DMatrix error_return_DMatrix;
54
static EST_DMatrix error_return_DMatrix;
55
const EST_DMatrix *EST_TVector<EST_DMatrix>::def_val = &def_val_DMatrix;
55
template <> const EST_DMatrix *EST_TVector<EST_DMatrix>::def_val = &def_val_DMatrix;
56
EST_DMatrix *EST_TVector<EST_DMatrix>::error_return = &error_return_DMatrix;
56
template <> EST_DMatrix *EST_TVector<EST_DMatrix>::error_return = &error_return_DMatrix;
57
57
58
int operator !=(const EST_DMatrix &fm1, 
58
int operator !=(const EST_DMatrix &fm1, 
59
		const EST_DMatrix &fm2)
59
		const EST_DMatrix &fm2)
(-)speech_tools/base_class/inst_tmpl/vector_dvector_t.cc (-2 / +2 lines)
Lines 52-59 template ostream& operator << (ostream & Link Here
52
#endif
52
#endif
53
static const EST_DVector def_val_DVector;
53
static const EST_DVector def_val_DVector;
54
static EST_DVector error_return_DVector;
54
static EST_DVector error_return_DVector;
55
const EST_DVector *EST_TVector<EST_DVector>::def_val = &def_val_DVector;
55
template <> const EST_DVector *EST_TVector<EST_DVector>::def_val = &def_val_DVector;
56
EST_DVector *EST_TVector<EST_DVector>::error_return = &error_return_DVector;
56
template <> EST_DVector *EST_TVector<EST_DVector>::error_return = &error_return_DVector;
57
57
58
int operator !=(const EST_DVector &fv1, 
58
int operator !=(const EST_DVector &fv1, 
59
		const EST_DVector &fv2)
59
		const EST_DVector &fv2)
(-)speech_tools/base_class/inst_tmpl/vector_fmatrix_t.cc (-2 / +2 lines)
Lines 52-59 template ostream& operator << (ostream & Link Here
52
#endif
52
#endif
53
static const EST_FMatrix def_val_FMatrix;
53
static const EST_FMatrix def_val_FMatrix;
54
static EST_FMatrix error_return_FMatrix;
54
static EST_FMatrix error_return_FMatrix;
55
const EST_FMatrix *EST_TVector<EST_FMatrix>::def_val = &def_val_FMatrix;
55
template <> const EST_FMatrix *EST_TVector<EST_FMatrix>::def_val = &def_val_FMatrix;
56
EST_FMatrix *EST_TVector<EST_FMatrix>::error_return = &error_return_FMatrix;
56
template <> EST_FMatrix *EST_TVector<EST_FMatrix>::error_return = &error_return_FMatrix;
57
57
58
int operator !=(const EST_FMatrix &fm1, 
58
int operator !=(const EST_FMatrix &fm1, 
59
		const EST_FMatrix &fm2)
59
		const EST_FMatrix &fm2)
(-)speech_tools/grammar/scfg/EST_SCFG_inout.cc (-2 / +2 lines)
Lines 54-61 Link Here
54
54
55
static const EST_bracketed_string def_val_s;
55
static const EST_bracketed_string def_val_s;
56
static EST_bracketed_string error_return_s;
56
static EST_bracketed_string error_return_s;
57
const EST_bracketed_string *EST_TVector<EST_bracketed_string>::def_val=&def_val_s;
57
template <> const EST_bracketed_string *EST_TVector<EST_bracketed_string>::def_val=&def_val_s;
58
EST_bracketed_string *EST_TVector<EST_bracketed_string>::error_return=&error_return_s;
58
template <> EST_bracketed_string *EST_TVector<EST_bracketed_string>::error_return=&error_return_s;
59
59
60
60
61
#if defined(INSTANTIATE_TEMPLATES)
61
#if defined(INSTANTIATE_TEMPLATES)
(-)speech_tools/grammar/wfst/wfst_ops.cc (-2 / +2 lines)
Lines 57-64 Declare_TList_T(EST_WFST_MultiState *,ES Link Here
57
	static EST_IList int_EST_IList_kv_def_EST_IList_s; 
57
	static EST_IList int_EST_IList_kv_def_EST_IList_s; 
58
	static int int_EST_IList_kv_def_int_s; 
58
	static int int_EST_IList_kv_def_int_s; 
59
	
59
	
60
	EST_IList *EST_TKVL< int, EST_IList >::default_val=&int_EST_IList_kv_def_EST_IList_s; 
60
	template <> EST_IList *EST_TKVL< int, EST_IList >::default_val=&int_EST_IList_kv_def_EST_IList_s; 
61
	int *EST_TKVL< int, EST_IList >::default_key=&int_EST_IList_kv_def_int_s; 
61
	template <> int *EST_TKVL< int, EST_IList >::default_key=&int_EST_IList_kv_def_int_s; 
62
	
62
	
63
	Declare_TList_N(KVI_int_EST_IList_t, 0)
63
	Declare_TList_N(KVI_int_EST_IList_t, 0)
64
64
(-)speech_tools/include/EST_THash.h (-1 / +1 lines)
Lines 325-331 protected: Link Here
325
325
326
public:
326
public:
327
  /// Create a string hash table of <parameter>size</parameter> buckets.
327
  /// Create a string hash table of <parameter>size</parameter> buckets.
328
  EST_TStringHash(int size) : EST_THash<EST_String, V>(size, StringHash) {};
328
  EST_TStringHash(int size) : EST_THash<EST_String, V>(size, this->StringHash) {};
329
329
330
  /// An entry returned by the iterator is a key value pair.
330
  /// An entry returned by the iterator is a key value pair.
331
  typedef EST_StringHash_Pair<V> Entry;
331
  typedef EST_StringHash_Pair<V> Entry;
(-)speech_tools/include/EST_TIterator.h (-13 / +13 lines)
Lines 201-218 public: Link Here
201
  typedef EST_TIterator<Container, IPointer, Entry> Iter;
201
  typedef EST_TIterator<Container, IPointer, Entry> Iter;
202
202
203
  /// Create an iterator not associated with any specific container.
203
  /// Create an iterator not associated with any specific container.
204
  EST_TStructIterator() {cont=NULL;}
204
  EST_TStructIterator() {this->cont=NULL;}
205
205
206
  /// Copy an iterator by assignment
206
  /// Copy an iterator by assignment
207
  Iter &operator = (const Iter &orig)
207
  Iter &operator = (const Iter &orig)
208
    { cont=orig.cont; pos=orig.pos; pointer=orig.pointer; return *this;}
208
    { this->cont=orig.cont; this->pos=orig.pos; this->pointer=orig.pointer; return *this;}
209
209
210
  /// Create an iterator ready to run over the given container.
210
  /// Create an iterator ready to run over the given container.
211
  EST_TStructIterator(const Container &over)
211
  EST_TStructIterator(const Container &over)
212
    { begin(over); }
212
    { begin(over); }
213
213
214
  const Entry *operator ->() const
214
  const Entry *operator ->() const
215
    {return &current();}
215
    {return &this->current();}
216
};
216
};
217
217
218
template <class Container, class IPointer, class Entry>
218
template <class Container, class IPointer, class Entry>
Lines 231-241 public: Link Here
231
  typedef EST_TIterator<Container, IPointer, Entry> Iter;
231
  typedef EST_TIterator<Container, IPointer, Entry> Iter;
232
232
233
  /// Create an iterator not associated with any specific container.
233
  /// Create an iterator not associated with any specific container.
234
  EST_TRwIterator() {cont=NULL;}
234
  EST_TRwIterator() {this->cont=NULL;}
235
235
236
  /// Copy an iterator by assignment
236
  /// Copy an iterator by assignment
237
  Iter &operator = (const Iter &orig)
237
  Iter &operator = (const Iter &orig)
238
    { cont=orig.cont; pos=orig.pos; pointer=orig.pointer; return *this;}
238
    { this->cont=orig.cont; this->pos=orig.pos; this->pointer=orig.pointer; return *this;}
239
239
240
  /// Create an iterator ready to run over the given container.
240
  /// Create an iterator ready to run over the given container.
241
  EST_TRwIterator(Container &over)
241
  EST_TRwIterator(Container &over)
Lines 243-260 public: Link Here
243
243
244
  /// Set the iterator ready to run over this container.
244
  /// Set the iterator ready to run over this container.
245
  void begin(Container &over)
245
  void begin(Container &over)
246
    {cont=&over; beginning();}
246
    {this->cont=&over; this->beginning();}
247
247
248
  /**@name Access
248
  /**@name Access
249
    */
249
    */
250
  //@{
250
  //@{
251
  /// Return the element currentl pointed to.
251
  /// Return the element currentl pointed to.
252
  Entry& current() const
252
  Entry& current() const
253
    {return cont->points_at(pointer);}
253
    {return this->cont->points_at(this->pointer);}
254
254
255
  /// The * operator returns the current element. 
255
  /// The * operator returns the current element. 
256
  Entry &operator *() const
256
  Entry &operator *() const
257
    {return current();}
257
    {return this->current();}
258
258
259
#if 0 
259
#if 0 
260
  Entry *operator ->() const
260
  Entry *operator ->() const
Lines 264-271 public: Link Here
264
  /// Return the current element and move the pointer forwards.
264
  /// Return the current element and move the pointer forwards.
265
  Entry& next_element() 
265
  Entry& next_element() 
266
	{ 
266
	{ 
267
	  Entry &it = cont->points_at(pointer); 
267
	  Entry &it = this->cont->points_at(this->pointer); 
268
	  cont->move_pointer_forwards(pointer); 
268
	  this->cont->move_pointer_forwards(this->pointer); 
269
	  return it; 
269
	  return it; 
270
	}
270
	}
271
271
Lines 281-298 public: Link Here
281
  typedef EST_TIterator<Container, IPointer, Entry> Iter;
281
  typedef EST_TIterator<Container, IPointer, Entry> Iter;
282
282
283
  /// Create an iterator not associated with any specific container.
283
  /// Create an iterator not associated with any specific container.
284
  EST_TRwStructIterator() {cont=NULL;}
284
  EST_TRwStructIterator() {this->cont=NULL;}
285
285
286
  /// Copy an iterator by assignment
286
  /// Copy an iterator by assignment
287
  Iter &operator = (const Iter &orig)
287
  Iter &operator = (const Iter &orig)
288
    { cont=orig.cont; pos=orig.pos; pointer=orig.pointer; return *this;}
288
    { this->cont=orig.cont; this->pos=orig.pos; this->pointer=orig.pointer; return *this;}
289
289
290
  /// Create an iterator ready to run over the given container.
290
  /// Create an iterator ready to run over the given container.
291
  EST_TRwStructIterator(Container &over)
291
  EST_TRwStructIterator(Container &over)
292
    { begin(over); }
292
    { begin(over); }
293
293
294
  Entry *operator ->() const
294
  Entry *operator ->() const
295
    {return &current();}
295
    {return &this->current();}
296
};
296
};
297
297
298
#endif
298
#endif
(-)speech_tools/include/EST_TMatrix.h (-7 / +7 lines)
Lines 105-111 protected: Link Here
105
    {
105
    {
106
106
107
      return mcell_pos(r, c, 
107
      return mcell_pos(r, c, 
108
		       p_row_step, p_column_step);
108
		       p_row_step, this->p_column_step);
109
    }
109
    }
110
110
111
  INLINE unsigned int mcell_pos_1(int r, int c) const
111
  INLINE unsigned int mcell_pos_1(int r, int c) const
Lines 117-130 protected: Link Here
117
117
118
  /// quick method for returning {\tt x[m][n]}
118
  /// quick method for returning {\tt x[m][n]}
119
  INLINE const T &fast_a_m(int r, int c) const 
119
  INLINE const T &fast_a_m(int r, int c) const 
120
    { return p_memory[mcell_pos(r,c)]; }
120
    { return this->p_memory[mcell_pos(r,c)]; }
121
  INLINE T &fast_a_m(int r, int c) 
121
  INLINE T &fast_a_m(int r, int c) 
122
    { return p_memory[mcell_pos(r,c)]; }
122
    { return this->p_memory[mcell_pos(r,c)]; }
123
123
124
  INLINE const T &fast_a_1(int r, int c) const 
124
  INLINE const T &fast_a_1(int r, int c) const 
125
    { return p_memory[mcell_pos_1(r,c)]; }
125
    { return this->p_memory[mcell_pos_1(r,c)]; }
126
  INLINE T &fast_a_1(int r, int c) 
126
  INLINE T &fast_a_1(int r, int c) 
127
    { return p_memory[mcell_pos_1(r,c)]; }
127
    { return this->p_memory[mcell_pos_1(r,c)]; }
128
  
128
  
129
129
130
    /// Get and set values from array
130
    /// Get and set values from array
Lines 176-182 public: Link Here
176
  /// return number of rows
176
  /// return number of rows
177
  int num_rows() const {return p_num_rows;}
177
  int num_rows() const {return p_num_rows;}
178
  /// return number of columns
178
  /// return number of columns
179
  int num_columns() const {return p_num_columns;}
179
  int num_columns() const {return this->p_num_columns;}
180
180
181
  /// const access with no bounds check, care recommend
181
  /// const access with no bounds check, care recommend
182
  INLINE const T &a_no_check(int row, int col) const 
182
  INLINE const T &a_no_check(int row, int col) const 
Lines 215-221 public: Link Here
215
215
216
  /// fill matrix with value v
216
  /// fill matrix with value v
217
  void fill(const T &v);
217
  void fill(const T &v);
218
  void fill() { fill(*def_val); }
218
  void fill() { fill(*this->def_val); }
219
219
220
  /// assignment operator
220
  /// assignment operator
221
  EST_TMatrix &operator=(const EST_TMatrix &s); 
221
  EST_TMatrix &operator=(const EST_TMatrix &s); 
(-)speech_tools/include/EST_TNamedEnum.h (-7 / +7 lines)
Lines 124-132 protected: Link Here
124
public:
124
public:
125
125
126
  EST_TNamedEnumI(EST_TValuedEnumDefinition<ENUM,const char *,INFO> defs[])
126
  EST_TNamedEnumI(EST_TValuedEnumDefinition<ENUM,const char *,INFO> defs[])
127
	{initialise((const void *)defs); };
127
	{this->initialise((const void *)defs); };
128
  EST_TNamedEnumI(EST_TValuedEnumDefinition<const char *,const char *,INFO> defs[], ENUM (*conv)(const char *))
128
  EST_TNamedEnumI(EST_TValuedEnumDefinition<const char *,const char *,INFO> defs[], ENUM (*conv)(const char *))
129
	{initialise((const void *)defs, conv); };
129
	{this->initialise((const void *)defs, conv); };
130
  const char *name(ENUM tok, int n=0) const {return value(tok,n); };
130
  const char *name(ENUM tok, int n=0) const {return value(tok,n); };
131
131
132
};
132
};
Lines 136-144 public: Link Here
136
template<class ENUM, class VAL> class EST_TValuedEnum : public EST_TValuedEnumI<ENUM,VAL,NO_INFO> { 
136
template<class ENUM, class VAL> class EST_TValuedEnum : public EST_TValuedEnumI<ENUM,VAL,NO_INFO> { 
137
public:
137
public:
138
  EST_TValuedEnum(EST_TValuedEnumDefinition<ENUM,VAL,NO_INFO> defs[]) 
138
  EST_TValuedEnum(EST_TValuedEnumDefinition<ENUM,VAL,NO_INFO> defs[]) 
139
	{initialise((const void *)defs);};
139
	{this->initialise((const void *)defs);};
140
  EST_TValuedEnum(EST_TValuedEnumDefinition<const char *,VAL,NO_INFO> defs[], ENUM (*conv)(const char *)) 
140
  EST_TValuedEnum(EST_TValuedEnumDefinition<const char *,VAL,NO_INFO> defs[], ENUM (*conv)(const char *)) 
141
	{initialise((const void *)defs, conv);};
141
	{this->initialise((const void *)defs, conv);};
142
};
142
};
143
143
144
144
Lines 148-158 private: Link Here
148
  EST_write_status priv_save(EST_String name, EST_TNamedEnum *definitive, char quote) const;
148
  EST_write_status priv_save(EST_String name, EST_TNamedEnum *definitive, char quote) const;
149
public:
149
public:
150
  EST_TNamedEnum(ENUM undef_e, const char *undef_n = NULL) 
150
  EST_TNamedEnum(ENUM undef_e, const char *undef_n = NULL) 
151
	{initialise(undef_e, undef_n);};
151
	{this->initialise(undef_e, undef_n);};
152
  EST_TNamedEnum(EST_TValuedEnumDefinition<ENUM,const char *,NO_INFO> defs[]) 
152
  EST_TNamedEnum(EST_TValuedEnumDefinition<ENUM,const char *,NO_INFO> defs[]) 
153
	{initialise((const void *)defs);};
153
	{this->initialise((const void *)defs);};
154
  EST_TNamedEnum(EST_TValuedEnumDefinition<const char *,const char *,NO_INFO> defs[], ENUM (*conv)(const char *)) 
154
  EST_TNamedEnum(EST_TValuedEnumDefinition<const char *,const char *,NO_INFO> defs[], ENUM (*conv)(const char *)) 
155
	{initialise((const void *)defs, conv);};
155
	{this->initialise((const void *)defs, conv);};
156
156
157
  EST_read_status load(EST_String name) { return priv_load(name, NULL); };
157
  EST_read_status load(EST_String name) { return priv_load(name, NULL); };
158
  EST_read_status load(EST_String name, EST_TNamedEnum &definitive) { return priv_load(name, &definitive); };
158
  EST_read_status load(EST_String name, EST_TNamedEnum &definitive) { return priv_load(name, &definitive); };
(-)speech_tools/include/EST_TSimpleVector.h (-1 / +1 lines)
Lines 74-80 public: Link Here
74
    void zero(void);
74
    void zero(void);
75
75
76
    /// Fill vector with default value
76
    /// Fill vector with default value
77
    void empty(void) { if (*def_val == 0) zero(); else fill(*def_val); }
77
    void empty(void) { if (*this->def_val == 0) zero(); else this->fill(*this->def_val); }
78
};
78
};
79
79
80
#endif
80
#endif
(-)speech_tools/include/instantiate/EST_TDequeI.h (-3 / +3 lines)
Lines 54-69 Link Here
54
#define Instantiate_TDEQ(T) Instantiate_TDEQ_T(T, T) 
54
#define Instantiate_TDEQ(T) Instantiate_TDEQ_T(T, T) 
55
55
56
#define Declare_TDEQ_T(T, TAG)  \
56
#define Declare_TDEQ_T(T, TAG)  \
57
	const T *EST_TDeque< T >::Filler=NULL;
57
	template <> const T *EST_TDeque< T >::Filler=NULL;
58
58
59
#define Declare_TDEQ_Base_T(T, FILLER ,TAG) \
59
#define Declare_TDEQ_Base_T(T, FILLER ,TAG) \
60
	const T TAG ## _deq_filler=FILLER; \
60
	const T TAG ## _deq_filler=FILLER; \
61
	const T *EST_TDeque< T >::Filler=& TAG ## _deq_filler;
61
	template <> const T *EST_TDeque< T >::Filler=& TAG ## _deq_filler;
62
	
62
	
63
63
64
#define Declare_TDEQ_Class_T(T, FILLER,TAG) \
64
#define Declare_TDEQ_Class_T(T, FILLER,TAG) \
65
	const T TAG ## _deq_filler(FILLER); \
65
	const T TAG ## _deq_filler(FILLER); \
66
	const T *EST_TDeque< T >::Filler=& TAG ## _deq_filler;
66
	template <> const T *EST_TDeque< T >::Filler=& TAG ## _deq_filler;
67
67
68
#define Declare_TDEQ(T) Declare_TDEQ_T(T, T)
68
#define Declare_TDEQ(T) Declare_TDEQ_T(T, T)
69
69
(-)speech_tools/include/instantiate/EST_THashI.h (-6 / +7 lines)
Lines 77-93 Link Here
77
77
78
78
79
#define Declare_THash_T(KEY, VAL, TAG) \
79
#define Declare_THash_T(KEY, VAL, TAG) \
80
	VAL EST_THash< KEY, VAL >::Dummy_Value; \
80
	template <> VAL EST_THash< KEY, VAL >::Dummy_Value; \
81
	KEY EST_THash< KEY, VAL >::Dummy_Key; \
81
	template <> KEY EST_THash< KEY, VAL >::Dummy_Key; \
82
	EST_THash< KEY, VAL > TAG ## _hash_dummy(0);
82
	EST_THash< KEY, VAL > TAG ## _hash_dummy(0);
83
83
84
#define Declare_THash_Base_T(KEY, VAL, DEFAULTK, DEFAULT, ERROR,TAG) \
84
#define Declare_THash_Base_T(KEY, VAL, DEFAULTK, DEFAULT, ERROR,TAG) \
85
	KEY EST_THash< KEY, VAL >::Dummy_Key=DEFAULTK; \
85
	template <> KEY EST_THash< KEY, VAL >::Dummy_Key=DEFAULTK; \
86
	VAL EST_THash<KEY, VAL>::Dummy_Value=DEFAULT;
86
	template <> VAL EST_THash<KEY, VAL>::Dummy_Value=DEFAULT;
87
87
88
#define Declare_THash_Class_T(KEY, VAL, DEFAULTK, DEFAULT, ERROR,TAG) \
88
#define Declare_THash_Class_T(KEY, VAL, DEFAULTK, DEFAULT, ERROR,TAG) \
89
	KEY EST_THash< KEY, VAL >::Dummy_Key(DEFAULTK); \
89
	template <> KEY EST_THash< KEY, VAL >::Dummy_Key(DEFAULTK); \
90
	VAL EST_THash<KEY, VAL>::Dummy_Value(DEFAULT);
90
	template <> VAL EST_THash<KEY, VAL>::Dummy_Value(DEFAULT);
91
91
92
#define Declare_THash(KEY, VAL) Declare_THash_T(KEY, VAL, KEY ## VAL)
92
#define Declare_THash(KEY, VAL) Declare_THash_T(KEY, VAL, KEY ## VAL)
93
93
Lines 98-100 Link Here
98
98
99
#endif
99
#endif
100
100
101
(-)speech_tools/include/instantiate/EST_TKVLI.h (-6 / +6 lines)
Lines 71-78 Link Here
71
	static VAL TAG##_kv_def_val_s; \
71
	static VAL TAG##_kv_def_val_s; \
72
	static KEY TAG##_kv_def_key_s; \
72
	static KEY TAG##_kv_def_key_s; \
73
	\
73
	\
74
	VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
74
	template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
75
	KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
75
	template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
76
	\
76
	\
77
	Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
77
	Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
78
#define Declare_KVL_T(KEY, VAL, TAG) \
78
#define Declare_KVL_T(KEY, VAL, TAG) \
Lines 85-92 Link Here
85
	static VAL TAG##_kv_def_val_s=DEFV; \
85
	static VAL TAG##_kv_def_val_s=DEFV; \
86
	static KEY TAG##_kv_def_key_s=DEFK; \
86
	static KEY TAG##_kv_def_key_s=DEFK; \
87
	\
87
	\
88
	VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
88
	template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
89
	KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
89
	template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
90
	\
90
	\
91
	Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
91
	Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
92
#define Declare_KVL_Base_T(KEY, VAL, DEFV, DEFK, TAG) \
92
#define Declare_KVL_Base_T(KEY, VAL, DEFV, DEFK, TAG) \
Lines 99-106 Link Here
99
	static VAL TAG##_kv_def_val_s(DEFV); \
99
	static VAL TAG##_kv_def_val_s(DEFV); \
100
	static KEY TAG##_kv_def_key_s(DEFK); \
100
	static KEY TAG##_kv_def_key_s(DEFK); \
101
	\
101
	\
102
	VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
102
	template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \
103
	KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
103
	template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \
104
	\
104
	\
105
	Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
105
	Declare_TList_N(KVI_ ## TAG ## _t, MaxFree)
106
#define Declare_KVL_Class_T(KEY, VAL, DEFV, DEFK,TAG) \
106
#define Declare_KVL_Class_T(KEY, VAL, DEFV, DEFK,TAG) \
(-)speech_tools/include/instantiate/EST_TListI.h (-3 / +3 lines)
Lines 64-72 Link Here
64
64
65
#define Declare_TList_TN(TYPE,MaxFree,TAG) \
65
#define Declare_TList_TN(TYPE,MaxFree,TAG) \
66
	typedef TYPE TLIST_ ## TAG ## _VAL; \
66
	typedef TYPE TLIST_ ## TAG ## _VAL; \
67
	EST_TItem< TYPE > * EST_TItem< TYPE >::s_free=NULL; \
67
	template <> EST_TItem< TYPE > * EST_TItem< TYPE >::s_free=NULL; \
68
	unsigned int EST_TItem< TYPE >::s_maxFree=MaxFree; \
68
	template <> unsigned int EST_TItem< TYPE >::s_maxFree=MaxFree; \
69
	unsigned int EST_TItem< TYPE >::s_nfree=0;
69
	template <> unsigned int EST_TItem< TYPE >::s_nfree=0;
70
#define Declare_TList_T(TYPE,TAG) \
70
#define Declare_TList_T(TYPE,TAG) \
71
	Declare_TList_TN(TYPE,0,TAG)
71
	Declare_TList_TN(TYPE,0,TAG)
72
72
(-)speech_tools/include/instantiate/EST_TVectorI.h (-6 / +6 lines)
Lines 62-83 Link Here
62
	static TYPE const TAG##_vec_def_val_s; \
62
	static TYPE const TAG##_vec_def_val_s; \
63
	static TYPE TAG##_vec_error_return_s; \
63
	static TYPE TAG##_vec_error_return_s; \
64
	\
64
	\
65
	TYPE const *EST_TVector< TYPE >::def_val=&TAG##_vec_def_val_s; \
65
	template <> TYPE const *EST_TVector< TYPE >::def_val=&TAG##_vec_def_val_s; \
66
	TYPE *EST_TVector< TYPE >::error_return=&TAG##_vec_error_return_s;
66
	template <> TYPE *EST_TVector< TYPE >::error_return=&TAG##_vec_error_return_s;
67
67
68
#define Declare_TVector_Base_T(TYPE,DEFAULT,ERROR,TAG)  \
68
#define Declare_TVector_Base_T(TYPE,DEFAULT,ERROR,TAG)  \
69
	static TYPE const TAG##_vec_def_val_s=DEFAULT; \
69
	static TYPE const TAG##_vec_def_val_s=DEFAULT; \
70
	static TYPE TAG##_vec_error_return_s=ERROR; \
70
	static TYPE TAG##_vec_error_return_s=ERROR; \
71
	\
71
	\
72
	TYPE const *EST_TVector<TYPE>::def_val=&TAG##_vec_def_val_s; \
72
	template <> TYPE const *EST_TVector<TYPE>::def_val=&TAG##_vec_def_val_s; \
73
	TYPE *EST_TVector<TYPE>::error_return=&TAG##_vec_error_return_s;
73
	template <> TYPE *EST_TVector<TYPE>::error_return=&TAG##_vec_error_return_s;
74
74
75
#define Declare_TVector_Class_T(TYPE,DEFAULT,ERROR,TAG)  \
75
#define Declare_TVector_Class_T(TYPE,DEFAULT,ERROR,TAG)  \
76
	static TYPE const TAG##_vec_def_val_s(DEFAULT); \
76
	static TYPE const TAG##_vec_def_val_s(DEFAULT); \
77
	static TYPE TAG##_vec_error_return_s(ERROR); \
77
	static TYPE TAG##_vec_error_return_s(ERROR); \
78
	\
78
	\
79
	TYPE const *EST_TVector<TYPE>::def_val=&TAG##_vec_def_val_s; \
79
	template <> TYPE const *EST_TVector<TYPE>::def_val=&TAG##_vec_def_val_s; \
80
	TYPE *EST_TVector<TYPE>::error_return=&TAG##_vec_error_return_s;
80
	template <> TYPE *EST_TVector<TYPE>::error_return=&TAG##_vec_error_return_s;
81
81
82
#define Declare_TVector(TYPE) Declare_TVector_T(TYPE,TYPE)
82
#define Declare_TVector(TYPE) Declare_TVector_T(TYPE,TYPE)
83
#define Declare_TVector_Base(TYPE,DEFAULT,ERROR)  Declare_TVector_Base_T(TYPE,DEFAULT,ERROR,TYPE)
83
#define Declare_TVector_Base(TYPE,DEFAULT,ERROR)  Declare_TVector_Base_T(TYPE,DEFAULT,ERROR,TYPE)
(-)speech_tools/ling_class/EST_FeatureFunctionContext.cc (-1 / +1 lines)
Lines 210-216 const EST_Item_featfunc EST_FeatureFunct Link Here
210
    return NULL;
210
    return NULL;
211
}
211
}
212
212
213
Declare_TStringHash(EST_Item_featfunc)
213
Declare_TStringHash_Base(EST_Item_featfunc,EST_Item_featfunc(),NULL)
214
Declare_TList_T(EST_FeatureFunctionPackage *, EST_FeatureFunctionPackageP)
214
Declare_TList_T(EST_FeatureFunctionPackage *, EST_FeatureFunctionPackageP)
215
215
216
216
(-)speech_tools/ling_class/EST_FeatureFunctionPackage.cc (-1 / +1 lines)
Lines 41-47 Link Here
41
#include "ling_class/EST_FeatureFunctionPackage.h"
41
#include "ling_class/EST_FeatureFunctionPackage.h"
42
42
43
			
43
			
44
Declare_TStringHash_T(EST_FeatureFunctionPackage::Entry, EST_FeatureFunctionPackage_Entry)
44
Declare_TStringHash_Base_T(EST_FeatureFunctionPackage::Entry, EST_FeatureFunctionPackage::Entry(), NULL, EST_FeatureFunctionPackage_Entry)
45
45
46
46
47
#if defined(INSTANTIATE_TEMPLATES)
47
#if defined(INSTANTIATE_TEMPLATES)
(-)speech_tools/ling_class/genxml.cc (-1 / +1 lines)
Lines 736-742 void GenXML_Parser_Class::error(XML_Pars Link Here
736
  est_error_throw();
736
  est_error_throw();
737
}
737
}
738
738
739
Declare_TStringHash_T(EST_Item_Content *, THash_String_ItemC_P)
739
Declare_TStringHash_Base_T(EST_Item_Content *, NULL, NULL, THash_String_ItemC_P)
740
740
741
#if defined(INSTANTIATE_TEMPLATES)
741
#if defined(INSTANTIATE_TEMPLATES)
742
742
(-)speech_tools/siod/siod.cc (-1 / +1 lines)
Lines 38-44 Cambridge, MA 02138 Link Here
38
38
39
extern "C" const char * repl_prompt;
39
extern "C" const char * repl_prompt;
40
40
41
Declare_TStringHash_T(EST_Regex *, hash_string_regex)
41
Declare_TStringHash_Base_T(EST_Regex *, NULL, NULL, hash_string_regex)
42
42
43
#if defined(INSTANTIATE_TEMPLATES)
43
#if defined(INSTANTIATE_TEMPLATES)
44
#include "../base_class/EST_THash.cc"
44
#include "../base_class/EST_THash.cc"
(-)speech_tools/stats/dynamic_program.cc (-2 / +2 lines)
Lines 50-59 template class EST_TVector<EST_Item*>; Link Here
50
#endif
50
#endif
51
51
52
static EST_Item *const def_val_item_ptr = NULL;
52
static EST_Item *const def_val_item_ptr = NULL;
53
EST_Item* const *EST_Item_ptr_Vector::def_val = &def_val_item_ptr;
53
template <> EST_Item* const *EST_Item_ptr_Vector::def_val = &def_val_item_ptr;
54
54
55
static EST_Item* error_return_item_ptr = NULL;
55
static EST_Item* error_return_item_ptr = NULL;
56
EST_Item* *EST_Item_ptr_Vector::error_return = &error_return_item_ptr;
56
template <> EST_Item* *EST_Item_ptr_Vector::error_return = &error_return_item_ptr;
57
57
58
typedef
58
typedef
59
float (*local_cost_function)(const EST_Item *item1,
59
float (*local_cost_function)(const EST_Item *item1,
(-)speech_tools/testsuite/hash_example.cc (-1 / +1 lines)
Lines 135-141 cout << "\n"; Link Here
135
}
135
}
136
136
137
137
138
Declare_THash(int,float)
138
Declare_THash_Base(int,float,0,0.0,NULL)
139
139
140
#if defined(INSTANTIATE_TEMPLATES)
140
#if defined(INSTANTIATE_TEMPLATES)
141
#include "../base_class/EST_THash.cc"
141
#include "../base_class/EST_THash.cc"

Return to bug 50331