From: <mk...@us...> - 2003-08-15 07:36:21
|
Update of /cvsroot/csp/APPLICATIONS/SimData/Source In directory sc8-pr-cvs1:/tmp/cvs-serv18849/Source Modified Files: Date.cpp HashUtility.cpp Key.cpp Version.cpp Log Message: Index: Date.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Source/Date.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Date.cpp 14 Aug 2003 12:19:12 -0000 1.5 --- Date.cpp 15 Aug 2003 06:59:16 -0000 1.6 *************** *** 22,106 **** #include <SimData/Date.h> ///////////////////////////////////////////////////////////// - // // 'fast' timing routines (1-2 msec accuracy) - // - ///////////////////////////////////////////////////////////// - #ifdef _WIN32 ! #include <Windows.h> ! #include <ctime> ! static LARGE_INTEGER _tstart, _tend; ! static LARGE_INTEGER freq; ! void tstart(void) ! { ! static int first = 1; ! if(first) { ! QueryPerformanceFrequency(&freq); ! first = 0; ! } ! QueryPerformanceCounter(&_tstart); ! } ! void tend(void) ! { ! QueryPerformanceCounter(&_tend); ! } ! double tval() ! { ! return ((double)_tend.QuadPart - ! (double)_tstart.QuadPart)/((double)freq.QuadPart); ! } ! timing_t get_realtime() { ! static double scale; ! static int first = 1; ! LARGE_INTEGER x; ! double now; ! if (first) { ! QueryPerformanceFrequency(&x); ! first = 0; ! scale = 1.0 / (double)x.QuadPart; } - QueryPerformanceCounter(&x); - now = (double)x.QuadPart; - return (timing_t) (now * scale); - } #else ! #include <sys/time.h> ! #include <unistd.h> ! static struct timeval _tstart, _tend; ! static struct timezone tz; ! void tstart(void) ! { ! gettimeofday(&_tstart, &tz); ! } ! void tend(void) ! { ! gettimeofday(&_tend,&tz); ! } ! double tval() ! { ! double t1, t2; ! t1 = (double)_tstart.tv_sec + (double)_tstart.tv_usec/(1000*1000); ! t2 = (double)_tend.tv_sec + (double)_tend.tv_usec/(1000*1000); ! return t2-t1; ! } ! timing_t get_realtime() { ! struct timezone tz; ! struct timeval now; ! gettimeofday(&now, &tz); ! return (timing_t) ((double)now.tv_sec + (double)now.tv_usec*1.0e-6); ! } #endif --- 22,101 ---- #include <SimData/Date.h> + + + NAMESPACE_SIMDATA + + ///////////////////////////////////////////////////////////// // 'fast' timing routines (1-2 msec accuracy) #ifdef _WIN32 ! #include <Windows.h> ! #include <ctime> ! static LARGE_INTEGER _tstart, _tend; ! static LARGE_INTEGER freq; ! void tstart(void) { ! static int first = 1; ! if (first) { ! QueryPerformanceFrequency(&freq); ! first = 0; ! } ! QueryPerformanceCounter(&_tstart); ! } ! void tend(void) { ! QueryPerformanceCounter(&_tend); ! } ! double tval() { ! return ((double)_tend.QuadPart - ! (double)_tstart.QuadPart)/((double)freq.QuadPart); ! } ! timing_t get_realtime() { ! static double scale; ! static int first = 1; ! LARGE_INTEGER x; ! double now; ! if (first) { ! QueryPerformanceFrequency(&x); ! first = 0; ! scale = 1.0 / (double)x.QuadPart; ! } ! QueryPerformanceCounter(&x); ! now = (double)x.QuadPart; ! return (timing_t) (now * scale); } #else ! #include <sys/time.h> ! #include <unistd.h> ! static struct timeval _tstart, _tend; ! static struct timezone tz; ! void tstart(void) { ! gettimeofday(&_tstart, &tz); ! } ! void tend(void) { ! gettimeofday(&_tend,&tz); ! } ! double tval() { ! double t1, t2; ! t1 = (double)_tstart.tv_sec + (double)_tstart.tv_usec/(1000*1000); ! t2 = (double)_tend.tv_sec + (double)_tend.tv_usec/(1000*1000); ! return t2-t1; ! } ! timing_t get_realtime() { ! struct timezone tz; ! struct timeval now; ! gettimeofday(&now, &tz); ! return (timing_t) ((double)now.tv_sec + (double)now.tv_usec*1.0e-6); ! } #endif *************** *** 108,114 **** ///////////////////////////////////////////////////////////// // end of timing routines - ///////////////////////////////////////////////////////////// - - NAMESPACE_SIMDATA --- 103,106 ---- *************** *** 436,440 **** double DateZulu::getAccurateMST(radian_t longitude) const { double JD = getJulianDate(); ! double T = (JD - EPOCH) * F1p0_36525p0; double F = DAYSEC * (JD - (int) JD); double GMST = COEFF0 - DAYSEC/2.0L --- 428,432 ---- double DateZulu::getAccurateMST(radian_t longitude) const { double JD = getJulianDate(); ! double T = (JD - EPOCH) * SIMDATA_F1p0_36525p0; double F = DAYSEC * (JD - (int) JD); double GMST = COEFF0 - DAYSEC/2.0L *************** *** 448,452 **** double DateZulu::getMST(radian_t longitude) const { double JD = getJulianDate(); ! double T = (JD - EPOCH) * F1p0_36525p0; double F = DAYSEC * (JD - (int) JD); double GMST = COEFF0 - DAYSEC/2.0L --- 440,444 ---- double DateZulu::getMST(radian_t longitude) const { double JD = getJulianDate(); ! double T = (JD - EPOCH) * SIMDATA_F1p0_36525p0; double F = DAYSEC * (JD - (int) JD); double GMST = COEFF0 - DAYSEC/2.0L Index: HashUtility.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Source/HashUtility.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HashUtility.cpp 14 Aug 2003 12:19:12 -0000 1.7 --- HashUtility.cpp 15 Aug 2003 06:59:16 -0000 1.8 *************** *** 22,28 **** * @file HashUtility.cpp * ! * Hash routines coded here are from "Hash Functions for Hash Table Lookup" ! * by Robert J. Jenkins Jr., <http://burtleburtle.net/bob/hash/evahash.html> ! * */ #include <sstream> --- 22,28 ---- * @file HashUtility.cpp * ! * The hash functions coded here are from "Hash Functions for Hash ! * Table Lookup" by Robert J. Jenokins Jr., and are Public Domain. ! * See <http://burtleburtle.net/bob/hash/evahash.html> */ #include <sstream> *************** *** 36,40 **** HASH<const char*> hashstring::h; ! /* The mixing step */ #define mix(a,b,c) \ { \ --- 36,40 ---- HASH<const char*> hashstring::h; ! // The mixing step #define mix(a,b,c) \ { \ *************** *** 50,122 **** } ! /* The whole new hash function */ ! u4 newhash( register u1 const *k, u4 length, u4 initval) ! //register u1 *k; /* the key */ ! //u4 length; /* the length of the key in bytes */ ! //u4 initval; /* the previous hash, or an arbitrary value */ { ! register u4 a,b,c; /* the internal state */ ! u4 len; /* how many key bytes still need mixing */ ! /* Set up the internal state */ len = length; ! a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */ ! c = initval; /* variable initialization of internal state */ ! /*---------------------------------------- handle most of the key */ while (len >= 12) { ! a=a+(k[0]+((u4)k[1]<<8)+((u4)k[2]<<16) +((u4)k[3]<<24)); ! b=b+(k[4]+((u4)k[5]<<8)+((u4)k[6]<<16) +((u4)k[7]<<24)); ! c=c+(k[8]+((u4)k[9]<<8)+((u4)k[10]<<16)+((u4)k[11]<<24)); mix(a,b,c); k = k+12; len = len-12; } ! /*------------------------------------- handle the last 11 bytes */ c = c+length; ! switch(len) /* all the case statements fall through */ ! { ! case 11: c=c+((u4)k[10]<<24); ! case 10: c=c+((u4)k[9]<<16); ! case 9 : c=c+((u4)k[8]<<8); ! /* the first byte of c is reserved for the length */ ! case 8 : b=b+((u4)k[7]<<24); ! case 7 : b=b+((u4)k[6]<<16); ! case 6 : b=b+((u4)k[5]<<8); ! case 5 : b=b+k[4]; ! case 4 : a=a+((u4)k[3]<<24); ! case 3 : a=a+((u4)k[2]<<16); ! case 2 : a=a+((u4)k[1]<<8); ! case 1 : a=a+k[0]; ! /* case 0: nothing left to add */ } mix(a,b,c); ! /*-------------------------------------------- report the result */ return c; } ! /** ! * Generate a 32-bit hash from a string */ ! u4 newhash4_cstring(std::string const &str) { ! return newhash((u1 const*)str.c_str(), str.size(), 0); } ! /** ! * Generate a 64-bit hash from a string */ - u8 newhash8_cstring(std::string const &str) { - u8 h0, h1; - h0 = newhash((u1 const*)str.c_str(), str.size(), 0); - h1 = newhash((u1 const*)str.c_str(), str.size(), 1); - return ((h1 << 32) | h0); - } - HashT newhasht_cstring(std::string const &str) { ! u4 h0, h1; ! h0 = newhash((u1 const*)str.c_str(), str.size(), 0); ! h1 = newhash((u1 const*)str.c_str(), str.size(), 1); return HashT(h1, h0); } --- 50,116 ---- } ! /** A character string to 32-bit hash function. ! * ! * @author Bob Jenkins, December 1996, Public Domain. ! * ! * @param k the string to hash ! * @param length the length of the string in bytes. ! * @param initval the previous hash, or an arbitrary value ! */ ! uint32 newhash(register uint8 const *k, uint32 length, uint32 initval) { ! register uint32 a,b,c; // the internal state ! uint32 len; // how many key bytes still need mixing ! // Set up the internal state len = length; ! a = b = 0x9e3779b9; // the golden ratio; an arbitrary value ! c = initval; // variable initialization of internal state ! // handle most of the key while (len >= 12) { ! a=a+(k[0]+((uint32)k[1]<<8)+((uint32)k[2]<<16) +((uint32)k[3]<<24)); ! b=b+(k[4]+((uint32)k[5]<<8)+((uint32)k[6]<<16) +((uint32)k[7]<<24)); ! c=c+(k[8]+((uint32)k[9]<<8)+((uint32)k[10]<<16)+((uint32)k[11]<<24)); mix(a,b,c); k = k+12; len = len-12; } ! // handle the last 11 bytes c = c+length; ! switch(len) { // all the case statements fall through ! case 11: c=c+((uint32)k[10]<<24); ! case 10: c=c+((uint32)k[9]<<16); ! case 9 : c=c+((uint32)k[8]<<8); ! // the first byte of c is reserved for the length ! case 8 : b=b+((uint32)k[7]<<24); ! case 7 : b=b+((uint32)k[6]<<16); ! case 6 : b=b+((uint32)k[5]<<8); ! case 5 : b=b+k[4]; ! case 4 : a=a+((uint32)k[3]<<24); ! case 3 : a=a+((uint32)k[2]<<16); ! case 2 : a=a+((uint32)k[1]<<8); ! case 1 : a=a+k[0]; ! // case 0: nothing left to add } mix(a,b,c); ! // report the result return c; } ! /** Generate a 32-bit hash from a string */ ! uint32 newhash4_cstring(std::string const &str) { ! return newhash((uint8 const*)str.c_str(), str.size(), 0); } ! /** Generate a 64-bit hash (HashT) from a string */ HashT newhasht_cstring(std::string const &str) { ! uint32 h0, h1; ! h0 = newhash((uint8 const*)str.c_str(), str.size(), 0); ! h1 = newhash((uint8 const*)str.c_str(), str.size(), 1); return HashT(h1, h0); } Index: Key.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Source/Key.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Key.cpp 6 Aug 2003 06:36:25 -0000 1.2 --- Key.cpp 15 Aug 2003 06:59:16 -0000 1.3 *************** *** 42,46 **** int k; p.unpack(k); ! _key = static_cast<u4>(k); } --- 42,46 ---- int k; p.unpack(k); ! _key = static_cast<uint32>(k); } Index: Version.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Source/Version.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Version.cpp 15 Aug 2003 01:17:06 -0000 1.5 --- Version.cpp 15 Aug 2003 06:59:16 -0000 1.6 *************** *** 21,24 **** --- 21,25 ---- #include <SimData/Version.h> + #include <cstdio> #ifndef SIMDATA_VERSION |