52 for( i = 0; i < size; i++ )
57 qsort( t, size,
sizeof(
struct tmp),
cmp );
60 for( i = 0; i < size; i++ ) array[i] = t[i].p;
66 int cmp(
const void *s1,
const void *s2 )
68 struct tmp *a1 = (
struct tmp *)s1;
69 struct tmp *a2 = (
struct tmp *)s2;
71 return((a1->
r) - (a2->
r));
78 return (
float)( ( a > 0.5 ) ? 1.0 : 0.0 );
84 return (
float)( 1.0 / ( 1.0 + exp( -1.0 * act ) ) );
92 return (
float)( 1.0 / ( 1.0 + exp( beta * a_pot ) ) );
95 float Sigmoid(
float beta,
float a_pot,
float thresh )
97 return (
float)( 1.0 / ( 1.0 + exp( beta * a_pot + thresh ) ) );
103 int **matrix =
new int*[row];
105 for (
int i = 0; i < row; i++ )
107 matrix[i] =
new int[col];
108 for (
int j = 0; j < col; j++ ) matrix[i][j] = val;
116 for (
int i = 0; i < row; i++ )
117 for (
int j = 0; j < col; j++ )
124 for (
int i = 0; i < row; i++ )
delete[] matrix[i];
132 float **matrix =
new float*[row];
134 for (
int i = 0; i < row; i++ )
136 matrix[i] =
new float[col];
137 for (
int j = 0; j < col; j++ ) matrix[i][j] = val;
145 for (
int i = 0; i < row; i++ )
146 for (
int j = 0; j < col; j++ )
153 for (
int i = 0; i < row; i++ )
delete[] matrix[i];
163 for (
int i = 0; i < size; i++ )
164 dist += ( pat1[i] - pat2[i] ) * ( pat1[i] - pat2[i] );
166 return (
float)( sqrt( dist ) / sqrt( (
float)size ) );
178 while ( infile->peek() ==
'\n' || infile->peek() ==
' ' || infile->peek() ==
'\t' )
180 while ( infile->peek() ==
'#' )infile->ignore( 1000,
'\n' );
182 if ( c ==
'\n' || c ==
'\t' || c ==
' ' || c ==
'#' )
193 char folder[FILENAME_MAX];
195 getcwd( folder, FILENAME_MAX );
196 std::cerr <<
"Error: Could not create file " << filename <<
" in directory ";
197 std::cerr << folder << std::endl;
202 char folder[FILENAME_MAX];
204 getcwd( folder, FILENAME_MAX );
205 std::cerr <<
"Error: Could not open file " << filename <<
" in directory ";
206 std::cerr << folder << std::endl;
214 gWidth = std::cout.width();
218 void AdjustStream( std::ostream &os,
int precision,
int width,
int pos,
bool trailers )
220 os.precision( precision );
224 os.setf(std::ios::showpoint, std::ios::showpoint);
226 os.unsetf(std::ios::showpoint);
228 os.setf(std::ios::left, std::ios::adjustfield);
230 os.setf(std::ios::right, std::ios::adjustfield);
237 os.unsetf(std::ios::showpoint);
238 os.setf(std::ios::left, std::ios::adjustfield);
246 double diff = val1 - val2;
248 if ( diff < 0.0 )
return ( 0.0 - diff );
254 float diff = val1 - val2;
256 if ( diff < 0.0 )
return (
float)( 0.0 - diff );
262 int diff = val1 - val2;
264 if ( diff < 0 )
return ( 0 - diff );
270 if ( val < 0.0 )
return ( 0.0 - val );
276 if ( val < 0.0 )
return (
float)( 0.0 - val );
282 if ( val < 0 )
return ( 0 - val );
int cmp(const void *s1, const void *s2)
void SkipComments(std::ifstream *infile)
void GetStreamDefaults(void)
void AdjustStream(std::ostream &os, int precision, int width, int pos, bool trailers)
void Permute(int *array, size_t size)
void SetStreamDefaults(std::ostream &os)
void DisposeMatrix(int **matrix, int row)
float ReturnDistance(float *pat1, float *pat2, int size)
void FileOpenError(char *filename)
int ** CreateMatrix(int val, int row, int col)
std::streamsize gPrecision
double SafeAbs(double val1, double val2)
void FileCreateError(char *filename)
void ResetMatrix(int **matrix, int val, int row, int col)