diff --git a/dynare++/tl/cc/t_container.hweb b/dynare++/tl/cc/t_container.hweb index ed4334f7b..be411b7f9 100644 --- a/dynare++/tl/cc/t_container.hweb +++ b/dynare++/tl/cc/t_container.hweb @@ -60,6 +60,7 @@ is multiplied by unfolded tensors $g$ yielding unfolded tensor $B$. #include #include +#include @<|ltsym| predicate@>; @<|TensorContainer| class definition@>; @@ -295,23 +296,19 @@ void writeMat4(FILE* fd, const char* prefix) const @ Output to the Memory Map. @<|TensorContainer::writeMMap| code@>= -void writeMMap(map* mm) const +void writeMMap(map &mm, const string &prefix) const { - for (const_iterator it = begin(); it != end(); ++it) { - char lname[100]; - sprintf(lname, "g"); - const Symmetry& sym = (*it).first; - for (int i = 0; i < sym.num(); i++) { - char tmp[10]; - sprintf(tmp, "_%d", sym[i]); - strcat(lname, tmp); - } - ConstTwoDMatrix mx(*((*it).second)); - mm->insert(make_pair(string(lname),mx)); - } + ostringstream lname; + for (const_iterator it = begin(); it != end(); ++it) { + lname.str(prefix); + lname << "_g"; + const Symmetry& sym = (*it).first; + for (int i = 0; i < sym.num(); i++) + lname << "_" << sym[i]; + mm.insert(make_pair(lname.str(), ConstTwoDMatrix(*((*it).second)))); + } } - @ Here we fetch all tensors given by symmetry and equivalence. We go through all equivalence classes, calculate implied symmetry, and fetch its tensor storing it in the same order to the vector.