Commit 78a21634 authored by sebastien's avatar sebastien
Browse files

dynare++ tensor library: improve on implementation of TensorContainer::writeMMap()


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2923 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 345a3e58
......@@ -60,6 +60,7 @@ is multiplied by unfolded tensors $g$ yielding unfolded tensor $B$.
#include <map>
#include <string>
#include <sstream>
@<|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<string,ConstTwoDMatrix>* mm) const
void writeMMap(map<string,ConstTwoDMatrix> &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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment