From: Gann B. <ga...@us...> - 2001-08-09 18:04:10
|
Update of /cvsroot/maxent/maxentc In directory usw-pr-cvs1:/tmp/cvs-serv25028 Modified Files: GISModel.cpp GISModel.h Log Message: Changed to different hash implementation to reduce memory Index: GISModel.cpp =================================================================== RCS file: /cvsroot/maxent/maxentc/GISModel.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GISModel.cpp 2001/05/01 10:17:26 1.6 --- GISModel.cpp 2001/08/09 18:04:08 1.7 *************** *** 43,48 **** delete[] ocNames; delete[] params; ! for(iStringIntMap iSIM = pmap.begin(); iSIM!=pmap.end(); iSIM++) ! delete (*iSIM).first; --- 43,49 ---- delete[] ocNames; delete[] params; ! // for(iStringIntMap iSIM = pmap.begin(); iSIM!=pmap.end(); iSIM++) ! // delete (*iSIM).first; ! pmap.Clear(); *************** *** 119,124 **** int numPreds = gzReadInt(modelinfo); for (i=0; i<numPreds; i++) { ! char* szFeature = gzReadStringCopy(modelinfo); ! pmap[szFeature] = i; } --- 120,125 ---- int numPreds = gzReadInt(modelinfo); for (i=0; i<numPreds; i++) { ! char* szFeature = gzReadString(modelinfo); ! pmap.put(szFeature, i); } *************** *** 131,135 **** for (int k=1; k<typelengths[i]; k++) { double d = gzReadDouble(modelparams); ! (params[pid])[types[i][k]] = d; } // if we could, we would trim the hash_map down to size --- 132,136 ---- for (int k=1; k<typelengths[i]; k++) { double d = gzReadDouble(modelparams); ! (params[pid]).put(types[i][k], d); } // if we could, we would trim the hash_map down to size *************** *** 166,177 **** for (int i=0; i<nNumPreds; i++) { ! if (pmap.find(context[i])!=pmap.end()) { ! IntDoubleMap idmap = params[(*pmap.find(context[i])).second]; ! for(iIntDoubleMap iIDM = idmap.begin(); iIDM!=idmap.end(); iIDM++) { ! int oid = (*iIDM).first; ! double param = (*iIDM).second; NUMFEATS[oid]++; OUTSUMS[oid] += fval * param; } } } --- 167,181 ---- for (int i=0; i<nNumPreds; i++) { ! if (pmap.bContains(context[i])) { ! IntDoubleMap* idmap = &(params[pmap.get(context[i])]); ! //for(iIntDoubleMap iIDM = idmap.begin(); iIDM!=idmap.end(); iIDM++) { ! idmap->Reset(); ! while(IntDoubleMap::HashMapEntry* next = idmap->pGetNextEntry()) { ! int oid = next->key; ! double param = next->value; NUMFEATS[oid]++; OUTSUMS[oid] += fval * param; } + //} } } Index: GISModel.h =================================================================== RCS file: /cvsroot/maxent/maxentc/GISModel.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GISModel.h 2001/05/01 10:17:26 1.7 --- GISModel.h 2001/08/09 18:04:08 1.8 *************** *** 22,31 **** #include <stdio.h> #ifdef WIN32 #include "include/zlib.h" - #include "include/stl_hash.h" #else #include <zlib.h> - #include <hash_map.h> #endif #include <string.h> --- 22,31 ---- #include <stdio.h> + // this is a temporary include + #include "HashMap.h" #ifdef WIN32 #include "include/zlib.h" #else #include <zlib.h> #endif #include <string.h> *************** *** 34,52 **** #define MAX_LINE_SIZE 200 ! struct strequal { ! bool operator()(char* x, char* y) { ! return strcmp(x,y)==0; ! } }; ! #ifdef WIN32 ! typedef std::hash_map<char*,int, std::hash<char*>, strequal > StringIntMap; ! typedef std::hash_map<int,double> IntDoubleMap; ! #else ! typedef hash_map<char*,int, hash<char*>, strequal > StringIntMap; ! typedef hash_map<int,double> IntDoubleMap; ! #endif ! typedef IntDoubleMap::iterator iIntDoubleMap; ! typedef StringIntMap::iterator iStringIntMap; /** --- 34,68 ---- #define MAX_LINE_SIZE 200 ! class sznHashMapFunctions : public szHashFunctions { ! public: ! static int copyVal(int n) { return n; } ! static void delVal(int n) { } }; ! typedef HashMap<char*, int, sznHashMapFunctions> StringIntMap; ! ! class ndHashMapFunctions : public nHashFunctions { ! public: ! static double copyVal(double n) { return n; } ! static void delVal(double n) { } ! }; ! ! typedef HashMap<int, double, ndHashMapFunctions> IntDoubleMap; ! ! ! //struct strequal { ! // bool operator()(char* x, char* y) { ! // return strcmp(x,y)==0; ! // } ! //}; ! //#ifdef WIN32 ! //typedef std::hash_map<char*,int, std::hash<char*>, strequal > StringIntMap; ! //typedef std::hash_map<int,double> IntDoubleMap; ! //#else ! //typedef hash_map<char*,int, hash<char*>, strequal > StringIntMap; ! //typedef hash_map<int,double> IntDoubleMap; ! //#endif ! //typedef IntDoubleMap::iterator iIntDoubleMap; ! //typedef StringIntMap::iterator iStringIntMap; /** |