Bläddra i källkod

Serializing of MatrixXr started...not yet settled.

submodule
T-bone 7 år sedan
förälder
incheckning
f3e877d0ca
2 ändrade filer med 30 tillägg och 0 borttagningar
  1. 1
    0
      Modules/LemmaCore/include/LayeredEarth.h
  2. 29
    0
      Modules/LemmaCore/include/helper.h

+ 1
- 0
Modules/LemmaCore/include/LayeredEarth.h Visa fil

@@ -28,6 +28,7 @@ namespace Lemma {
28 28
 	class LayeredEarth : public EarthModel {
29 29
 
30 30
         friend class LayeredEarthEM;
31
+        friend class LayeredEarthMR;
31 32
 
32 33
 		public:
33 34
 

+ 29
- 0
Modules/LemmaCore/include/helper.h Visa fil

@@ -284,6 +284,35 @@ struct convert<Lemma::Vector3r> {
284 284
   }
285 285
 };
286 286
 
287
+template<>
288
+struct convert<Lemma::MatrixXr> {
289
+  static Node encode(const Lemma::MatrixXr& rhs) {
290
+    Node node;
291
+    node["rows"] = rhs.rows();
292
+    node["cols"] = rhs.cols();
293
+    for (int ir=0; ir<rhs.rows(); ++ir) {
294
+        for (int ic=0; ic<rhs.cols(); ++ic) {
295
+            node["data"].push_back( rhs(ir,ic) );
296
+        }
297
+    }
298
+    node.SetTag( "MatrixXr" );
299
+    return node;
300
+  }
301
+
302
+//   static bool decode(const Node& node, Lemma::Vector3r& rhs) {
303
+//     if( node.Tag() != "Vector3r" ) {
304
+//         return false;
305
+//     }
306
+//     int ir=0;
307
+//     for(YAML::const_iterator it=node[0].begin(); it!=node[0].end(); ++it) {
308
+//         rhs(ir) = it->as<Lemma::Real>();
309
+//         ++ir;
310
+//     }
311
+//     return true;
312
+//   }
313
+
314
+};
315
+
287 316
 }
288 317
 
289 318
 #endif   // ----- #ifndef HELPER_INC  -----

Laddar…
Avbryt
Spara