Skip to content
This repository
Browse code

dealing with warnings

  • Loading branch information...
commit 3a44f7cf11984548b577bc4150506ba0626b2fab 1 parent 778f8e8
authored August 21, 2012
22  vowpalwabbit/bfgs.cc
@@ -25,7 +25,7 @@ Implementation by Miro Dudik.
25 25
 #include <exception>
26 26
 
27 27
 #ifdef _WIN32
28  
-inline bool isnan(double d) { return _isnan(d); }
  28
+inline bool isnan(double d) { return (bool)_isnan(d); }
29 29
 #endif
30 30
 
31 31
 using namespace std;
@@ -340,10 +340,10 @@ void bfgs_iter_middle(vw& all, float* mem, double* rho, double* alpha, int& last
340 340
       g_Hg += mem[(MEM_GT+origin)%mem_stride] * w[W_COND] * mem[(MEM_GT+origin)%mem_stride];
341 341
     }
342 342
 
343  
-    double beta = g_Hy/g_Hg;
  343
+    float beta = (float) (g_Hy/g_Hg);
344 344
 
345  
-    if (beta<0. || nanpattern(beta))
346  
-      beta = 0.;
  345
+    if (beta<0.f || nanpattern(beta))
  346
+      beta = 0.f;
347 347
       
348 348
     mem = mem0;
349 349
     w = w0;
@@ -381,7 +381,7 @@ void bfgs_iter_middle(vw& all, float* mem, double* rho, double* alpha, int& last
381 381
     throw curv_ex;
382 382
   rho[0] = 1/y_s;
383 383
   
384  
-  double gamma = y_s/y_Hy;
  384
+  float gamma = (float) (y_s/y_Hy);
385 385
 
386 386
   for (int j=0; j<lastj; j++) {
387 387
     alpha[j] = rho[j] * s_q;
@@ -389,7 +389,7 @@ void bfgs_iter_middle(vw& all, float* mem, double* rho, double* alpha, int& last
389 389
     mem = mem0;
390 390
     w = w0;
391 391
     for(uint32_t i = 0; i < length; i++, mem+=mem_stride, w+=stride) {
392  
-      w[W_DIR] -= alpha[j]*mem[(2*j+MEM_YT+origin)%mem_stride];
  392
+      w[W_DIR] -= (float)alpha[j]*mem[(2*j+MEM_YT+origin)%mem_stride];
393 393
       s_q += mem[(2*j+2+MEM_ST+origin)%mem_stride]*w[W_DIR];
394 394
     }
395 395
   }
@@ -399,7 +399,7 @@ void bfgs_iter_middle(vw& all, float* mem, double* rho, double* alpha, int& last
399 399
   mem = mem0;
400 400
   w = w0;
401 401
   for(uint32_t i = 0; i < length; i++, mem+=mem_stride, w+=stride) {
402  
-    w[W_DIR] -= alpha[lastj]*mem[(2*lastj+MEM_YT+origin)%mem_stride];
  402
+    w[W_DIR] -= (float)alpha[lastj]*mem[(2*lastj+MEM_YT+origin)%mem_stride];
403 403
     w[W_DIR] *= gamma*w[W_COND];
404 404
     y_r += mem[(2*lastj+MEM_YT+origin)%mem_stride]*w[W_DIR];
405 405
   }
@@ -412,7 +412,7 @@ void bfgs_iter_middle(vw& all, float* mem, double* rho, double* alpha, int& last
412 412
     mem = mem0;
413 413
     w = w0;
414 414
     for(uint32_t i = 0; i < length; i++, mem+=mem_stride, w+=stride) {
415  
-      w[W_DIR] += coef_j*mem[(2*j+MEM_ST+origin)%mem_stride];
  415
+      w[W_DIR] += (float)coef_j*mem[(2*j+MEM_ST+origin)%mem_stride];
416 416
       y_r += mem[(2*j-2+MEM_YT+origin)%mem_stride]*w[W_DIR];
417 417
     }
418 418
   }
@@ -421,7 +421,7 @@ void bfgs_iter_middle(vw& all, float* mem, double* rho, double* alpha, int& last
421 421
   mem = mem0;
422 422
   w = w0;
423 423
   for(uint32_t i = 0; i < length; i++, mem+=mem_stride, w+=stride) {
424  
-    w[W_DIR] = -w[W_DIR]-coef_j*mem[(MEM_ST+origin)%mem_stride];
  424
+    w[W_DIR] = -w[W_DIR]-(float)coef_j*mem[(MEM_ST+origin)%mem_stride];
425 425
   }
426 426
   
427 427
   /*********************
@@ -502,13 +502,13 @@ void finalize_preconditioner(vw& all, float regularization)
502 502
     for(uint32_t i = 0; i < length; i++) {
503 503
       weights[stride*i+3] += regularization;
504 504
       if (weights[stride*i+3] > 0)
505  
-	weights[stride*i+3] = 1. / weights[stride*i+3];
  505
+	weights[stride*i+3] = 1.f / weights[stride*i+3];
506 506
     }
507 507
   else
508 508
     for(uint32_t i = 0; i < length; i++) {
509 509
       weights[stride*i+3] += all.reg.regularizers[2*i];
510 510
       if (weights[stride*i+3] > 0)
511  
-	weights[stride*i+3] = 1. / weights[stride*i+3];
  511
+	weights[stride*i+3] = 1.f / weights[stride*i+3];
512 512
     }
513 513
 }
514 514
 
6  vowpalwabbit/parse_primitives.h
@@ -116,7 +116,7 @@ inline float parseFloat(char * p, char **end)
116 116
     s = -1; p++;
117 117
   }
118 118
   
119  
-  double acc = 0;
  119
+  float acc = 0;
120 120
   while (*p >= '0' && *p <= '9')
121 121
     acc = acc * 10 + *p++ - '0';
122 122
   
@@ -142,12 +142,12 @@ inline float parseFloat(char * p, char **end)
142 142
   }
143 143
   if (*p == ' ')//easy case succeeded.
144 144
     {
145  
-      acc *= powf(10,exp_acc-num_dec);
  145
+      acc *= powf(10,(float)(exp_acc-num_dec));
146 146
       *end = p;
147 147
       return s * acc;
148 148
     }
149 149
   else
150  
-    return strtod(start,end);
  150
+    return (float)strtod(start,end);
151 151
 }
152 152
 
153 153
 inline bool nanpattern( float value ) { return ((*(uint32_t*)&value) & 0x7fffffff) > 0x7f800000; } 
2  vowpalwabbit/sparse_dense.h
@@ -13,7 +13,7 @@ embodied in the content of this file are licensed under the BSD
13 13
 inline float sign(float w){ if (w < 0.) return -1.; else  return 1.;}
14 14
 
15 15
 inline float trunc_weight(float w, float gravity){
16  
-  return (gravity < fabsf(w)) ? w - sign(w) * gravity : 0.;
  16
+  return (gravity < fabsf(w)) ? w - sign(w) * gravity : 0.f;
17 17
 }
18 18
 
19 19
 float sd_add(weight* weights, size_t mask, feature* begin, feature* end);

0 notes on commit 3a44f7c

Please sign in to comment.
Something went wrong with that request. Please try again.