globals.cpp
E:\\News Arthur\\SVM\\2\\globals.cpp(115) : error C2144: syntax error : missing ')' before type 'char'
E:\\News Arthur\\SVM\\2\\globals.cpp(115) : error C2059: syntax error : ')'
E:\\News Arthur\\SVM\\2\\globals.cpp(116) : error C2143: syntax error : missing ';' before '{'
E:\\News Arthur\\SVM\\2\\globals.cpp(116) : error C2065: 'error_msg' : undeclared identifier
E:\\News Arthur\\SVM\\2\\globals.cpp(116) : error C2065: 'the_error' : undeclared identifier
E:\\News Arthur\\SVM\\2\\globals.cpp(118) : error C2143: syntax error : missing ';' before '{'
E:\\News Arthur\\SVM\\2\\globals.cpp(118) : error C2440: '=' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\\News Arthur\\SVM\\2\\globals.cpp(120) : error C2144: syntax error : missing ')' before type 'char'
E:\\News Arthur\\SVM\\2\\globals.cpp(120) : error C2059: syntax error : ')'
E:\\News Arthur\\SVM\\2\\globals.cpp(121) : error C2143: syntax error : missing ';' before '{'
E:\\News Arthur\\SVM\\2\\globals.cpp(123) : error C2143: syntax error : missing ';' before '{'
E:\\News Arthur\\SVM\\2\\globals.cpp(123) : error C2440: '=' : cannot convert from 'char [1]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\\News Arthur\\SVM\\2\\globals.cpp(127) : error C2601: '<<' : local function definitions are illegal
E:\\News Arthur\\SVM\\2\\globals.cpp(127) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
代码如下:
#include \"stdafx.h\"
#include \"globals.h\"
SVMFLOAT x_i(const svm_example x, const SVMINT i)
{
// return x by binary search
SVMINT low=0;
SVMINT high=x.length;
SVMINT med;
SVMFLOAT result;
while(low<high)
{
med = (low+high)/2;
if(x.example[med].index>=i)
{
high=med;
}
else
{
low=med+1;
}
}
if((high < x.length) && (x.example[high].index==i))
{
result = x.example[high].att;
}
else
{
result = 0;
}
return result;
}
SVMFLOAT string2svmfloat(char* s)
{
// number =~ [+-]?\\d+([.]\\d+)?([Ee][+-]?\\d+)?
int size = 0;
while(s[size] != '\\0') size++;
int char_read=0;
SVMFLOAT number=0;
int sign = 1;
// sign
if((size > 0) && ('+' == s[0]))
{
char_read++;
}
else if((size > 0) && ('-' ==s[0]))
{
char_read++;
sign = -1;
}
// digits before \".\"
while((char_read<size) && (s[char_read] >= '0') && (s[char_read] <= '9'))
{
number=number*10+(s[char_read]-'0');
char_read++;
}
// digits after \".\"
if((char_read<size) && (('.' == s[char_read]) || (',' == s[char_read])))
{
SVMFLOAT factor = 0.1;
char_read++;
while((char_read<size) && (s[char_read] >= '0') && (s[char_read] <= '9'))
{
number=number+factor*(s[char_read]-'0');
char_read++;
factor *= 0.1;
}
}
if(sign<0)
{
number = -number;
}
// exponent
if((char_read<size) && (('e' == s[char_read]) || ('E' == s[char_read])))
{
sign = 1;
char_read++;
if((char_read<size) && ('+' == s[char_read]))
{
char_read++;
}
else if((char_read<size) && ('-' == s[char_read]))
{
char_read++;
sign = -1;
}
int exponent=0;
while((char_read<size) && (s[char_read] >= '0') && (s[char_read] <= '9'))
{
exponent = exponent*10+(s[char_read]-'0');
char_read++;
}
number = number*pow(10,sign*exponent);
}
if(char_read<size)
{
throw no_number_exception();
}
return number;
}
long get_time()
{
#ifdef use_time
struct tms the_time;
times(&the_time);
return(the_time.tms_utime);
#else return 0;
#endif}
general_exception::general_exception(char* the_error)
{ error_msg = the_error; }
general_exception::general_exception()
{ error_msg = \"\"; }
read_exception::read_exception(char* the_error)
{ error_msg = the_error; }
read_exception::read_exception()
{ error_msg = \"\"; }
ostream& operator<< (ostream& data_stream, example_format& format)
{
if(format.sparse)
{
data_stream<<\"sparse\";
}
else
{
for(int i=1;i<=5;i++)
{
if(format.where_x == i)
{
data_stream<<\"x\";
}
else if(format.where_y == i)
{
data_stream<<\"y\";
}
else if (format.where_alpha == i)
{
data_stream<<\"a\";
}
}
}
return data_stream;
} |