Browse Source

MatrixXr serialization updated.

submodule
T-bone 6 years ago
parent
commit
360b475614
1 changed files with 9 additions and 5 deletions
  1. 9
    5
      Modules/LemmaCore/include/helper.h

+ 9
- 5
Modules/LemmaCore/include/helper.h View File

@@ -306,11 +306,15 @@ struct convert<Lemma::MatrixXr> {
306 306
     if( node.Tag() != "MatrixXr" ) {
307 307
         return false;
308 308
     }
309
-    rhs.resize( node["rows"].as<int>(), node["cols"].as<int>() );
310
-    int ir=0;
311
-    for(YAML::const_iterator it=node[0].begin(); it!=node[0].end(); ++it) {
312
-        rhs(ir) = it->as<Lemma::Real>();
313
-        ++ir;
309
+    int nc = node["cols"].as<int>();
310
+    int nr = node["rows"].as<int>();
311
+    rhs.resize(nr, nc);
312
+    for (int ir=0; ir<nr; ++ir) {
313
+        int ic=0;
314
+        for(YAML::const_iterator it=node[ir].begin(); it!=node[ir].end(); ++it) {
315
+            rhs(ir,ic) = it->as<Lemma::Real>();
316
+            ++ic;
317
+        }
314 318
     }
315 319
     return true;
316 320
   }

Loading…
Cancel
Save