dynare++ tensor library: improve on implementation of TensorContainer::writeMMap()
git-svn-id: https://www.dynare.org/svn/dynare/trunk@2923 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
345a3e587a
commit
78a216344f
|
@ -60,6 +60,7 @@ is multiplied by unfolded tensors $g$ yielding unfolded tensor $B$.
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
@<|ltsym| predicate@>;
|
@<|ltsym| predicate@>;
|
||||||
@<|TensorContainer| class definition@>;
|
@<|TensorContainer| class definition@>;
|
||||||
|
@ -295,23 +296,19 @@ void writeMat4(FILE* fd, const char* prefix) const
|
||||||
|
|
||||||
@ Output to the Memory Map.
|
@ Output to the Memory Map.
|
||||||
@<|TensorContainer::writeMMap| code@>=
|
@<|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) {
|
ostringstream lname;
|
||||||
char lname[100];
|
for (const_iterator it = begin(); it != end(); ++it) {
|
||||||
sprintf(lname, "g");
|
lname.str(prefix);
|
||||||
const Symmetry& sym = (*it).first;
|
lname << "_g";
|
||||||
for (int i = 0; i < sym.num(); i++) {
|
const Symmetry& sym = (*it).first;
|
||||||
char tmp[10];
|
for (int i = 0; i < sym.num(); i++)
|
||||||
sprintf(tmp, "_%d", sym[i]);
|
lname << "_" << sym[i];
|
||||||
strcat(lname, tmp);
|
mm.insert(make_pair(lname.str(), ConstTwoDMatrix(*((*it).second))));
|
||||||
}
|
}
|
||||||
ConstTwoDMatrix mx(*((*it).second));
|
|
||||||
mm->insert(make_pair(string(lname),mx));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ Here we fetch all tensors given by symmetry and equivalence. We go
|
@ Here we fetch all tensors given by symmetry and equivalence. We go
|
||||||
through all equivalence classes, calculate implied symmetry, and
|
through all equivalence classes, calculate implied symmetry, and
|
||||||
fetch its tensor storing it in the same order to the vector.
|
fetch its tensor storing it in the same order to the vector.
|
||||||
|
|
Loading…
Reference in New Issue