Commit 02008951 authored by Laurent Belcour's avatar Laurent Belcour

Does compile under Windows

parent da34b627
...@@ -151,7 +151,7 @@ class arguments ...@@ -151,7 +151,7 @@ class arguments
float get_float(const std::string& key, float default_value = 0.0f) const float get_float(const std::string& key, float default_value = 0.0f) const
{ {
if(_map.count(key) > 0) if(_map.count(key) > 0)
return atof(_map.find(key)->second.c_str()) ; return (float)atof(_map.find(key)->second.c_str()) ;
else else
return default_value ; return default_value ;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
double norm(const vec& a) double norm(const vec& a)
{ {
double norm = 0.0 ; double norm = 0.0 ;
for(unsigned int i=0; i<a.size(); ++i) for(int i=0; i<a.size(); ++i)
{ {
norm += a[i]*a[i]; norm += a[i]*a[i];
} }
...@@ -14,13 +14,13 @@ vec normalize(const vec& a) ...@@ -14,13 +14,13 @@ vec normalize(const vec& a)
{ {
vec b(a.size()); vec b(a.size());
double norm = 0.0 ; double norm = 0.0 ;
for(unsigned int i=0; i<a.size(); ++i) for(int i=0; i<a.size(); ++i)
{ {
norm += a[i]*a[i]; norm += a[i]*a[i];
} }
norm = sqrt(norm); norm = sqrt(norm);
for(unsigned int i=0; i<a.size(); ++i) for(int i=0; i<a.size(); ++i)
{ {
b[i] = a[i]/norm; b[i] = a[i]/norm;
} }
...@@ -33,7 +33,7 @@ double dot(const vec& a, const vec& b) ...@@ -33,7 +33,7 @@ double dot(const vec& a, const vec& b)
assert(a.size() == b.size()); assert(a.size() == b.size());
#endif #endif
double res = 0.0; double res = 0.0;
for(unsigned int i=0; i<a.size(); ++i) for(int i=0; i<a.size(); ++i)
{ {
res += a[i]*b[i]; res += a[i]*b[i];
} }
...@@ -48,7 +48,7 @@ vec product(const vec& a, const vec& b) ...@@ -48,7 +48,7 @@ vec product(const vec& a, const vec& b)
#endif #endif
vec res(a.size()); vec res(a.size());
for(unsigned int i=0; i<a.size(); ++i) for(int i=0; i<a.size(); ++i)
{ {
res[i] = a[i]*b[i]; res[i] = a[i]*b[i];
} }
......
...@@ -256,13 +256,26 @@ template<typename T> T clamp(T x, T a, T b) ...@@ -256,13 +256,26 @@ template<typename T> T clamp(T x, T a, T b)
return std::max<T>(std::min<T>(x, b), a); return std::max<T>(std::min<T>(x, b), a);
} }
#ifdef WIN32
#define NOT_IMPLEMENTED() \
std::cerr << "<<ERROR>> not implemented " << __FUNCDNAME__ << " in file " << __FILE__ \
<< ":" << __LINE__ << std::endl; \
throw
#else
#define NOT_IMPLEMENTED() \ #define NOT_IMPLEMENTED() \
std::cerr << "<<ERROR>> not implemented " << __PRETTY_FUNCTION__ << " in file " << __FILE__ \ std::cerr << "<<ERROR>> not implemented " << __PRETTY_FUNCTION__ << " in file " << __FILE__ \
<< ":" << __LINE__ << std::endl; \ << ":" << __LINE__ << std::endl; \
throw throw
#endif
// Mathematical definition not provided on the Window plateform
#ifdef WIN32 #ifdef WIN32
#define M_PI 3.14159265 #define M_PI 3.14159265
template<typename T> bool isnan(T x)
{
return x==std::numeric_limits<T>::signaling_NaN();
}
#endif #endif
#ifdef WIN32 #ifdef WIN32
......
...@@ -10,7 +10,7 @@ void function::save(const std::string& filename, const arguments& args) const ...@@ -10,7 +10,7 @@ void function::save(const std::string& filename, const arguments& args) const
bool is_matlab = args["export"] == "matlab"; bool is_matlab = args["export"] == "matlab";
// Open the file // Open the file
std::ofstream file(filename); std::ofstream file(filename.c_str());
if(!file.is_open()) if(!file.is_open())
{ {
std::cerr << "<<ERROR>> unable to open output file for writing" << std::endl; std::cerr << "<<ERROR>> unable to open output file for writing" << std::endl;
......
...@@ -261,7 +261,7 @@ vec rational_function_1d::value(const vec& x) const ...@@ -261,7 +261,7 @@ vec rational_function_1d::value(const vec& x) const
std::ostream& operator<< (std::ostream& out, const rational_function_1d& r) std::ostream& operator<< (std::ostream& out, const rational_function_1d& r)
{ {
std::cout << "p = [" ; std::cout << "p = [" ;
for(unsigned int i=0; i<r.a.size(); ++i) for(int i=0; i<r.a.size(); ++i)
{ {
if(i != 0) if(i != 0)
{ {
...@@ -272,7 +272,7 @@ std::ostream& operator<< (std::ostream& out, const rational_function_1d& r) ...@@ -272,7 +272,7 @@ std::ostream& operator<< (std::ostream& out, const rational_function_1d& r)
std::cout << "]" << std::endl ; std::cout << "]" << std::endl ;
std::cout << "q = [" ; std::cout << "q = [" ;
for(unsigned int i=0; i<r.b.size(); ++i) for(int i=0; i<r.b.size(); ++i)
{ {
if(i != 0) if(i != 0)
{ {
......
...@@ -57,8 +57,8 @@ void vertical_segment::load(const std::string& filename, const arguments& args) ...@@ -57,8 +57,8 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
_min.resize(dimX()) ; _min.resize(dimX()) ;
_max.resize(dimX()) ; _max.resize(dimX()) ;
min = args.get_vec("min", _nX, -std::numeric_limits<double>::max()) ; min = args.get_vec("min", _nX, -std::numeric_limits<float>::max()) ;
max = args.get_vec("max", _nX, std::numeric_limits<double>::max()) ; max = args.get_vec("max", _nX, std::numeric_limits<float>::max()) ;
for(int k=0; k<dimX(); ++k) for(int k=0; k<dimX(); ++k)
{ {
...@@ -121,7 +121,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args) ...@@ -121,7 +121,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
} }
else else
{ {
double dt = args.get_float("dt", 0.1); double dt = args.get_float("dt", 0.1f);
min_dt = -dt; min_dt = -dt;
max_dt = dt; max_dt = dt;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment