Bladeren bron

Cleaning up MSVC compiler warnings

add-code-of-conduct-1
John Daily 6 jaren geleden
bovenliggende
commit
6f23d0d820

+ 1
- 1
Modules/FDEM1D/include/FHT.h Bestand weergeven

@@ -267,7 +267,7 @@ namespace Lemma {
267 267
 
268 268
         // lambda needs to be expanded to include lagged results
269 269
         VectorXr lambda = (VectorXr(WT.rows()+nlag) << WT.col(0).array()/rho, VectorXr::Zero(nlag)).finished();
270
-        for (int ilam =WT.rows(); ilam< nlag+WT.rows(); ++ilam) {
270
+        for (Index ilam = WT.rows(); ilam< nlag+WT.rows(); ++ilam) {
271 271
             lambda(ilam) = lambda(ilam-1)/GetABSER();
272 272
         }
273 273
 

+ 1
- 1
Modules/FDEM1D/include/HankelTransformFactory.h Bestand weergeven

@@ -119,8 +119,8 @@ namespace Lemma {
119 119
                     return FHT<IRONS>::NewSP();
120 120
                 default:
121 121
                     std::cerr << "HankelTransformFactory only works with defined types\n";
122
+                    return FHTAnderson801::NewSP(); // dummy return 
122 123
             }
123
-
124 124
         }
125 125
 
126 126
         /**

+ 2
- 2
Modules/FDEM1D/include/KernelEM1DBase.h Bestand weergeven

@@ -67,7 +67,7 @@ namespace Lemma {
67 67
 
68 68
             virtual void SetMode(const EMMODE& mode)=0;
69 69
 
70
-            int GetManagerIndex() const {
70
+            Index GetManagerIndex() const {
71 71
                 return this->managerIdx;
72 72
             }
73 73
 
@@ -91,7 +91,7 @@ namespace Lemma {
91 91
             // ====================  DATA MEMBERS  =========================
92 92
 
93 93
             /** Where does this kernel live on the vector managed by the manager */
94
-            int  managerIdx;
94
+            Index  managerIdx;
95 95
 
96 96
         private:
97 97
 

+ 1
- 1
Modules/FDEM1D/include/WireAntenna.h Bestand weergeven

@@ -165,7 +165,7 @@ namespace Lemma {
165 165
               * returns number of dipoles used to approximate this
166 166
               * loop
167 167
 			  */
168
-            int GetNumberOfDipoles();
168
+            size_t GetNumberOfDipoles();
169 169
 
170 170
 			/**
171 171
               * @return the number of frequencies of this wire loop.

+ 2
- 2
Modules/FDEM1D/src/AEMSurveyReader.cpp Bestand weergeven

@@ -105,13 +105,13 @@ namespace Lemma {
105 105
         int nb = Parser->ReadInts(1)[0];  // number of locations
106 106
         for (int ib=0; ib<nb; ++ib) {
107 107
             std::vector<Real> rvals = Parser->ReadReals(6); // position and moment
108
-            int bp = Parser->GetFileLocation(  );
108
+	    std::streamoff bp = Parser->GetFileLocation(  );
109 109
             Parser->JumpToLocation( 0 );
110 110
             //std::vector<int> ivals = Parser->ReadInts(1);   // number of frequencies
111 111
             int nf = Parser->ReadInts(1)[0];   // number of frequencies
112 112
             for (int isc=0; isc<nf; ++isc) {
113 113
                 Survey->Sources.push_back(DipoleSource::NewSP());
114
-                int cnt = Survey->Sources.size() - 1; //
114
+                size_t cnt = Survey->Sources.size() - 1; //
115 115
                 // and now set it
116 116
                 Survey->Sources[cnt]->SetNumberOfFrequencies(1);
117 117
                 Survey->Sources[cnt]->SetFrequency(0, Parser->ReadReals(1)[0]);

+ 1
- 2
Modules/FDEM1D/src/DipoleSource.cpp Bestand weergeven

@@ -8,7 +8,6 @@
8 8
   @file
9 9
   @author   Trevor Irons
10 10
   @date     12/02/2009
11
-  @version  $Id: dipolesource.cpp 203 2015-01-09 21:19:04Z tirons $
12 11
  **/
13 12
 
14 13
 #include "DipoleSource.h"
@@ -1266,7 +1265,7 @@ namespace Lemma {
1266 1265
     }
1267 1266
 
1268 1267
     int DipoleSource::GetNumberOfFrequencies() {
1269
-        return this->Freqs.size();
1268
+        return (int)(this->Freqs.size());
1270 1269
     }
1271 1270
 
1272 1271
     void DipoleSource::SetNumberOfFrequencies(const int &nfreq){

+ 4
- 2
Modules/FDEM1D/src/GQChave.cpp Bestand weergeven

@@ -544,7 +544,7 @@ namespace Lemma{
544 544
         np  = 0; // TI, zero based indexing
545 545
 
546 546
         int  NPB   = 1; // 0?
547
-        int  L     = 0; // TODO, should be 0?
547
+        int  L     = 0; 
548 548
         Real B     = 0.;
549 549
         Real A     = 0.;
550 550
         Real SUMR  = 0.;
@@ -580,7 +580,9 @@ namespace Lemma{
580 580
                     LASTI=XSUMI;
581 581
                 }
582 582
             }
583
-            while (ZeroJ(NPB,IORDER) > XSUM(NSUM*rho)) {
583
+	    // TODO, evaluate this case triggering cerr, as well as sttement below
584
+            //while ( ZeroJ(NPB,IORDER) > XSUM(NSUM*rho)) {
585
+            while ( ZeroJ(NPB,IORDER) > XSUM( (int)(NSUM*rho) )) {
584 586
                 ++NPB;
585 587
             }
586 588
         }

+ 3
- 4
Modules/FDEM1D/src/WireAntenna.cpp Bestand weergeven

@@ -8,7 +8,6 @@
8 8
   @file
9 9
   @author   Trevor Irons
10 10
   @date     12/16/2009
11
-  @version  $Id: wireantenna.cpp 199 2014-12-29 19:25:20Z tirons $
12 11
  **/
13 12
 
14 13
 #include "WireAntenna.h"
@@ -119,7 +118,7 @@ namespace Lemma {
119 118
     }
120 119
 
121 120
     int WireAntenna::GetNumberOfFrequencies() {
122
-        return Freqs.size();
121
+        return (int)(Freqs.size());  // Index to int
123 122
     }
124 123
 
125 124
     Vector3Xr WireAntenna::GetPoints() {
@@ -223,8 +222,8 @@ namespace Lemma {
223 222
 
224 223
     // ====================  INQUIRY       =======================
225 224
 
226
-    int WireAntenna::GetNumberOfDipoles() {
227
-        return Dipoles.size();
225
+    size_t WireAntenna::GetNumberOfDipoles() {
226
+        return Dipoles.size();  // size_t to int
228 227
     }
229 228
 
230 229
     std::shared_ptr<DipoleSource> WireAntenna::GetDipoleSource(const int &dip) {

+ 4
- 5
Modules/LemmaCore/include/ASCIIParser.h Bestand weergeven

@@ -10,10 +10,9 @@
10 10
 /**
11 11
  * @file
12 12
  * @date      09/23/2013 02:31:24 PM
13
- * @version   $Id$
14 13
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
16
- * @copyright Copyright (c) 2013, Trevor Irons
14
+ * @email     Trevor.Irons@LemmaSoftware.org
15
+ * @copyright Copyright (c) 2013, 2018 Trevor Irons
17 16
  */
18 17
 
19 18
 #ifndef  ASCIIPARSER_INC
@@ -116,7 +115,7 @@ class ASCIIParser : public LemmaObject {
116 115
     /**
117 116
      * @param[in] loc is the point in the file to jump to. Uses seekg
118 117
      */
119
-    void JumpToLocation(const int& loc);
118
+    void JumpToLocation(const std::streamoff& loc);
120 119
 
121 120
     // ====================  ACCESS        =======================
122 121
 
@@ -135,7 +134,7 @@ class ASCIIParser : public LemmaObject {
135 134
     /**
136 135
      * @return the current position in the file, as reported by istream::tellg
137 136
      */
138
-    int GetFileLocation();
137
+    std::streamoff GetFileLocation();
139 138
 
140 139
     /** Returns the name of the underlying class, similiar to Python's type */
141 140
     virtual std::string GetName() const;

+ 3
- 3
Modules/LemmaCore/include/CubicSplineInterpolator.h Bestand weergeven

@@ -34,7 +34,7 @@ struct SplineSet{
34 34
     SplineSet( ) {
35 35
     }
36 36
 
37
-    SplineSet(const int&n) {
37
+    SplineSet(const Index& n) {
38 38
         a = VectorXr::Zero(n+1);
39 39
         b = VectorXr::Zero(n);
40 40
         c = VectorXr::Zero(n+1);
@@ -163,7 +163,7 @@ class CubicSplineInterpolator : public LemmaObject {
163 163
 
164 164
     /** Finds the interval of knots in spline to use for integration.
165 165
      */
166
-    int Interval(const Real& x);
166
+    Index Interval(const Real& x);
167 167
 
168 168
     private:
169 169
 
@@ -175,7 +175,7 @@ class CubicSplineInterpolator : public LemmaObject {
175 175
 
176 176
     SplineSet Spline;
177 177
 
178
-    int ilo;
178
+    Index ilo;
179 179
 
180 180
     int mflag;
181 181
 

+ 3
- 1
Modules/LemmaCore/include/lemma.h Bestand weergeven

@@ -213,7 +213,9 @@
213 213
         /// A 3 component Eigen vector of Reals
214 214
         typedef Eigen::Matrix<Real, 3, 1> Vector3r;
215 215
 
216
-        /// A 3 X Dynamic Component Eigen matrix of Reals
216
+        typedef Eigen::Matrix<Real, Eigen::Dynamic, 1>::Index Index;
217
+        
218
+	/// A 3 X Dynamic Component Eigen matrix of Reals
217 219
         typedef Eigen::Matrix<Real, 3, Eigen::Dynamic> Vector3Xr;
218 220
 
219 221
         /// Variable length Eigen vector of Reals

+ 5
- 6
Modules/LemmaCore/src/ASCIIParser.cpp Bestand weergeven

@@ -10,10 +10,9 @@
10 10
 /**
11 11
  * @file
12 12
  * @date      09/23/2013 02:33:41 PM
13
- * @version   $Id$
14 13
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
16
- * @copyright Copyright (c) 2013, Trevor Irons
14
+ * @email     Trevor.Irons@Lemmasoftware.org
15
+ * @copyright Copyright (c) 2013,2018 Trevor Irons
17 16
  */
18 17
 
19 18
 #include "ASCIIParser.h"
@@ -24,7 +23,7 @@ namespace Lemma {
24 23
     // ====================  FRIEND METHODS  =====================
25 24
 
26 25
     std::ostream &operator << (std::ostream &stream, const ASCIIParser &ob) {
27
-        stream << ob.Serialize()  << "\n---\n"; // End of doc
26
+        stream << ob.Serialize()  << "\n"; 
28 27
         return stream;
29 28
     }
30 29
 
@@ -211,7 +210,7 @@ namespace Lemma {
211 210
     //       Class:  ASCIIParser
212 211
     //      Method:  GetFileLocation
213 212
     //--------------------------------------------------------------------------------------
214
-    int ASCIIParser::GetFileLocation (  ) {
213
+    std::streamoff ASCIIParser::GetFileLocation (  ) {
215 214
         return input.tellg();
216 215
     }		// -----  end of method ASCIIParser::GetFileLocation  -----
217 216
 
@@ -219,7 +218,7 @@ namespace Lemma {
219 218
     //       Class:  ASCIIParser
220 219
     //      Method:  JumpToLocation
221 220
     //--------------------------------------------------------------------------------------
222
-    void ASCIIParser::JumpToLocation ( const int& loc ) {
221
+    void ASCIIParser::JumpToLocation ( const std::streamoff& loc ) {
223 222
         input.seekg( loc );
224 223
         return ;
225 224
     }		// -----  end of method ASCIIParser::JumpToLocation  -----

+ 19
- 19
Modules/LemmaCore/src/CubicSplineInterpolator.cpp Bestand weergeven

@@ -101,18 +101,19 @@ namespace Lemma {
101 101
     //--------------------------------------------------------------------------------------
102 102
     void CubicSplineInterpolator::SetKnots ( const VectorXr& x, const VectorXr& y ) {
103 103
 
104
-        int n = x.size()-1;
104
+        //int n = x.size()-1;
105
+        Index n = x.size()-1;
105 106
 
106 107
         Spline = SplineSet(n);
107 108
 
108 109
         Spline.a = y;
109 110
         Spline.x = x;
110 111
         VectorXr h = VectorXr::Zero(n);
111
-        for(int i=0; i<n; ++i)
112
+        for(Index i=0; i<n; ++i)
112 113
             h(i) = Spline.x(i+1)-Spline.x(i);
113 114
 
114 115
         VectorXr alpha(n-1);
115
-        for(int i=1; i<n-1; ++i)
116
+        for(Index i=1; i<n-1; ++i)
116 117
             alpha(i) =  3.*(Spline.a[i+1]-Spline.a[i])/h[i] - 3.*(Spline.a[i]-Spline.a[i-1])/h[i-1] ;
117 118
 
118 119
         VectorXr l = VectorXr::Zero(n+1);
@@ -122,7 +123,7 @@ namespace Lemma {
122 123
         mu[0] = 0;
123 124
         z[0] = 0;
124 125
 
125
-        for(int i = 1; i < n-1; ++i) {
126
+        for(Index i = 1; i < n-1; ++i) {
126 127
             l[i] = 2 *(Spline.x[i+1]-Spline.x[i-1])-h[i-1]*mu[i-1];
127 128
             mu[i] = h[i]/l[i];
128 129
             z[i] = (alpha[i]-h[i-1]*z[i-1])/l[i];
@@ -130,7 +131,7 @@ namespace Lemma {
130 131
         l[n] = 1;
131 132
         z[n] = 0;
132 133
 
133
-        for(int j = n-1; j >= 0; --j) {
134
+        for(Index j = n-1; j >= 0; --j) {
134 135
             Spline.c[j] = z[j] - mu[j] * Spline.c[j+1];
135 136
             Spline.b[j] = (Spline.a[j+1]-Spline.a[j])/h[j]-h[j]*(Spline.c[j+1]+2*Spline.c[j])/3;
136 137
             Spline.d[j] = (Spline.c[j+1]-Spline.c[j])/3/h[j];
@@ -230,9 +231,8 @@ namespace Lemma {
230 231
     //--------------------------------------------------------------------------------------
231 232
     Real CubicSplineInterpolator::Integrate ( const Real& x0, const Real& x1 ) {
232 233
 
233
-
234
-        int i0 = Interval(x0);
235
-        int i1 = Interval(x1);
234
+        Index i0 = Interval(x0);
235
+        Index i1 = Interval(x1);
236 236
 
237 237
         Real h0 = x0 - Spline.x(i0);
238 238
         if (mflag == -1) h0 = 0;
@@ -245,7 +245,7 @@ namespace Lemma {
245 245
 
246 246
         // Include integrals over intervening intervals.
247 247
         if (i1 > i0) {
248
-            for (int i=i0; i<i1-1; ++i) {
248
+            for (Index i=i0; i<i1-1; ++i) {
249 249
                 Real h = Spline.x(i+1) - Spline.x(i);
250 250
                 cubint +=  (((Spline.d(i)*h/4.0 + Spline.c(i) )*h/3.0 +
251 251
                               Spline.b(i))*h/2.0 + Spline.a(i) )*h;
@@ -260,10 +260,10 @@ namespace Lemma {
260 260
     //       Class:  CubicSplineInterpolator
261 261
     //      Method:  Interval
262 262
     //--------------------------------------------------------------------------------------
263
-    int CubicSplineInterpolator::Interval ( const Real& x ) {
263
+    Index CubicSplineInterpolator::Interval ( const Real& x ) {
264 264
 
265 265
         std::cerr << "ENTERING CubicSplineInterpolator::Inverval. Known bugs here"  << std::endl;
266
-        int nx = Spline.x.size() - 2; // TODO check if this is correct or just -1
266
+        Index nx = Spline.x.size() - 2; // TODO check if this is correct or just -1
267 267
         // when x not in range
268 268
         if (x <= Spline.x(0) || nx <= 1 ) {
269 269
             mflag = -1;
@@ -277,7 +277,7 @@ namespace Lemma {
277 277
 
278 278
         mflag = 0;
279 279
         if (ilo >= nx) ilo = nx-1;
280
-        int ihi = ilo+1;
280
+        Index ihi = ilo+1;
281 281
 
282 282
         // if x is already in the interval
283 283
         if ( x<Spline.x(ihi) && x >= Spline.x(ilo) ) {
@@ -286,17 +286,17 @@ namespace Lemma {
286 286
         }
287 287
 
288 288
         if (x <= Spline.x(ilo)) { // decrease ilo to capture
289
-            int istep = 1;
290
-            for (int ix=1; ix<nx; ++ix) {
289
+            Index istep = 1;
290
+            for (Index ix=1; ix<nx; ++ix) {
291 291
                 ihi = ilo;
292 292
                 ilo = ihi - istep;
293
-                ilo = std::max(1, ilo);
293
+                ilo = std::max(Index(1), ilo);
294 294
                 if (x >= Spline.x(ilo) || ilo == 1) break;
295 295
                 istep *= 2;
296 296
             }
297 297
         } else if (x >= Spline.x(ihi)) { // increase ihi to capture
298
-            int istep = 1;
299
-            for (int ix=1; ix<nx; ++ix) {
298
+            Index istep = 1;
299
+            for (Index ix=1; ix<nx; ++ix) {
300 300
                 ilo = ihi;
301 301
                 ihi = ilo + istep;
302 302
                 ihi = std::min(ihi, nx);
@@ -307,8 +307,8 @@ namespace Lemma {
307 307
 
308 308
         // Now Spline.x(ilo) <= x < Spline.x(ihi) --> Narrow the interval.
309 309
         //std::cout << "WIDE INTERVAL " << Spline.x(ilo) << "\t" << x << "\t" << Spline.x(ihi) << std::endl;
310
-        for (int ix=1; ix<nx; ++ix) {
311
-            int middle = (ilo+ihi) / 2;
310
+        for (Index ix=1; ix<nx; ++ix) {
311
+            Index middle = (ilo+ihi) / 2;
312 312
             if (middle == ilo) break;
313 313
             if (x < Spline.x(middle)) {
314 314
                 ihi = middle;

+ 8
- 4
Modules/LemmaCore/src/RectilinearGrid.cpp Bestand weergeven

@@ -16,7 +16,7 @@
16 16
 namespace Lemma {
17 17
 
18 18
     std::ostream &operator << (std::ostream &stream, const RectilinearGrid &ob) {
19
-        stream << ob.Serialize()  << "\n---\n"; // End of doc
19
+        stream << ob.Serialize()  << "\n"; 
20 20
         return stream;
21 21
     }
22 22
 
@@ -111,9 +111,13 @@ namespace Lemma {
111 111
 
112 112
     void RectilinearGrid::SetSpacing (const VectorXr &idx, const VectorXr &idy,
113 113
                 const VectorXr &idz) {
114
-        nx = idx.size();
115
-        ny = idy.size();
116
-        nz = idz.size();
114
+        // MSVC doens't allow static_cast here
115
+        //nx = std::static_cast<int>( idx.size() );
116
+        //ny = std::static_cast<int>( idy.size() );
117
+        //nz = std::static_cast<int>( idz.size() );
118
+        nx = (int)( idx.size() );
119
+        ny = (int)( idy.size() );
120
+        nz = (int)( idz.size() );
117 121
         dx = idx;
118 122
         dy = idy;
119 123
         dz = idz;

+ 1
- 2
Modules/LemmaCore/src/WindowFilter.cpp Bestand weergeven

@@ -8,7 +8,6 @@
8 8
   @file
9 9
   @author   Trevor Irons
10 10
   @date     07/20/2010
11
-  @version  $Id: windowfilter.cpp 87 2013-09-05 22:44:05Z tirons $
12 11
  **/
13 12
 
14 13
 #include "WindowFilter.h"
@@ -134,7 +133,7 @@ namespace Lemma {
134 133
         std::cout << "Window nyquist " << Nyquist << std::endl;
135 134
         std::cout << "Window Nw  " << Nw << std::endl;
136 135
         Real  df      = (Nyquist)/((Real)(Nw)); // df Hz per bin
137
-        Width         = Bandwidth/df;
136
+        Width         = (int)(std::round(Bandwidth/df));
138 137
         Coefficients.resize(Width);
139 138
         switch (Type) {
140 139
             case HAMMING:

Laden…
Annuleren
Opslaan