diff -ruN MHT_Orig/TRACKING/mht/apqueue.c MHT/TRACKING/mht/apqueue.c --- MHT_Orig/TRACKING/mht/apqueue.c 1995-04-27 09:26:59.000000000 -0500 +++ MHT/TRACKING/mht/apqueue.c 2009-12-04 12:37:28.000000000 -0600 @@ -40,6 +40,8 @@ *********************************************************************/ #include +#include // for memcpy(), memmove() +#include #include "apqueue.h" /*DBG BEGIN */ @@ -127,7 +129,6 @@ ROW_COL_COST *rcc, double parentCost ) { - BGN #ifdef NEVER static VECTOR_OF< double > lowestCostForRow; @@ -221,8 +222,6 @@ void apqSOLUTION::solve( void ) { - BGN - static VECTOR_OF< void * > solutionTag; int solutionSize; int i; @@ -273,8 +272,6 @@ void apqSOLUTION::partition() { - BGN - void *doomedRCCtag; ROW_COL_COST doomedRCC; char rowIsNotEmpty; @@ -306,8 +303,8 @@ break; /* #ifdef TSTBUG */ - if( i >= m_numRCCs ) - THROW_ERR( "ASSIGNMENT_PQUEUE looking for non-existant tag" ) + assert( i < m_numRCCs ); + // THROW_ERR( "ASSIGNMENT_PQUEUE looking for non-existant tag" ) /* #endif*/ #ifdef SDBG @@ -419,8 +416,6 @@ void apqSOLUTION:: getSolutionTags( VECTOR_OF< void * > &solutionTag, int *solutionSize ) { - BGN - int i; solutionTag.resize( m_solutionSize ); @@ -436,25 +431,23 @@ void apqSOLUTION::print() { - BGN - int i, j; ROW_COL_COST *rcc; if( m_cost == UNSOLVABLE ) - cout << "#"; + std::cout << "#"; else - cout << m_cost; + std::cout << m_cost; for( i = 0; i < m_solutionSize; i++ ) { rcc = (ROW_COL_COST *)m_solutionTag[ i ]; if( i < m_baseSolutionSize ) - cout << " [" << rcc->row << "," + std::cout << " [" << rcc->row << "," << rcc->col << "," << rcc->cost << "]"; else - cout << " (" << rcc->row << "," + std::cout << " (" << rcc->row << "," << rcc->col << "," << rcc->cost << ")"; } @@ -465,7 +458,7 @@ if( m_solutionTag[ j ] == m_rcc[ i ].tag ) break; if( j >= m_solutionSize ) - cout << " " << m_rcc[ i ].row << "," + std::cout << " " << m_rcc[ i ].row << "," << m_rcc[ i ].col << "," << m_rcc[ i ].cost << " "; } @@ -482,8 +475,6 @@ int numRows, int numCols ) { - BGN - apqSOLUTION *solution = new apqSOLUTION( problemTag, rcc, numRCCs, @@ -502,8 +493,6 @@ void ASSIGNMENT_PQUEUE::removeProblem( void *problemTag ) { - BGN - PTR_INTO_iDLIST_OF< apqSOLUTION > ptr; LOOP_DLIST( ptr, m_solutionList ) @@ -519,8 +508,6 @@ void *ASSIGNMENT_PQUEUE:: getNextSolution( VECTOR_OF< void * > &solutionTag, int *solutionSize ) { - BGN - void *problemTag; findBestSolution(); @@ -545,8 +532,6 @@ void ASSIGNMENT_PQUEUE::findBestSolution() { - BGN - PTR_INTO_iDLIST_OF< apqSOLUTION > ptr; double estimatedCost; @@ -576,14 +561,13 @@ { estimatedCost = m_bestSolution->getCost(); m_bestSolution->solve(); - /* #ifdef TSTBUG */ - if( m_bestSolution->getCost()- estimatedCost<-0.001 ) - THROW_ERR( "Estimated cost (" << estimatedCost << ")" - " higher than actual (" << - m_bestSolution->getCost() << ")" ); + assert( m_bestSolution->getCost()- estimatedCost >= -0.001 ); + // THROW_ERR( "Estimated cost (" << estimatedCost << ")" + // " higher than actual (" << + // m_bestSolution->getCost() << ")" ); /* #endif */ diff -ruN MHT_Orig/TRACKING/mht/apqueue.h MHT/TRACKING/mht/apqueue.h --- MHT_Orig/TRACKING/mht/apqueue.h 2008-11-24 11:18:56.000000000 -0600 +++ MHT/TRACKING/mht/apqueue.h 2009-12-03 22:38:40.000000000 -0600 @@ -160,6 +160,7 @@ #include "except.h" #include "list.h" #include "assign.h" +#include /*-------------------------------------------------------------------* | Declarations of stuff found in this file. @@ -242,8 +243,7 @@ ~apqSOLUTION() { - BGN - + delete [] m_solutionTag; delete [] m_baseSolutionTag; delete [] m_rcc; @@ -298,7 +298,6 @@ void removeAllProblems() { - BGN m_solutionList.removeAll(); } @@ -312,13 +311,13 @@ double getNextSolutionCost() { - BGN findBestSolution(); #ifdef TSTBUG - if( m_bestSolution == 0 ) - THROW_ERR( "Assignment priority queue is empty" ); + // NOTE: Assertion boolean was negated from original for the if-statement + assert( m_bestSolution != 0 ); + // THROW_ERR("Assignment priority queue is empty") #endif return m_bestSolution->getCost(); diff -ruN MHT_Orig/TRACKING/mht/assign.c MHT/TRACKING/mht/assign.c --- MHT_Orig/TRACKING/mht/assign.c 1995-04-27 09:26:59.000000000 -0500 +++ MHT/TRACKING/mht/assign.c 2009-12-03 23:05:40.000000000 -0600 @@ -223,14 +223,14 @@ void SortAssignmentProblem( ROW_COL_COST *rcc, int numRCCs ) { - BGN + qsort( (void *)rcc, numRCCs, sizeof( *rcc ), compareRCCs ); } static int compareRCCs( const void *addr0, const void *addr1 ) { - BGN + #define rcc0 (*(ROW_COL_COST *)addr0) #define rcc1 (*(ROW_COL_COST *)addr1) @@ -260,7 +260,7 @@ int numRows, int numCols, VECTOR_OF< void * > &tag, int *numTags ) { - BGN + G_numAssignCalls++; G_totalAssignSizes += numRCCs; @@ -291,7 +291,7 @@ static void setupProblem( ROW_COL_COST *rcc, int numRCCs, int numRows, int numCols ) { - BGN + register int row, col; register int i; @@ -406,7 +406,7 @@ static void jumpStartProblem() { - BGN + register int row, col; register int i; @@ -478,7 +478,7 @@ static double solveProblem() { - BGN + #ifdef DEBUG int numIterationsWithoutProgress = 0; @@ -508,10 +508,10 @@ #ifdef DEBUG if( g_numAssignmentsMade == oldNumAssignmentsMade ) { - if( ++numIterationsWithoutProgress >= END_OF_PATIENCE ) - THROW_ERR( "Giving up on Hungarian after " << - numIterationsWithoutProgress << - " iterations without progress" ); + assert( ++numIterationsWithoutProgress < END_OF_PATIENCE ); + // THROW_ERR( "Giving up on Hungarian after " << + // numIterationsWithoutProgress << + // " iterations without progress" ); } else numIterationsWithoutProgress = 0; @@ -541,8 +541,8 @@ return UNSOLVABLE; #ifdef TSTBUG - if( minCost == 0 ) - THROW_ERR( "Big, hairy, Hungarian bug -- minCost == 0" ) + assert( minCost != 0 ); + // THROW_ERR( "Big, hairy, Hungarian bug -- minCost == 0" ) #endif /* construct the new subgraph */ @@ -582,7 +582,7 @@ static int augment() { - BGN + int row, col; int mateForCol; @@ -659,7 +659,7 @@ static double storeSolution( VECTOR_OF< void * > &tag, int *numTags ) { - BGN + ROW_COL_COST *usedRCC; double cost; diff -ruN MHT_Orig/TRACKING/mht/bassign.c MHT/TRACKING/mht/bassign.c --- MHT_Orig/TRACKING/mht/bassign.c 1995-04-27 09:26:59.000000000 -0500 +++ MHT/TRACKING/mht/bassign.c 2009-11-29 13:34:59.000000000 -0600 @@ -83,7 +83,7 @@ int numRows, int numCols, VECTOR_OF< void * > &tag, int *numTags ) { - BGN + if( numRCCs == 0 ) { @@ -102,7 +102,7 @@ static void setupProblem( ROW_COL_COST *rcc, int numRCCs, int numRows, int numCols ) { - BGN + int row, col; int i; @@ -163,7 +163,7 @@ static double solveProblem() { - BGN + int i; @@ -191,14 +191,13 @@ static void search( int level, double costSoFar ) { - BGN + int row, col; int i; if( level <= g_maxRow ) { - TRACE row = level; @@ -227,7 +226,6 @@ } else if( level <= g_maxRow + 1 + g_maxCol ) { - TRACE col = level - g_maxRow - 1; @@ -256,8 +254,6 @@ } else if( costSoFar < g_bestSolutionCost ) { - TRACE - for( i = 0; i < g_solutionSize; i++ ) g_bestSolution[ i ] = g_solution[ i ]; g_bestSolutionSize = g_solutionSize; @@ -267,7 +263,7 @@ static double storeSolution( VECTOR_OF< void * > &tag, int *numTags ) { - BGN + int i; diff -ruN MHT_Orig/TRACKING/mht/except.c MHT/TRACKING/mht/except.c --- MHT_Orig/TRACKING/mht/except.c 2008-11-24 11:22:54.000000000 -0600 +++ MHT/TRACKING/mht/except.c 2009-12-04 12:39:35.000000000 -0600 @@ -43,12 +43,12 @@ *********************************************************************/ #define DECLARE_EXCEPT - +/* #include #include #include #include - +*/ #include "except.h" /*-------------------------------------------------------------------* @@ -60,13 +60,13 @@ int i; for( i = 0; i < numSpaces; i++ ) - cout << " "; + std::cout << " "; } /*-------------------------------------------------------------------* | DumpCore() -- crash the program so that it does a core dump *-------------------------------------------------------------------*/ - +/* void DumpCore() { int dummy; @@ -78,26 +78,26 @@ _exit( -1 ); // just in case "one / zero" didn't cause a // crash for some reason } - +*/ /*-------------------------------------------------------------------* | TraceScope() -- construct string describing the current scope *-------------------------------------------------------------------*/ - +/* void TraceScope( char *buf, int bufSize ) { static char scope_overflow_msg[] = "** TOO MANY SCOPES **\n"; SCOPE_TRACER *scope; - /* loop through scopes on stack */ + // loop through scopes on stack *buf = 0; for( scope = SCOPE_TRACER::M_currentScope; scope; scope = scope->m_prevScope ) { - /* make sure there's enough room left in buf for the description - of this scope */ + // make sure there's enough room left in buf for the description + // of this scope if( bufSize <= strlen( scope->m_file ) + // room for filename 1 + // ... " " 5 + // ... line number @@ -111,16 +111,16 @@ break; } - /* make sure that the line number is not out of range (probably - only happens if it's garbage) */ + // make sure that the line number is not out of range (probably + // only happens if it's garbage) if( scope->m_line < 0 ) scope->m_line = 0; if( scope->m_line > 99999 ) scope->m_line = 99999; - /* use sprintf to build the descriptions, instead of a stream, - since making a stream might compound with an error we've - just detected (such as out of memory) */ + // use sprintf to build the descriptions, instead of a stream, + // since making a stream might compound with an error we've + // just detected (such as out of memory) if( *scope->m_action != 0 ) sprintf( buf, "%s %d: %s\n", scope->m_file, @@ -131,7 +131,7 @@ scope->m_file, scope->m_line ); - /* move pointer on to beginning of record for next scope */ + // move pointer on to beginning of record for next scope while( *buf != 0 ) { buf++; @@ -139,10 +139,11 @@ } } } +*/ /*-------------------------------------------------------------------* | XDoErr() -- print out an error and exit *-------------------------------------------------------------------*/ - +/* void XDoErr( int line, char *file ) { static char scopeStr[ 10000 ]; @@ -166,3 +167,4 @@ fprintf( stderr, "ABORTING EXECUTION\n" ); _exit( -1 ); } +*/ diff -ruN MHT_Orig/TRACKING/mht/except.h MHT/TRACKING/mht/except.h --- MHT_Orig/TRACKING/mht/except.h 2009-12-04 12:29:28.000000000 -0600 +++ MHT/TRACKING/mht/except.h 2009-12-04 12:49:16.000000000 -0600 @@ -234,12 +234,12 @@ #ifndef EXCEPT_H #define EXCEPT_H -#include -#include -#include +//#include +//#include +//#include #include -#include "strstream" -#include +//#include "strstream" +//#include //#include "portspecs.h" #include "safeglobal.h" @@ -250,10 +250,12 @@ #define GLOBAL extern #endif +/* using std::cout; using std::endl; using std::strstream; using std::ostrstream; +*/ /*-------------------------------------------------------------------* | Automatic declaration of TSTBUG *-------------------------------------------------------------------*/ @@ -265,14 +267,14 @@ /*-------------------------------------------------------------------* | Declarations of stuff found in this file. *-------------------------------------------------------------------*/ - +/* class SCOPE_TRACER; class ERR_STREAM; - +*/ /*-------------------------------------------------------------------* | RECURSION_CHECKER -- class used in CANT_RECUR macro *-------------------------------------------------------------------*/ - +/* class RECURSION_CHECKER { private: @@ -300,12 +302,12 @@ m_busyFlag = 0; } }; - +*/ /*-------------------------------------------------------------------* | CANT_RECUR macro -- make sure that a routine is not called | recursively *-------------------------------------------------------------------*/ - +/* #ifdef TSTBUG #define CANT_RECUR \ @@ -317,14 +319,14 @@ #define CANT_RECUR #endif - +*/ /*-------------------------------------------------------------------* | SCOPE_TRACER -- object used in tracing scopes | | This class should only be used explicitly by the BGN, | TRACE, and ACTION macros. *-------------------------------------------------------------------*/ - +/* class SCOPE_TRACER { private: @@ -384,12 +386,12 @@ #ifdef DECLARE_EXCEPT SCOPE_TRACER *SCOPE_TRACER::M_currentScope = 0; #endif - +*/ /*-------------------------------------------------------------------* | BGN, ACTION(), and TRACE -- macros for constructing trace of where | errors occur *-------------------------------------------------------------------*/ - +/* #ifdef TSTBUG #define BGN \ @@ -411,16 +413,16 @@ #define TRACE #endif - +*/ /*-------------------------------------------------------------------* | Global variables used in THROW_ERR() *-------------------------------------------------------------------*/ - +/* GLOBAL char G_errHasHappened; // set to 1 by THROW_ERR() GLOBAL char XG_msg[ 1000 ]; // description of error GLOBAL char XG_msgStreamExists; // flag set when XG_errStream is // initialized - +*/ /*-------------------------------------------------------------------* | ERR_STREAM -- contains an ostrstream for building XG_msg | @@ -430,7 +432,7 @@ | because errors might occur during initialization before the | ostrstream is constructed. *-------------------------------------------------------------------*/ - +/* class ERR_STREAM { private: @@ -466,11 +468,11 @@ }; SAFE_GLOBAL( ERR_STREAM, XG_errStream ) - +*/ /*-------------------------------------------------------------------* | THROW_ERR() -- macro to spit out an error message and exit *-------------------------------------------------------------------*/ - +/* #define THROW_ERR( description ) \ { \ G_errHasHappened = 1; \ @@ -480,14 +482,14 @@ strncpy( XG_msg, #description, sizeof( XG_msg ) ); \ XDoErr( __LINE__, __FILE__ ); \ } \ - +*/ /*-------------------------------------------------------------------* | External routines *-------------------------------------------------------------------*/ GLOBAL void Indent( int numSpaces ); // routine to indent cout -GLOBAL void DumpCore(); // routine to crash with core dump -GLOBAL void XDoErr( int line, char *file ); +//GLOBAL void DumpCore(); // routine to crash with core dump +//GLOBAL void XDoErr( int line, char *file ); #undef GLOBAL #endif diff -ruN MHT_Orig/TRACKING/mht/links.h MHT/TRACKING/mht/links.h --- MHT_Orig/TRACKING/mht/links.h 2008-11-24 10:34:52.000000000 -0600 +++ MHT/TRACKING/mht/links.h 2009-12-03 21:41:27.000000000 -0600 @@ -359,6 +359,7 @@ #include "except.h" #include "list.h" +#include /*-------------------------------------------------------------------* | Declarations of stuff found in this file. @@ -395,7 +396,8 @@ LINK_NODE(): DLISTnode(), m_thatObj( 0 ), m_partner( 0 ) {} LINK_NODE( const LINK_NODE & ) { - THROW_ERR( "Trying to copy a LINK_NODE (don't know how)" ) + assert(false); + //THROW_ERR( "Trying to copy a LINK_NODE (don't know how)" ) } protected: @@ -538,8 +540,6 @@ PTR_INTO_LINKS_TO< TYPE > &operator=( const PTR_INTO_LINKS_TO< TYPE > &ptr ) { - BGN - *(PTR_INTO_LINKSbase *)this = *(const PTR_INTO_LINKSbase *)&ptr; return *this; diff -ruN MHT_Orig/TRACKING/mht/list.c MHT/TRACKING/mht/list.c --- MHT_Orig/TRACKING/mht/list.c 1995-04-27 09:27:00.000000000 -0500 +++ MHT/TRACKING/mht/list.c 2009-12-03 23:05:07.000000000 -0600 @@ -49,7 +49,7 @@ DLISTnode *DLISTnode::XgetHead() const { - BGN + DLISTnode const*node; @@ -58,8 +58,8 @@ for( node = m_prev; node->isNode(); node = node->m_prev ) { #ifdef TSTBUG - if( node == this ) - THROW_ERR( "Dlist has no head" ) + assert( node != this ); + // THROW_ERR( "Dlist has no head" ) #endif } @@ -72,7 +72,7 @@ DLISTnode *DLISTnode::XgetTail() const { - BGN + DLISTnode const*node; @@ -81,8 +81,8 @@ for( node = m_prev; node->isNode(); node = node->m_prev ) { #ifdef TSTBUG - if( node == this ) - THROW_ERR( "Dlist has no tail" ) + assert( node != this ); + // THROW_ERR( "Dlist has no tail" ) #endif } @@ -99,13 +99,13 @@ void DLISTnode::check() const { - BGN + DLISTnode const*node; int listHasHeader; - if( m_prev == 0 || m_next == 0 ) - THROW_ERR( "Bad dlist node -- NULL link" ); + assert( m_prev != 0 && m_next != 0 ); + // THROW_ERR( "Bad dlist node -- NULL link" ); if( ! isOnList() ) return; @@ -114,14 +114,14 @@ node = this; do { - if( node->m_prev->m_next != node || - node->m_next->m_prev != node ) - THROW_ERR( "Bad dlist node -- links don't match" ) + assert( node->m_prev->m_next == node && + node->m_next->m_prev == node ); + // THROW_ERR( "Bad dlist node -- links don't match" ) if( ! node->isNode() ) { - if( listHasHeader ) - THROW_ERR( "More than one header on dlist" ) + assert( ! listHasHeader ); + // THROW_ERR( "More than one header on dlist" ) listHasHeader = 1; } @@ -129,8 +129,8 @@ } while( node != this ); - if( ! listHasHeader ) - THROW_ERR( "Dlist without header" ) + assert( listHasHeader ); + // THROW_ERR( "Dlist without header" ) } #endif @@ -142,7 +142,7 @@ void DLISTbase::XprependCopy( const DLISTbase &dlist ) { - BGN + DLISTnode const*node; @@ -157,7 +157,7 @@ void DLISTbase::XappendCopy( const DLISTbase &dlist ) { - BGN + DLISTnode const*node; @@ -173,7 +173,7 @@ void DLISTbase::Xsplice( DLISTbase &dlist ) { - BGN + if( dlist.isEmpty() ) return; @@ -213,7 +213,7 @@ int DLISTbase::getLength() const { - BGN + DLISTnode const*node; int length; @@ -231,7 +231,7 @@ void DLISTbase::removeAll() { - BGN + while( ! isEmpty() ) removeHead(); diff -ruN MHT_Orig/TRACKING/mht/list.h MHT/TRACKING/mht/list.h --- MHT_Orig/TRACKING/mht/list.h 2008-11-24 10:42:18.000000000 -0600 +++ MHT/TRACKING/mht/list.h 2009-12-03 22:37:07.000000000 -0600 @@ -581,6 +581,7 @@ #define LIST_H #include "except.h" +#include /*-------------------------------------------------------------------* | Declarations of stuff found in this file. @@ -640,8 +641,6 @@ void Xprepend( DLISTnode *node ) { - BGN - node->checkIsNode(); node->checkNotOnList(); @@ -654,8 +653,6 @@ void Xappend( DLISTnode *node ) { - BGN - node->checkNotOnList(); node->m_prev = this; @@ -667,8 +664,6 @@ void unlink() { - BGN - m_prev->m_next = m_next; m_next->m_prev = m_prev; @@ -699,34 +694,33 @@ #elif defined( TSTBUG ) void check() const { - if( m_prev->m_next != this || m_next->m_prev != this ) - THROW_ERR( "Corrupted DLIST" ) + assert( m_prev->m_next == this && m_next->m_prev == this ); + // THROW_ERR( "Corrupted DLIST" ); } #else void check() const {} #endif #ifdef TSTBUG - + // NOTE: The boolean statements for the assertions have been negated from their original in their if-statements void checkOnList() const - { if( ! isOnList() ) THROW_ERR( "Node must be on dlist" ); } + { assert( isOnList() );}// THROW_ERR( "Node must be on dlist" ); } void checkNotOnList() const - { if( isOnList() ) THROW_ERR( "Node mustn't be on dlist" ); } + { assert( ! isOnList() );}// THROW_ERR( "Node mustn't be on dlist" ); } void checkIsNode() const - { if( ! isNode() ) THROW_ERR( "Must be a real node" ); } + { assert( isNode() );}// THROW_ERR( "Must be a real node" ); } void checkIsNotNode() const - { if( isNode() ) THROW_ERR( "Mustn't be a node" ); } + { assert( ! isNode() );}// THROW_ERR( "Mustn't be a node" ); } void checkIsHead() const - { if( ! isHead() ) THROW_ERR( "Previous must be node" ); } + { assert( isHead() );}// THROW_ERR( "Previous must be node" ); } void checkIsNotHead() const - { if( isHead() ) THROW_ERR( "Previous mustn't be node" ); } + { assert( ! isHead() );}// THROW_ERR( "Previous mustn't be node" ); } void checkIsTail() const - { if( ! isTail() ) THROW_ERR( "Next must be node" ); } + { assert( isTail() );}// THROW_ERR( "Next must be node" ); } void checkIsNotTail() const - { if( isTail() ) THROW_ERR( "Next mustn't be node" ); } + { assert( ! isTail() );}// THROW_ERR( "Next mustn't be node" ); } #else - void checkOnList() const {} void checkNotOnList() const {} void checkIsNode() const {} @@ -735,7 +729,6 @@ void checkIsNotHead() const {} void checkIsTail() const {} void checkIsNotTail() const {} - #endif }; @@ -768,7 +761,7 @@ protected: virtual DLISTnode *XmakeCopy() const - { BGN return new dummyDLISTnode( *this ); } + {return new dummyDLISTnode( *this ); } public: @@ -787,21 +780,21 @@ #define MEMBERS_FOR_DLISTnode( TYPE ) \ TYPE *getPrev() const \ - { BGN checkIsHead(); return (TYPE *)XgetPrev(); } \ + {checkIsHead(); return (TYPE *)XgetPrev(); } \ TYPE *getNext() const \ - { BGN checkIsTail(); return (TYPE *)XgetNext(); } \ + {checkIsTail(); return (TYPE *)XgetNext(); } \ TYPE *getHead() const \ - { BGN checkOnList(); return (TYPE *)XgetHead(); } \ + {checkOnList(); return (TYPE *)XgetHead(); } \ TYPE *getTail() const \ - { BGN checkOnList(); return (TYPE *)XgetTail(); } \ + {checkOnList(); return (TYPE *)XgetTail(); } \ void prepend( TYPE *node ) \ - { BGN checkOnList(); Xprepend( node ); } \ + {checkOnList(); Xprepend( node ); } \ void append( TYPE *node ) \ - { BGN checkOnList(); Xappend( node ); } \ + {checkOnList(); Xappend( node ); } \ TYPE *makeCopy() const \ - { BGN return (TYPE *)XmakeCopy(); } \ + {return (TYPE *)XmakeCopy(); } \ virtual DLISTnode *XmakeCopy() const \ - { BGN return new TYPE( *this ); } \ + {return new TYPE( *this ); } \ /*-------------------------------------------------------------------* | DLISTbase -- base class for all doubly-linked lists @@ -820,7 +813,7 @@ DLISTbase(): m_vnode() {} DLISTbase( const DLISTbase &dlist ): m_vnode() - { BGN XappendCopy( dlist ); } + {XappendCopy( dlist ); } virtual ~DLISTbase() { removeAll(); } @@ -853,21 +846,22 @@ void check() const { m_vnode.check(); } #ifdef TSTBUG + // NOTE: Booleans for assertions have been negated from their originals for the if-statements void checkEmpty() const - { if( ! isEmpty() ) THROW_ERR( "Dlist must be empty" ) } + { assert( isEmpty() );}// THROW_ERR( "Dlist must be empty" ); } void checkNotEmpty() const - { if( isEmpty() ) THROW_ERR( "Dlist mustn't be empty" ) } + { assert( ! isEmpty() );}// THROW_ERR( "Dlist mustn't be empty" ); } void checkHasOneMember() const { - if( ! hasOneMember() ) - THROW_ERR( "Dlist must have one and only one member" ) + assert( hasOneMember() ); + //THROW_ERR( "Dlist must have one and only one member" ); } void checkNotHasOneMember() const { - if( hasOneMember() ) - THROW_ERR( "Dlist mustn't have one and only one member" ) + assert( ! hasOneMember() ); + // THROW_ERR( "Dlist mustn't have one and only one member" ); } #else @@ -893,13 +887,13 @@ DLISTtmplt( const DLISTtmplt< TYPE > &dlist ): \ DLISTbase( dlist ) {} \ void prependCopy( const DLISTtmplt< TYPE > &dlist ) \ - { BGN XprependCopy( dlist ); } \ + {XprependCopy( dlist ); } \ void appendCopy( const DLISTtmplt< TYPE > &dlist ) \ - { BGN XappendCopy( dlist ); } \ + {XappendCopy( dlist ); } \ void splice( DLISTtmplt< TYPE > &dlist ) \ - { BGN Xsplice( dlist ); } \ + {Xsplice( dlist ); } \ DLISTtmplt< TYPE > &operator=( const DLISTtmplt< TYPE > &dlist ) \ - { BGN removeAll(); XappendCopy( dlist ); return *this; } \ + {removeAll(); XappendCopy( dlist ); return *this; } \ /*-------------------------------------------------------------------* | PTR_INTO_DLISTbase -- base class for all PTR_INTO_xDLIST's @@ -945,7 +939,6 @@ m_dummy(), m_ptr( ptr.m_ptr ) { - BGN ptr.checkNotRemoved(); } @@ -979,14 +972,13 @@ int isEqualTo( const PTR_INTO_DLISTbase &ptr ) const { return m_ptr == ptr.m_ptr; } - void gotoPrev() { BGN m_ptr = m_ptr->XgetPrev(); } - void gotoNext() { BGN m_ptr = m_ptr->XgetNext(); } - void gotoHead() { BGN m_ptr = m_ptr->XgetHead(); } - void gotoTail() { BGN m_ptr = m_ptr->XgetTail(); } + void gotoPrev() {m_ptr = m_ptr->XgetPrev(); } + void gotoNext() {m_ptr = m_ptr->XgetNext(); } + void gotoHead() {m_ptr = m_ptr->XgetHead(); } + void gotoTail() {m_ptr = m_ptr->XgetTail(); } void remove() { - BGN checkValid(); @@ -996,70 +988,69 @@ } #ifdef TSTBUG - + // NOTE: Assertion booleans have been negated from their original if-statements. void checkInitialized() const { - if( ! isInitialized() ) - THROW_ERR( "Pointer into dlist must be initialized" ) + assert( isInitialized() ); + // THROW_ERR( "Pointer into dlist must be initialized" ); } void checkNotInitialized() const { - if( isInitialized() ) - THROW_ERR( "Pointer into dlist mustn't be initialized" ) + assert( ! isInitialized() ); + // THROW_ERR( "Pointer into dlist mustn't be initialized" ); } void checkValid() const { - if( ! isValid() ) - THROW_ERR( "Pointer into dlist must be valid" ) + assert( isValid() ); + // THROW_ERR( "Pointer into dlist must be valid" ); } void checkNotValid() const { - if( isValid() ) - THROW_ERR( "Pointer into dlist must not be valid" ) + assert( ! isValid() ); + // THROW_ERR( "Pointer into dlist must not be valid" ); } void checkRemoved() const { - if( ! isRemoved() ) - THROW_ERR( "Pointer into dlist must point to removed node" ) + assert( isRemoved() ); + // THROW_ERR( "Pointer into dlist must point to removed node" ); } void checkNotRemoved() const { - if( isRemoved() ) - THROW_ERR( "Pointer into dlist " - "mustn't point to removed node" ) + assert( ! isRemoved() ); + // THROW_ERR( "Pointer into dlist " + // "mustn't point to removed node" ); } void checkAtHead() const { - if( ! isAtHead() ) - THROW_ERR( "Pointer into dlist must be at head" ) + assert( isAtHead() ); + // THROW_ERR( "Pointer into dlist must be at head" ); } void checkNotAtHead() const - { - if( ! isAtHead() ) - THROW_ERR( "Pointer into dlist mustn't be at head" ) + { // Odd... this was originally identical to checkAtHead()... + assert( ! isAtHead() ); + // THROW_ERR( "Pointer into dlist mustn't be at head" ); } void checkAtTail() const { - if( ! isAtTail() ) - THROW_ERR( "Pointer into dlist must be at tail" ) + assert( isAtTail() ); + // THROW_ERR( "Pointer into dlist must be at tail" ); } void checkNotAtTail() const - { - if( ! isAtTail() ) - THROW_ERR( "Pointer into dlist mustn't be at tail" ) + { // Odd... this was originally identical to checkNotAtTail() + assert( ! isAtTail() ); + // THROW_ERR( "Pointer into dlist mustn't be at tail" ); } #else - void checkInitialized() const {} void checkNotInitialized() const {} void checkValid() const {} @@ -1070,7 +1061,6 @@ void checkNotAtHead() const {} void checkAtTail() const {} void checkNotAtTail() const {} - #endif }; @@ -1096,25 +1086,25 @@ PTRtmplt( const PTRtmplt< TYPE > &ptr ): \ PTR_INTO_DLISTbase( ptr ) {} \ void set( DLISTtmplt< TYPE > &dlist ) \ - { BGN Xset( dlist ); } \ + {Xset( dlist ); } \ void set( DLISTtmplt< TYPE > &dlist, START_AT_HEADversion ) \ - { BGN Xset( dlist, START_AT_HEAD ); } \ + {Xset( dlist, START_AT_HEAD ); } \ void set( DLISTtmplt< TYPE > &dlist, START_AT_TAILversion ) \ - { BGN Xset( dlist, START_AT_TAIL ); } \ + {Xset( dlist, START_AT_TAIL ); } \ void set( const PTRtmplt< TYPE > &ptr ) \ - { BGN ptr.checkNotRemoved(); Xset( ptr ); } \ + {ptr.checkNotRemoved(); Xset( ptr ); } \ PTRtmplt< TYPE > &operator=( DLISTtmplt< TYPE > &dlist ) \ - { BGN set( dlist ); return *this; } \ + {set( dlist ); return *this; } \ PTRtmplt< TYPE > &operator=( const PTRtmplt< TYPE > &ptr ) \ - { BGN set( ptr ); return *this; } \ + {set( ptr ); return *this; } \ PTRtmplt< TYPE > &operator++() \ - { BGN gotoNext(); return *this; } \ + {gotoNext(); return *this; } \ PTRtmplt< TYPE > &operator--() \ - { BGN gotoPrev(); return *this; } \ + {gotoPrev(); return *this; } \ int operator==( const PTRtmplt< TYPE > ptr ) const \ - { BGN return isEqualTo( ptr ); } \ + {return isEqualTo( ptr ); } \ int operator!=( const PTRtmplt< TYPE > ptr ) const \ - { BGN return ! isEqualTo( ptr ); } \ + {return ! isEqualTo( ptr ); } \ /*-------------------------------------------------------------------* | Templates for store-by-value doubly-linked lists @@ -1152,26 +1142,22 @@ TYPE *getHead() const { - BGN - checkNotEmpty(); return &((vDLIST_NODE_OF< TYPE > *)XgetHead())->m_info; } TYPE *getTail() const { - BGN - checkNotEmpty(); return &((vDLIST_NODE_OF< TYPE > *)XgetTail())->m_info; } void prepend( const TYPE &node ) - { BGN Xprepend( new vDLIST_NODE_OF< TYPE >( node ) ); } + {Xprepend( new vDLIST_NODE_OF< TYPE >( node ) ); } void append( const TYPE &node ) - { BGN Xappend( new vDLIST_NODE_OF< TYPE >( node ) ); } + {Xappend( new vDLIST_NODE_OF< TYPE >( node ) ); } TYPE &operator*() const - { BGN return *getHead(); } + {return *getHead(); } }; template< class TYPE > @@ -1185,32 +1171,24 @@ TYPE *get() const { - BGN - checkValid(); return &((vDLIST_NODE_OF< TYPE > *)Xget())->m_info; } void prepend( const TYPE &node ) { - BGN - checkNotRemoved(); Xprepend( new vDLIST_NODE_OF< TYPE >( node ) ); } void append( const TYPE &node ) { - BGN - checkNotRemoved(); Xappend( new vDLIST_NODE_OF< TYPE >( node ) ); } TYPE &operator*() const { - BGN - return *get(); } }; @@ -1251,26 +1229,22 @@ TYPE *getHead() const { - BGN - checkNotEmpty(); return ((ptrDLIST_NODE_OF< TYPE > *)XgetHead())->m_info; } TYPE *getTail() const { - BGN - checkNotEmpty(); return ((ptrDLIST_NODE_OF< TYPE > *)XgetTail())->m_info; } void prepend( TYPE &node ) - { BGN Xprepend( new ptrDLIST_NODE_OF< TYPE >( node ) ); } + {Xprepend( new ptrDLIST_NODE_OF< TYPE >( node ) ); } void append( TYPE &node ) - { BGN Xappend( new ptrDLIST_NODE_OF< TYPE >( node ) ); } + {Xappend( new ptrDLIST_NODE_OF< TYPE >( node ) ); } TYPE &operator*() const - { BGN return *getHead(); } + {return *getHead(); } }; template< class TYPE > @@ -1284,32 +1258,24 @@ TYPE *get() const { - BGN - checkValid(); return ((ptrDLIST_NODE_OF< TYPE > *)Xget())->m_info; } void prepend( TYPE &node ) { - BGN - checkNotRemoved(); Xprepend( new ptrDLIST_NODE_OF< TYPE >( node ) ); } void append( TYPE &node ) { - BGN - checkNotRemoved(); Xappend( new ptrDLIST_NODE_OF< TYPE >( node ) ); } TYPE &operator*() const { - BGN - return *get(); } }; @@ -1326,15 +1292,15 @@ MEMBERS_FOR_DLISTbase( iDLIST_OF, TYPE ) TYPE *getHead() const - { BGN checkNotEmpty(); return (TYPE *)XgetHead(); } + {checkNotEmpty(); return (TYPE *)XgetHead(); } TYPE *getTail() const - { BGN checkNotEmpty(); return (TYPE *)XgetTail(); } + {checkNotEmpty(); return (TYPE *)XgetTail(); } void prepend( TYPE *node ) - { BGN Xprepend( node ); } + {Xprepend( node ); } void append( TYPE *node ) - { BGN Xappend( node ); } + {Xappend( node ); } TYPE &operator*() const - { BGN return *getHead(); } + {return *getHead(); } }; template< class TYPE > @@ -1349,27 +1315,25 @@ PTR_INTO_iDLIST_OF( TYPE *node ): PTR_INTO_DLISTbase( node ) { - BGN - node->checkOnList(); } operator TYPE*() { return get(); } TYPE *get() const - { BGN checkValid(); return (TYPE *)Xget(); } + {checkValid(); return (TYPE *)Xget(); } void set( TYPE *ptr ) - { BGN Xset( ptr ); } + {Xset( ptr ); } void prepend( TYPE *node ) - { BGN checkNotRemoved(); Xprepend( node ); } + {checkNotRemoved(); Xprepend( node ); } void append( TYPE *node ) - { BGN checkNotRemoved(); Xappend( node ); } + {checkNotRemoved(); Xappend( node ); } TYPE &operator*() const - { BGN return *get(); } + {return *get(); } int operator==( const TYPE *ptr ) const - { BGN return isEqualTo( ptr ); } + {return isEqualTo( ptr ); } int operator!=( const TYPE *ptr ) const - { BGN return ! isEqualTo( ptr ); } + {return ! isEqualTo( ptr ); } }; /*-------------------------------------------------------------------* diff -ruN MHT_Orig/TRACKING/mht/makefile MHT/TRACKING/mht/makefile --- MHT_Orig/TRACKING/mht/makefile 2008-11-25 04:30:45.000000000 -0600 +++ MHT/TRACKING/mht/makefile 2009-12-04 13:19:22.000000000 -0600 @@ -22,18 +22,14 @@ build = $(C++) $(C++FLAGS) -o $@ touch = touch $@ -libmht.a: libmht.a(apqueue.o) libmht.a(assign.o) \ - libmht.a(except.o) \ - libmht.a(links.o) libmht.a(list.o) \ - libmht.a(matrix.o) libmht.a(mem.o) libmht.a(mdlmht.o) \ - libmht.a(mht.o) libmht.a(mht_group.o) \ - libmht.a(mht_report.o) libmht.a(mht_track.o) \ - libmht.a(tree.o) - $(C++) $(C++FLAGS) -c $(?:.o=.c) +libmht.a: apqueue.o assign.o \ + except.o \ + links.o list.o \ + matrix.o mdlmht.o \ + mht.o mht_group.o \ + mht_report.o mht_track.o tree.o $(AR) $(ARFLAGS) libmht.a $? - rm $? @echo lib is now up-to-date -.c.a:; apqueue_test: apqueue_test.o libmht.a $(build) apqueue_test.o -L. -lmht -lm @@ -41,58 +37,59 @@ assign_test: assign_test.o bassign.o libmht.a $(build) assign_test.o bassign.o -L. -lmht -lm -mdlmht.o: mdlmht.h mht.h except.h safeglobal.h list.h tree.h links.h vector.h + +mdlmht.o: mdlmht.h mht.h except.h safeglobal.h list.h tree.h links.h vector.h mdlmht.c $(C++) -c $(C++FLAGS) mdlmht.c -mht.o: mht.h safeglobal.h list.h tree.h links.h vector.h except.h +mht.o: mht.h safeglobal.h list.h tree.h links.h vector.h except.h mht.c $(C++) -c $(C++FLAGS) mht.c mht_group.o: mht.h pqueue.h apqueue.h safeglobal.h list.h tree.h \ - links.h vector.h assign.h except.h + links.h vector.h assign.h except.h mht_group.c $(C++) -c $(C++FLAGS) mht_group.c mht_report.o: mht.h pqueue.h apqueue.h safeglobal.h list.h tree.h \ - links.h vector.h assign.h except.h + links.h vector.h assign.h except.h mht_report.c $(C++) -c $(C++FLAGS) mht_report.c -mht_track.o: mht.h safeglobal.h list.h tree.h links.h vector.h except.h +mht_track.o: mht.h safeglobal.h list.h tree.h links.h vector.h except.h mht_track.c $(C++) -c $(C++FLAGS) mht_track.c -apqueue_test.o: apqueue.h mem.h except.h +apqueue_test.o: apqueue.h except.h apqueue_test.c $(C++) -c $(C++FLAGS) apqueue_test.c -apqueue.o: apqueue.h except.h safeglobal.h list.h assign.h vector.h +apqueue.o: apqueue.h except.h safeglobal.h list.h assign.h vector.h apqueue.c $(C++) -c $(C++FLAGS) apqueue.c -assign_test.o: bassign.h mem.h except.h +assign_test.o: bassign.h except.h assign_test.c $(C++) -c $(C++FLAGS) assign_test.c -assign.o: assign.h queue.h except.h vector.h +assign.o: assign.h queue.h except.h vector.h assign.c $(C++) -c $(C++FLAGS) assign.c -bassign.o: bassign.h safeglobal.h vector.h assign.h except.h +bassign.o: bassign.h safeglobal.h vector.h assign.h except.h bassign.c $(C++) -c $(C++FLAGS) bassign.c -links.o: links.h safeglobal.h list.h except.h +links.o: links.h safeglobal.h list.h except.h links.c $(C++) -c $(C++FLAGS) links.c -tree.o: tree.h except.h safeglobal.h list.h +tree.o: tree.h except.h safeglobal.h list.h tree.c $(C++) -c $(C++FLAGS) tree.c -list.o: list.h except.h safeglobal.h +list.o: list.h except.h safeglobal.h list.c $(C++) -c $(C++FLAGS) list.c -matrix.o: matrix.h vector.h safeglobal.h except.h +matrix.o: matrix.h vector.h safeglobal.h except.h matrix.c $(C++) -c $(C++FLAGS) matrix.c -pqueue.o: pqueue.h except.h safeglobal.h +pqueue.o: pqueue.h except.h safeglobal.h pqueue.c $(C++) -c $(C++FLAGS) pqueue.c -mem.o: mem.h except.h safeglobal.h - $(C++) -c $(C++FLAGS) mem.c +#mem.o: mem.h except.h safeglobal.h mem.c +# $(C++) -c $(C++FLAGS) mem.c -except.o: except.h safeglobal.h +except.o: except.h safeglobal.h except.c $(C++) -c $(C++FLAGS) except.c -normrand.o: normrand.h +normrand.o: normrand.h normrand.c $(C++) -c $(C++FLAGS) normrand.c diff -ruN MHT_Orig/TRACKING/mht/matrix.c MHT/TRACKING/mht/matrix.c --- MHT_Orig/TRACKING/mht/matrix.c 2008-11-24 11:25:10.000000000 -0600 +++ MHT/TRACKING/mht/matrix.c 2009-12-04 13:20:23.000000000 -0600 @@ -43,6 +43,7 @@ #include #include +#include #include "vector.h" #include "matrix.h" @@ -67,7 +68,7 @@ MATRIX &MATRIX::operator=( double val ) { - BGN + int i; double *p = m_data; @@ -93,7 +94,7 @@ void MATRIX::vset( double firstVal, va_list ap ) { - BGN + int i; double *p = m_data; @@ -111,7 +112,7 @@ int MATRIX::isIdentity() const { - BGN + int row, col; double *p = m_data; @@ -136,7 +137,7 @@ tmpMATRIX MATRIX::trans() { - BGN + tmpMATRIX tmp( m_numCols, m_numRows ); int row, col; @@ -166,14 +167,14 @@ tmpMATRIX MATRIX::reduce( int numRows, int numCols ) { - BGN + #ifdef TSTBUG - if( numRows > m_numRows || numCols > m_numCols ) - THROW_ERR( "Can't reduce " - << m_numRows << "x" << m_numCols << " matrix " - << "to" - << numRows << "x" << numCols ) + assert( numRows <= m_numRows && numCols <= m_numCols ); + // THROW_ERR( "Can't reduce " + // << m_numRows << "x" << m_numCols << " matrix " + // << "to" + // << numRows << "x" << numCols ) #endif tmpMATRIX tmp( numRows, numCols ); @@ -205,7 +206,7 @@ tmpMATRIX MATRIX::inv() { - BGN + static VECTOR_OF< int > originalRow; originalRow.resize( m_numRows ); static VECTOR_OF< double > colBuf; colBuf.resize( m_numRows ); @@ -246,13 +247,13 @@ double MATRIX::det() { - BGN + #ifdef TSTBUG - if( m_numRows != m_numCols ) - THROW_ERR( "Can't find determinant of " - << m_numRows << "x" << m_numCols << " matrix -- " - << "must be square" ) + assert( m_numRows == m_numCols ); + // THROW_ERR( "Can't find determinant of " + // << m_numRows << "x" << m_numCols << " matrix -- " + // << "must be square" ) #endif MATRIX lu( *this ); @@ -281,7 +282,7 @@ void MATRIX::print( int numSpaces ) const { - BGN + int row, col; double *p = m_data; @@ -295,10 +296,10 @@ for( col = 0; col < m_numCols; col++ ) { - cout << DBL( *p ) << " "; + std::cout << DBL( *p ) << " "; p++; } - cout << endl; + std::cout << std::endl; } #undef DBL @@ -313,15 +314,15 @@ tmpMATRIX::tmpMATRIX( const MATRIX &m0, const MATRIX &m1 ): MATRIX( m0.getNumRows(), m1.getNumCols() ) { - BGN + #ifdef TSTBUG - if( m1.getNumRows() != m0.getNumCols() ) - THROW_ERR( "Bad multiply -- " - << m0.getNumRows() << "x" << m0.getNumCols() - << " matrix * " - << m1.getNumRows() << "x" << m1.getNumRows() - << " matrix" ) + assert( m1.getNumRows() == m0.getNumCols() ); + // THROW_ERR( "Bad multiply -- " + // << m0.getNumRows() << "x" << m0.getNumCols() + // << " matrix * " + // << m1.getNumRows() << "x" << m1.getNumRows() + // << " matrix" ) #endif const int num_m0Cols_m1Rows = // both the number of rows in m1 @@ -362,16 +363,16 @@ tmpMATRIX &tmpMATRIX::add( const MATRIX &src ) { - BGN + #ifdef TSTBUG - if( m_numRows != src.getNumRows() || - m_numCols != src.getNumCols() ) - THROW_ERR( "Bad add -- " - << m_numRows << "x" << m_numCols - << " matrix + " - << src.getNumRows() << "x" << src.getNumRows() - << " matrix" ) + assert( m_numRows == src.getNumRows() && + m_numCols == src.getNumCols() ); + // THROW_ERR( "Bad add -- " + // << m_numRows << "x" << m_numCols + // << " matrix + " + // << src.getNumRows() << "x" << src.getNumRows() + // << " matrix" ) #endif int i; @@ -391,16 +392,16 @@ tmpMATRIX &tmpMATRIX::subtract( const MATRIX &src ) { - BGN + #ifdef TSTBUG - if( m_numRows != src.getNumRows() || - m_numCols != src.getNumCols() ) - THROW_ERR( "Bad subtract -- " - << m_numRows << "x" << m_numCols - << " matrix - " - << src.getNumRows() << "x" << src.getNumRows() - << " matrix" ) + assert( m_numRows == src.getNumRows() && + m_numCols == src.getNumCols() ); + // THROW_ERR( "Bad subtract -- " + // << m_numRows << "x" << m_numCols + // << " matrix - " + // << src.getNumRows() << "x" << src.getNumRows() + // << " matrix" ) #endif int i; @@ -420,16 +421,16 @@ tmpMATRIX &tmpMATRIX::subtractFrom( const MATRIX &src ) { - BGN + #ifdef TSTBUG - if( m_numRows != src.getNumRows() || - m_numCols != src.getNumCols() ) - THROW_ERR( "Bad subtract -- " - << m_numRows << "x" << m_numCols - << " matrix - " - << src.getNumRows() << "x" << src.getNumRows() - << " matrix" ) + assert( m_numRows == src.getNumRows() && + m_numCols == src.getNumCols() ); + // THROW_ERR( "Bad subtract -- " + // << m_numRows << "x" << m_numCols + // << " matrix - " + // << src.getNumRows() << "x" << src.getNumRows() + // << " matrix" ) #endif int i; @@ -453,7 +454,7 @@ tmpMATRIX &tmpMATRIX::multiply( double src ) { - BGN + int i; double *p = m_data; @@ -508,7 +509,7 @@ static void luSolve( const MATRIX &lu, int *originalRow, double *colBuf ) { - BGN + int firstNonZeroRow = -1; double sum = -1; @@ -619,7 +620,7 @@ static int luDecompose( MATRIX &mat, int *originalRow ) { - BGN + int numSwapsIsOdd = 0; int row, col; @@ -645,8 +646,8 @@ biggest = tmpDbl; #ifdef TSTBUG - if( biggest == 0 ) - THROW_ERR( "Trying to LU-decompose singular matrix" ); + assert( biggest != 0 ); + // THROW_ERR( "Trying to LU-decompose singular matrix" ); #endif scaler[ row ] = 1. / biggest; diff -ruN MHT_Orig/TRACKING/mht/matrix.h MHT/TRACKING/mht/matrix.h --- MHT_Orig/TRACKING/mht/matrix.h 2008-11-24 11:09:16.000000000 -0600 +++ MHT/TRACKING/mht/matrix.h 2009-12-04 13:24:11.000000000 -0600 @@ -193,6 +193,7 @@ #include #include "except.h" +#include /*-------------------------------------------------------------------* | Declarations of stuff found in this file @@ -240,8 +241,6 @@ m_size( src.m_size ), m_data( new double[ src.m_numRows * src.m_numCols ] ) { - BGN - memcpy( m_data, src.m_data, m_size * sizeof( *m_data ) ); } @@ -249,8 +248,6 @@ virtual ~MATRIX() { - BGN - if( m_data != 0 ) delete [] m_data; m_data = 0; @@ -260,14 +257,12 @@ MATRIX &operator=( const MATRIX &src ) { - BGN - #ifdef TSTBUG - if( m_numRows != src.m_numRows || m_numCols != src.m_numCols ) - THROW_ERR( "Bad assignment -- " - << m_numRows << "x" << m_numCols << " matrix = " - << src.m_numRows << "x" << src.m_numCols - << " matrix" ) + assert( m_numRows == src.m_numRows && m_numCols == src.m_numCols ); + //THROW_ERR( "Bad assignment -- " + //<< m_numRows << "x" << m_numCols << " matrix = " + //<< src.m_numRows << "x" << src.m_numCols + //<< " matrix" ) #endif memcpy( m_data, src.m_data, m_size * sizeof( *m_data ) ); @@ -278,14 +273,12 @@ double &operator()( int row = 0, int col = 0 ) const { - BGN - #ifdef TSTBUG - if( 0 > row || row >= m_numRows || - 0 > col || col >= m_numCols ) - THROW_ERR( "Matrix index <" << row << "," << col << ">" - << " out of bounds in " - << m_numRows << "x" << m_numCols << " matrix" ) + assert( 0 <= row && row < m_numRows && + 0 <= col && col < m_numCols ); + //THROW_ERR( "Matrix index out of bounds. -- <" << row << "," << col << ">" + //<< " out of bounds in " + //<< m_numRows << "x" << m_numCols << " matrix" ) #endif return m_data[ row * m_numCols + col ]; @@ -338,13 +331,11 @@ double *stealData() const /* not really const */ { - BGN - double *data; #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to steal nonexistant tmpMATRIX data" ) + assert( m_data != 0 ); + // THROW_ERR( "Trying to steal nonexistant tmpMATRIX data" ) #endif data = m_data; @@ -357,14 +348,12 @@ double &operator()( int row = 0, int col = 0 ) const { - BGN - #ifdef TSTBUG - if( 0 > row || row >= m_numRows || - 0 > col || col >= m_numCols ) - THROW_ERR( "Matrix index <" << row << "," << col << ">" - << " out of bounds in " - << m_numRows << "x" << m_numCols << " matrix" ) + assert( 0 <= row && row < m_numRows && + 0 <= col && col < m_numCols ); + //THROW_ERR( "Matrix index out of bounds -- <" // << row << "," << col << ">" + //<< " out of bounds in " + //<< m_numRows << "x" << m_numCols << " matrix" ) #endif return m_data[ row * m_numCols + col ]; @@ -414,14 +403,12 @@ inline MATRIX &MATRIX::operator=( const tmpMATRIX &src ) { - BGN - #ifdef TSTBUG - if( m_numRows != src.m_numRows || m_numCols != src.m_numCols ) - THROW_ERR( "Bad assignment -- " - << m_numRows << "x" << m_numCols << " matrix = " - << src.m_numRows << "x" << src.m_numCols - << " matrix" ) + assert( m_numRows == src.m_numRows && m_numCols == src.m_numCols ); + //THROW_ERR( "Bad assignment -- " + //<< m_numRows << "x" << m_numCols << " matrix = " + //<< src.m_numRows << "x" << src.m_numCols + //<< " matrix" ) #endif delete [] m_data; @@ -437,8 +424,6 @@ inline tmpMATRIX operator+( const MATRIX &m0, const MATRIX &m1 ) { - BGN - tmpMATRIX tmp( m0 ); tmp.add( m1 ); return tmp; @@ -447,8 +432,6 @@ inline tmpMATRIX operator+( const MATRIX &m0, const tmpMATRIX &m1 ) { - BGN - tmpMATRIX tmp( m1 ); tmp.add( m0 ); return tmp; @@ -461,8 +444,6 @@ inline tmpMATRIX operator-( const MATRIX &m0, const MATRIX &m1 ) { - BGN - tmpMATRIX tmp( m0 ); tmp.subtract( m1 ); return tmp; @@ -471,8 +452,6 @@ inline tmpMATRIX operator-( const MATRIX &m0, const tmpMATRIX &m1 ) { - BGN - tmpMATRIX tmp( m1 ); tmp.subtractFrom( m0 ); return tmp; @@ -485,8 +464,6 @@ inline tmpMATRIX operator*( const MATRIX &m0, const MATRIX &m1 ) { - BGN - tmpMATRIX tmp( m0, m1 ); return tmp; } @@ -494,8 +471,6 @@ inline tmpMATRIX operator*( const MATRIX &m, double num ) { - BGN - tmpMATRIX tmp( m ); tmp.multiply( num ); return tmp; diff -ruN MHT_Orig/TRACKING/mht/mdlmht.c MHT/TRACKING/mht/mdlmht.c --- MHT_Orig/TRACKING/mht/mdlmht.c 1995-04-27 09:27:00.000000000 -0500 +++ MHT/TRACKING/mht/mdlmht.c 2009-11-29 13:30:45.000000000 -0600 @@ -49,7 +49,7 @@ void MDL_MHT::measureAndValidate() { - BGN + PTR_INTO_ptrDLIST_OF< T_HYPO > tHypoPtr; MDL_T_HYPO *tHypo; @@ -96,7 +96,7 @@ void MDL_ROOT_T_HYPO::makeDefaultChildren() { - BGN + installChild( new MDL_DUMMY_T_HYPO( m_mdlMht ) ); } @@ -109,7 +109,7 @@ void MDL_ROOT_T_HYPO::makeChildrenFor( MDL_REPORT *report ) { - BGN + PTR_INTO_ptrDLIST_OF< MODEL > modelPtr; MODEL *mdl; @@ -147,7 +147,7 @@ void MDL_DUMMY_T_HYPO::makeDefaultChildren() { - BGN + installChild( new MDL_DUMMY_T_HYPO( m_mdlMht, m_logLikelihood ) ); } @@ -162,7 +162,7 @@ void MDL_CONTINUE_T_HYPO::makeDefaultChildren() { - BGN + MODEL *mdl = m_state->getMdl(); double endLogLikelihood = mdl->getEndLogLikelihood( m_state ); @@ -208,7 +208,7 @@ void MDL_CONTINUE_T_HYPO::makeChildrenFor( MDL_REPORT *report ) { - BGN + MODEL *mdl = m_state->getMdl(); double continueLogLikelihood = diff -ruN MHT_Orig/TRACKING/mht/mdlmht.h MHT/TRACKING/mht/mdlmht.h --- MHT_Orig/TRACKING/mht/mdlmht.h 2008-11-24 10:50:36.000000000 -0600 +++ MHT/TRACKING/mht/mdlmht.h 2009-11-29 13:05:56.000000000 -0600 @@ -647,8 +647,6 @@ MDL_DUMMY_T_HYPO( MDL_MHT *mdlMht, double logLikelihood = 0 ): MDL_T_HYPO( mdlMht ) { - BGN - m_endsTrack = 1; m_mustVerify = 0; m_logLikelihood = logLikelihood; @@ -678,8 +676,6 @@ MDL_FALARM_T_HYPO( MDL_MHT *mdlMht, MDL_REPORT *report ): MDL_DUMMY_T_HYPO( mdlMht, report ) { - BGN - m_endsTrack = 1; m_mustVerify = 1; m_logLikelihood = report->getFalarmLogLikelihood(); @@ -688,8 +684,6 @@ virtual void verify() { - BGN - m_mdlMht->falseAlarm( getTimeStamp(), (MDL_REPORT *)getReport() ); } @@ -736,8 +730,6 @@ MDL_T_HYPO( mdlMht, report ), m_state( state ) { - BGN - m_endsTrack = 0; m_mustVerify = 1; m_logLikelihood = trackLogLikelihood + @@ -752,8 +744,6 @@ virtual void makeChildrenFor( MDL_REPORT *report ); virtual void verify() { - BGN - m_mdlMht->continueTrack( getTrackStamp(), getTimeStamp(), m_state, (MDL_REPORT *)getReport() ); } @@ -783,8 +773,6 @@ MDL_STATE *state, MDL_REPORT *report ): MDL_CONTINUE_T_HYPO( mdlMht, report ) { - BGN - m_state = state; m_endsTrack = 0; m_mustVerify = 1; @@ -793,8 +781,6 @@ virtual void verify() { - BGN - m_mdlMht->startTrack( getTrackStamp(), getTimeStamp(), m_state, (MDL_REPORT *)getReport() ); } @@ -825,8 +811,6 @@ MDL_STATE *state ): MDL_CONTINUE_T_HYPO( mdlMht ) { - BGN - m_state = state; m_endsTrack = 0; m_mustVerify = 1; @@ -838,8 +822,6 @@ virtual void verify() { - BGN - m_mdlMht->skipTrack( getTrackStamp(), getTimeStamp(), m_state ); } @@ -867,8 +849,6 @@ double endLogLikelihood ): MDL_DUMMY_T_HYPO( mdlMht ) { - BGN - m_endsTrack = 1; m_mustVerify = 1; m_logLikelihood = trackLogLikelihood + @@ -878,7 +858,6 @@ virtual void verify() { - BGN m_mdlMht->endTrack( getTrackStamp(), getTimeStamp() ); } diff -ruN MHT_Orig/TRACKING/mht/mem.c MHT/TRACKING/mht/mem.c --- MHT_Orig/TRACKING/mht/mem.c 1995-04-27 09:27:01.000000000 -0500 +++ MHT/TRACKING/mht/mem.c 2009-12-04 13:32:03.000000000 -0600 @@ -50,9 +50,9 @@ #define DECLARE_MEM -#include -#include -#include +#include +#include // for malloc() +#include // for std::set_new_handler() #include "mem.h" @@ -161,12 +161,12 @@ void *operator new( size_t size ) { - CANT_RECUR - BGN + //CANT_RECUR + #ifdef TSTBUG - if( size <= 0 ) - THROW_ERR( "Illegal size given to new() -- " << size ) + assert( size > 0 ); + // THROW_ERR( "Illegal size given to new() -- " << size ) #endif void *mem; @@ -189,8 +189,8 @@ void operator delete( void *mem ) { - CANT_RECUR - BGN + //CANT_RECUR + if( mem != 0 ) { @@ -211,7 +211,7 @@ void CollectGarbage() { - BGN + chunkCleanup(); } @@ -234,26 +234,26 @@ return; isBusy = 1; - if( poolArray[ 0 ] != 0 ) - THROW_ERR( "Pool for zero size chunks exists" ) + assert( poolArray[ 0 ] == 0 ); + // THROW_ERR( "Pool for zero size chunks exists" ) for( i = 1; i < NUM_POOLS; i++ ) for( mem = poolArray[ i ]; mem != 0; mem = nextMem ) { nextMem = chunkHeaderFor( mem ).link.next; - if( chunkHeaderFor( mem ).magicNumber != HEADER_FREE || - chunkFooterFor( mem ).magicNumber != FOOTER_FREE ) - THROW_ERR( "Corrupted heap at " << mem ) + assert( chunkHeaderFor( mem ).magicNumber == HEADER_FREE && + chunkFooterFor( mem ).magicNumber == FOOTER_FREE ); + // THROW_ERR( "Corrupted heap at " << mem ) } for( mem = g_allocedList.nextAlloced; mem != 0; mem = nextMem ) { nextMem = chunkHeaderFor( mem ).nextAlloced; - if( chunkHeaderFor( mem ).magicNumber != HEADER_ALLOCED || - chunkFooterFor( mem ).magicNumber != FOOTER_ALLOCED ) - THROW_ERR( "Corrupted heap at " << mem ) + assert( chunkHeaderFor( mem ).magicNumber == HEADER_ALLOCED && + chunkFooterFor( mem ).magicNumber == FOOTER_ALLOCED ); + // THROW_ERR( "Corrupted heap at " << mem ) } isBusy = 0; @@ -275,10 +275,10 @@ head = chunkHeaderFor( mem ).magicNumber; foot = chunkFooterFor( mem ).magicNumber; - if( (head != HEADER_ALLOCED && head != HEADER_FREE) || - (head == HEADER_ALLOCED && foot != FOOTER_ALLOCED) || - (head == HEADER_FREE && foot != FOOTER_FREE) ) - THROW_ERR( "Corrupted heap at " << mem ); + assert( (head == HEADER_ALLOCED || head == HEADER_FREE) && + (head != HEADER_ALLOCED || foot == FOOTER_ALLOCED) && + (head != HEADER_FREE || foot == FOOTER_FREE) ); + // THROW_ERR( "Corrupted heap at " << mem ); } isBusy = 0; @@ -293,7 +293,7 @@ static inline int isSimpleMem( void *mem ) { - BGN + return chunkHeaderFor( mem ).link.pool == 0; } @@ -304,7 +304,7 @@ static inline void *simpleAlloc( size_t originalSize ) { - BGN + size_t size; void *mem; @@ -339,18 +339,19 @@ static inline void simpleDealloc( void *mem ) { - BGN + #ifdef DEBUG if( chunkHeaderFor( mem ).magicNumber != HEADER_ALLOCED || chunkFooterFor( mem ).magicNumber != FOOTER_ALLOCED ) { - if( chunkHeaderFor( mem ).magicNumber == HEADER_FREE && - chunkFooterFor( mem ).magicNumber == FOOTER_FREE ) - THROW_ERR( "Memory deallocated twice -- " << mem ) - - THROW_ERR( "Corrupted heap or deallocating bad address at " - << mem ) + assert( chunkHeaderFor( mem ).magicNumber != HEADER_FREE || + chunkFooterFor( mem ).magicNumber != FOOTER_FREE ); + // THROW_ERR( "Memory deallocated twice -- " << mem ) + + assert(false); + //THROW_ERR( "Corrupted heap or deallocating bad address at " + // << mem ) } chunkHeaderFor( mem ).magicNumber = HEADER_FREE; @@ -367,7 +368,7 @@ static inline void *chunkAlloc( size_t size ) { - BGN + int poolNum; register void *mem; @@ -382,9 +383,9 @@ mem = chunkGroupAlloc( poolNum ); #ifdef DEBUG - if( chunkHeaderFor( mem ).magicNumber != HEADER_FREE || - chunkFooterFor( mem ).magicNumber != FOOTER_FREE ) - THROW_ERR( "Corrupted heap at " << mem ); + assert( chunkHeaderFor( mem ).magicNumber == HEADER_FREE && + chunkFooterFor( mem ).magicNumber == FOOTER_FREE ); + // THROW_ERR( "Corrupted heap at " << mem ); #endif *pool = chunkHeaderFor( mem ).link.next; @@ -407,18 +408,19 @@ static inline void chunkDealloc( void *mem ) { - BGN + #ifdef DEBUG if( chunkHeaderFor( mem ).magicNumber != HEADER_ALLOCED || chunkFooterFor( mem ).magicNumber != FOOTER_ALLOCED ) { - if( chunkHeaderFor( mem ).magicNumber == HEADER_FREE && - chunkFooterFor( mem ).magicNumber == FOOTER_FREE ) - THROW_ERR( "Memory deallocated twice" ) - - THROW_ERR( "Corrupted heap or deallocating bad address at " - << mem ) + assert( chunkHeaderFor( mem ).magicNumber != HEADER_FREE || + chunkFooterFor( mem ).magicNumber != FOOTER_FREE ); + // THROW_ERR( "Memory deallocated twice" ) + + assert(false); + //THROW_ERR( "Corrupted heap or deallocating bad address at " + // << mem ) } #endif @@ -442,7 +444,7 @@ static void *chunkGroupAlloc( int poolNum ) { - BGN + size_t originalSize; size_t chunkSize; @@ -510,7 +512,7 @@ static void chunkCleanup() { - BGN + GROUP_HEADER *prevGroup; GROUP_HEADER *group; @@ -609,7 +611,7 @@ static inline CHUNK_HEADER &chunkHeaderFor( void *mem ) { - BGN + return ((CHUNK_HEADER *)mem)[ -1 ]; } @@ -680,7 +682,7 @@ static inline int isEmergencyMem( void *mem ) { - BGN + return (mem >= (void *)emergencyBuf && mem < (void *)(emergencyBuf + EMERGENCY_BUF_LONGS)); @@ -692,7 +694,7 @@ static void *emergencyAlloc( size_t size ) { - BGN + long i, j; @@ -705,7 +707,8 @@ if( i > EMERGENCY_BUF_LONGS || emergencyBuf[ i ] == 0 ) { fprintf( stderr, "\nEmergency buffer is corrupted\n" ); - DumpCore(); + //DumpCore(); + assert(false); } for( i = 0; i < EMERGENCY_BUF_LONGS; i += labs( emergencyBuf[ i ] ) ) @@ -727,7 +730,8 @@ fprintf( stderr, "\nOut of emergency buffer space " "(looking for %d bytes)\n", size * 2 ); - DumpCore(); + //DumpCore(); + assert(false); } if( size < emergencyBuf[ i ] ) @@ -744,7 +748,7 @@ static inline void emergencyDealloc( void *mem ) { - BGN + if( ((long *)mem)[ -1 ] < 0 ) ((long *)mem)[ -1 ] *= -1; @@ -756,7 +760,7 @@ static void *alloc( size_t originalSize ) { - BGN + void *mem; size_t size; @@ -777,8 +781,8 @@ mem = malloc( size ); } - if( mem == 0 ) - THROW_ERR( "Can't allocate " << size << " bytes of memory" ) + assert( mem != 0 ); + // THROW_ERR( "Can't allocate " << size << " bytes of memory" ) } G_allocatedMemory += size; @@ -796,7 +800,7 @@ static inline void dealloc( void *mem ) { - BGN + size_t size; @@ -805,8 +809,8 @@ size = *((size_t *)mem); #ifdef TSTBUG - if( size < sizeof( size_t ) ) - THROW_ERR( "Corrupted heap at " << mem ) + assert( size >= sizeof( size_t ) ); + // THROW_ERR( "Corrupted heap at " << mem ) *((size_t *)mem) = 0; #endif @@ -822,12 +826,12 @@ static inline HANDLER_FOR_NEW getHandlerForNew() { - BGN + HANDLER_FOR_NEW handlerForNew; - handlerForNew = set_new_handler( 0 ); - set_new_handler( handlerForNew ); + handlerForNew = std::set_new_handler( 0 ); + std::set_new_handler( handlerForNew ); return handlerForNew; } diff -ruN MHT_Orig/TRACKING/mht/mem.h MHT/TRACKING/mht/mem.h --- MHT_Orig/TRACKING/mht/mem.h 1995-04-27 09:27:01.000000000 -0500 +++ MHT/TRACKING/mht/mem.h 2009-12-03 21:55:13.000000000 -0600 @@ -159,9 +159,10 @@ #ifndef MEM_H #define MEM_H -#include +#include #include "except.h" +#include #ifdef DECLARE_MEM #define GLOBAL diff -ruN MHT_Orig/TRACKING/mht/mht.c MHT/TRACKING/mht/mht.c --- MHT_Orig/TRACKING/mht/mht.c 1995-04-27 09:27:01.000000000 -0500 +++ MHT/TRACKING/mht/mht.c 2009-12-03 22:55:45.000000000 -0600 @@ -52,7 +52,7 @@ int MHT::scan() { - BGN + Timer timer; @@ -109,7 +109,7 @@ void MHT::importNewReports() { - BGN + PTR_INTO_iDLIST_OF< REPORT > reportPtr; int rowNum; @@ -129,7 +129,7 @@ void MHT::makeNewGroups() { - BGN + for( ; m_nextNewTTree.isValid(); ++m_nextNewTTree ) { @@ -172,7 +172,7 @@ void MHT::findGroupLabels() { - BGN + PTR_INTO_iDLIST_OF< T_TREE > tTreePtr; PTR_INTO_iDLIST_OF< REPORT > reportPtr; @@ -197,8 +197,8 @@ } #ifdef TSTBUG - if( ! m_newReportList.isEmpty() ) - THROW_ERR( "m_newReportList must be empty in findGroupLabels()" ) + assert( m_newReportList.isEmpty() ); + // THROW_ERR( "m_newReportList must be empty in findGroupLabels()" ) #endif #ifdef DEBUG @@ -217,7 +217,7 @@ void MHT::splitGroups() { - BGN + PTR_INTO_iDLIST_OF< GROUP > groupPtr; @@ -240,7 +240,7 @@ void MHT::mergeGroups() { - BGN + PTR_INTO_iDLIST_OF< GROUP > groupPtr0; PTR_INTO_iDLIST_OF< GROUP > groupPtr1; @@ -270,7 +270,7 @@ void MHT::pruneAndHypothesize() { - BGN + PTR_INTO_iDLIST_OF< GROUP > groupPtr; @@ -284,7 +284,7 @@ void MHT::clear() { - BGN + PTR_INTO_iDLIST_OF< GROUP > groupPtr; for (int i=m_maxDepth; i>=0; i--) @@ -309,7 +309,7 @@ void MHT::removeUnusedTHypos() { - BGN + PTR_INTO_iDLIST_OF< T_TREE > tTreePtr; PTR_INTO_iTREE_OF< T_HYPO > tHypoPtr; @@ -331,7 +331,7 @@ void MHT::verifyTTreeRoots() { - BGN + PTR_INTO_iDLIST_OF< T_TREE > tTreePtr; iTREE_OF< T_HYPO > *tTree; @@ -361,7 +361,7 @@ void MHT::verifyLastTTreeRoots() { - BGN + PTR_INTO_iDLIST_OF< T_TREE > tTreePtr; iTREE_OF< T_HYPO > *tTree; @@ -401,7 +401,7 @@ void MHT::removeUnusedTTrees() { - BGN + PTR_INTO_iDLIST_OF< T_TREE > tTreePtr; iTREE_OF< T_HYPO > *tTree; @@ -437,7 +437,7 @@ void MHT::removeUnusedReports() { - BGN + PTR_INTO_iDLIST_OF< REPORT > reportPtr; @@ -453,7 +453,7 @@ void MHT::removeUnusedGroups() { - BGN + PTR_INTO_iDLIST_OF< GROUP > groupPtr; @@ -469,7 +469,7 @@ void MHT::updateActiveTHypoList() { - BGN + PTR_INTO_iDLIST_OF< T_TREE > tTreePtr; PTR_INTO_iTREE_OF< T_HYPO > tHypoPtr; @@ -490,7 +490,7 @@ void MHT::checkGroups() { - BGN + PTR_INTO_iDLIST_OF< GROUP > groupPtr0; PTR_INTO_iDLIST_OF< GROUP > groupPtr1; @@ -506,8 +506,8 @@ groupId = (*groupPtr0).getGroupId(); for( (groupPtr1 = groupPtr0),++groupPtr1; groupPtr1.isValid(); ++groupPtr1) - if( (*groupPtr1).getGroupId() == groupId ) - THROW_ERR( "Two groups with same id" ) + assert( (*groupPtr1).getGroupId() != groupId ); + // THROW_ERR( "Two groups with same id" ) } } @@ -517,7 +517,7 @@ void MHT::describe( int spaces ) { - BGN + PTR_INTO_ptrDLIST_OF< T_HYPO > tHypoPtr; PTR_INTO_iDLIST_OF< GROUP > groupPtr; @@ -525,63 +525,63 @@ PTR_INTO_iDLIST_OF< T_TREE > tTreePtr; int k; - Indent( spaces ); cout << "MHT "; print(); cout << endl; + Indent( spaces ); std::cout << "MHT "; print(); std::cout << std::endl; spaces += 2; Indent( spaces ); - cout << "lastTrackUsed = " << m_lastTrackIdUsed; - cout << ", time = " << m_currentTime; - cout << endl; + std::cout << "lastTrackUsed = " << m_lastTrackIdUsed; + std::cout << ", time = " << m_currentTime; + std::cout << std::endl; Indent( spaces ); - cout << "maxDepth = " << m_maxDepth; - cout << ", logMinRatio = " << m_logMinGHypoRatio; - cout << ", maxGHypos = " << m_maxGHypos; - cout << endl; + std::cout << "maxDepth = " << m_maxDepth; + std::cout << ", logMinRatio = " << m_logMinGHypoRatio; + std::cout << ", maxGHypos = " << m_maxGHypos; + std::cout << std::endl; - Indent( spaces ); cout << "active tHypo's:"; + Indent( spaces ); std::cout << "active tHypo's:"; k = 0; LOOP_DLIST( tHypoPtr, m_activeTHypoList ) { if( k++ >= 3 ) { - cout << endl; - Indent( spaces ); cout << " "; + std::cout << std::endl; + Indent( spaces ); std::cout << " "; k = 0; } - cout << " "; (*tHypoPtr).print(); + std::cout << " "; (*tHypoPtr).print(); } - cout << endl; + std::cout << std::endl; - Indent( spaces ); cout << "===== clusters"; cout << endl; + Indent( spaces ); std::cout << "===== clusters"; std::cout << std::endl; LOOP_DLIST( groupPtr, m_groupList ) { (*groupPtr).describe( spaces + 2 ); } - Indent( spaces ); cout << "===== oldReports"; cout << endl; + Indent( spaces ); std::cout << "===== oldReports"; std::cout << std::endl; LOOP_DLIST( reportPtr, m_oldReportList ) { (*reportPtr).describe( spaces + 2 ); } - Indent( spaces ); cout << "===== newReports"; cout << endl; + Indent( spaces ); std::cout << "===== newReports"; std::cout << std::endl; LOOP_DLIST( reportPtr, m_newReportList ) { (*reportPtr).describe( spaces + 2 ); } - Indent( spaces ); cout << "===== oldTrees"; cout << endl; + Indent( spaces ); std::cout << "===== oldTrees"; std::cout << std::endl; LOOP_DLIST( tTreePtr, m_tTreeList ) { if( tTreePtr == m_nextNewTTree ) { - Indent( spaces ); cout << "===== newTrees"; cout << endl; + Indent( spaces ); std::cout << "===== newTrees"; std::cout << std::endl; } - cout << endl; + std::cout << std::endl; (**(*tTreePtr).getTree()).describeTree( spaces + 2 ); } } @@ -593,7 +593,7 @@ void MHT::printStats( int spaces ) { - BGN + int totalTTrees = m_tTreeList.getLength(); int totalTHypos = m_activeTHypoList.getLength(); @@ -614,20 +614,20 @@ maxGHypos = numGHypos; } - Indent( spaces ); cout << "track trees ---------------- " - << totalTTrees << endl; - Indent( spaces ); cout << " track hypos: " - << totalTHypos << endl; - Indent( spaces ); cout << " hypos per tree: " - << (double)totalTHypos / totalTTrees << endl; - Indent( spaces ); cout << "groups --------------------- " - << totalGroups << endl; - Indent( spaces ); cout << " group hypos: " - << totalGHypos << endl; - Indent( spaces ); cout << " hypos per group: " - << (double)totalGHypos / totalGroups << endl; - Indent( spaces ); cout << " max hypos in a group: " - << maxGHypos << endl; + Indent( spaces ); std::cout << "track trees ---------------- " + << totalTTrees << std::endl; + Indent( spaces ); std::cout << " track hypos: " + << totalTHypos << std::endl; + Indent( spaces ); std::cout << " hypos per tree: " + << (double)totalTHypos / totalTTrees << std::endl; + Indent( spaces ); std::cout << "groups --------------------- " + << totalGroups << std::endl; + Indent( spaces ); std::cout << " group hypos: " + << totalGHypos << std::endl; + Indent( spaces ); std::cout << " hypos per group: " + << (double)totalGHypos / totalGroups << std::endl; + Indent( spaces ); std::cout << " max hypos in a group: " + << maxGHypos << std::endl; } /*-------------------------------------------------------------------* @@ -636,43 +636,43 @@ void MHT::doDbgA() { - BGN + - cout << endl; - cout << " ************************** MHT after measureAndValidate()" - << endl; + std::cout << std::endl; + std::cout << " ************************** MHT after measureAndValidate()" + << std::endl; describe( 4 ); - cout << " HIT RETURN..." << endl; + std::cout << " HIT RETURN..." << std::endl; getchar(); } void MHT::doDbgB() { - BGN + - cout << endl; - cout << " ******************************* MHT after group formation" - << endl; + std::cout << std::endl; + std::cout << " ******************************* MHT after group formation" + << std::endl; describe( 4 ); - cout << " HIT RETURN..." << endl; + std::cout << " HIT RETURN..." << std::endl; getchar(); } void MHT::doDbgC() { - BGN + - cout << endl; - cout << " *************************************** MHT after pruning" - << endl; + std::cout << std::endl; + std::cout << " *************************************** MHT after pruning" + << std::endl; describe( 4 ); - cout << " HIT RETURN..." << endl; + std::cout << " HIT RETURN..." << std::endl; getchar(); } diff -ruN MHT_Orig/TRACKING/mht/mht_group.c MHT/TRACKING/mht/mht_group.c --- MHT_Orig/TRACKING/mht/mht_group.c 1995-04-27 09:27:01.000000000 -0500 +++ MHT/TRACKING/mht/mht_group.c 2009-12-03 23:15:34.000000000 -0600 @@ -175,8 +175,8 @@ { } - G_HYPO *getGHypo0() const { BGN return g_gHypoArray0[ i0 ]; } - G_HYPO *getGHypo1() const { BGN return g_gHypoArray1[ i1 ]; } + G_HYPO *getGHypo0() const { return g_gHypoArray0[ i0 ]; } + G_HYPO *getGHypo1() const { return g_gHypoArray1[ i1 ]; } double getLogLikelihood() const { @@ -209,7 +209,7 @@ static int compareGHypoPtrs( const void *addr0, const void *addr1 ) { - BGN + #define gHypo0 (*(G_HYPO **)addr0) #define gHypo1 (*(G_HYPO **)addr1) @@ -226,7 +226,7 @@ static void setupArray0( iDLIST_OF< G_HYPO > &gHypoList, int numGHypos ) { - BGN + int compareGHypoPtrs( const void *addr0, const void *addr1 ); @@ -251,7 +251,7 @@ static void setupArray1( iDLIST_OF< G_HYPO > &gHypoList, int numGHypos ) { - BGN + int compareGHypoPtrs( const void *addr0, const void *addr1 ); @@ -284,7 +284,7 @@ double logMinGHypoRatio, int maxGHypos ) { - BGN + #define G_HYPO_PAIR_USED( g0, g1 ) \ g_gHypoPairUsed[ ((g0) * maxGHypos) + g1 ] @@ -301,7 +301,7 @@ numGHypos1 = src->m_gHypoList.getLength(); numGHypos0 = m_gHypoList.getLength(); - CheckMem(); + //CheckMem(); if( numGHypos1 == 1 ) { @@ -309,7 +309,7 @@ LOOP_DLIST( gHypoPtr, m_gHypoList ) { (*gHypoPtr).merge( src->m_gHypoList.getHead() ); - CheckMem(); + //CheckMem(); } src->m_gHypoList.removeAll(); @@ -331,7 +331,7 @@ gHypo->merge( gHypoPair.getGHypo0() ); gHypo->merge( gHypoPair.getGHypo1() ); newGHypoList.append( gHypo ); - CheckMem(); + //CheckMem(); if( gHypoPair.i0 + 1 < numGHypos0 && ! G_HYPO_PAIR_USED( gHypoPair.i0 + 1, gHypoPair.i1 ) ) { @@ -360,10 +360,10 @@ */ m_gHypoList.removeAll(); - CheckMem(); + //CheckMem(); src->m_gHypoList.removeAll(); - CheckMem(); + //CheckMem(); m_gHypoList.splice( newGHypoList ); #undef G_HYPO_PAIR_USED @@ -419,7 +419,7 @@ void GROUP::splitIfYouMust() { - BGN + GROUP *newGroup; int groupId; @@ -466,7 +466,7 @@ void GROUP::removeRepeats() { - BGN + PTR_INTO_iDLIST_OF< G_HYPO > gHypoPtr0; PTR_INTO_iDLIST_OF< G_HYPO > gHypoPtr1; @@ -496,7 +496,7 @@ double logMinGHypoRatio, int maxGHypos ) { - BGN + Timer timer0; Timer timer1; @@ -586,7 +586,7 @@ void GROUP::clear( int maxDepth) { - BGN + PTR_INTO_iDLIST_OF< G_HYPO > gHypoPtr; @@ -611,22 +611,22 @@ void GROUP::check() { - BGN + PTR_INTO_iDLIST_OF< G_HYPO > gHypoPtr; int numTHypos; int groupId; numTHypos = (*m_gHypoList).getNumTHypos(); - if( numTHypos == 0 ) - THROW_ERR( "Group with 0 trees" ) + assert( numTHypos != 0 ); + // THROW_ERR( "Group with 0 trees" ) groupId = (*m_gHypoList).getGroupId(); LOOP_DLIST( gHypoPtr, m_gHypoList ) { - if( (*gHypoPtr).getNumTHypos() != numTHypos ) - THROW_ERR( "Group with different numbers of tHypos" ) - if( (*gHypoPtr).getGroupId() != groupId ) - THROW_ERR( "More than one group id in same group" ) + assert( (*gHypoPtr).getNumTHypos() == numTHypos ); + // THROW_ERR( "Group with different numbers of tHypos" ) + assert( (*gHypoPtr).getGroupId() == groupId ); + // THROW_ERR( "More than one group id in same group" ) } } @@ -636,11 +636,11 @@ void GROUP::describe( int spaces ) { - BGN + PTR_INTO_iDLIST_OF< G_HYPO > gHypoPtr; - Indent( spaces ); cout << "CLUSTER "; print(); cout << endl; + Indent( spaces ); std::cout << "CLUSTER "; print(); std::cout << std::endl; LOOP_LINKS( gHypoPtr, m_gHypoList ) { @@ -660,7 +660,7 @@ m_numTHyposUsedInProblem( 0 ), m_tHypoLinks() { - BGN + int i; for( i = 0; i < solutionSize; i++ ) @@ -771,7 +771,7 @@ void G_HYPO::makeProblem() { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; PTR_INTO_iTREE_OF< T_HYPO > childPtr; @@ -793,8 +793,8 @@ LOOP_LINKS( tHypoPtr, m_tHypoLinks ) { #ifdef TSTBUG - if( (*tHypoPtr).isLeaf() ) - THROW_ERR( "THypo has no children for next iteration" ) + assert( ! (*tHypoPtr).isLeaf() ); + // THROW_ERR( "THypo has no children for next iteration" ) #endif numRCCs += (*tHypoPtr).getNumChildren(); @@ -856,7 +856,7 @@ void G_HYPO::nScanBackPrune( int maxDepth ) { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; PTR_INTO_iTREE_OF< T_HYPO > parentPtr; @@ -893,7 +893,7 @@ void G_HYPO::recomputeLogLikelihood() { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; @@ -913,7 +913,7 @@ int G_HYPO::mustSplit() { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; int groupId; @@ -939,7 +939,7 @@ G_HYPO *G_HYPO::split( int groupId ) { - BGN + G_HYPO *newGHypo = new G_HYPO(); PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; @@ -966,7 +966,7 @@ void G_HYPO::merge( G_HYPO *src ) { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; @@ -983,7 +983,7 @@ void G_HYPO::setFlags() { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; @@ -1000,7 +1000,7 @@ void G_HYPO::resetFlags() { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; @@ -1017,7 +1017,7 @@ int G_HYPO::allFlagsAreSet() { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; @@ -1036,32 +1036,32 @@ void G_HYPO::describe( int spaces ) { - BGN + PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; int k; - Indent( spaces ); cout << "G_HYPO "; print(); cout << endl; + Indent( spaces ); std::cout << "G_HYPO "; print(); std::cout << std::endl; - Indent( spaces ); cout << "|"; - cout << " numTHyposUsed = " << m_numTHyposUsedInProblem; - cout << ", logLikelihood = " << m_logLikelihood; - cout << endl; + Indent( spaces ); std::cout << "|"; + std::cout << " numTHyposUsed = " << m_numTHyposUsedInProblem; + std::cout << ", logLikelihood = " << m_logLikelihood; + std::cout << std::endl; - Indent( spaces ); cout << "| tHypo's:"; + Indent( spaces ); std::cout << "| tHypo's:"; k = 0; LOOP_LINKS( tHypoPtr, m_tHypoLinks ) { if( k++ >= 3 ) { - cout << endl; - Indent( spaces ); cout << "| "; + std::cout << std::endl; + Indent( spaces ); std::cout << "| "; k = 0; } - cout << " "; (*tHypoPtr).print(); + std::cout << " "; (*tHypoPtr).print(); } - cout << endl; + std::cout << std::endl; } diff -ruN MHT_Orig/TRACKING/mht/mht.h MHT/TRACKING/mht/mht.h --- MHT_Orig/TRACKING/mht/mht.h 2008-11-24 10:46:20.000000000 -0600 +++ MHT/TRACKING/mht/mht.h 2009-12-03 22:27:30.000000000 -0600 @@ -446,14 +446,18 @@ #ifndef MHT_H #define MHT_H -#include +#include +#include // for strncopy() +#include // for std::cout, std::endl +#include #include "except.h" #include "list.h" #include "tree.h" #include "links.h" #include "vector.h" -#include "mem.h" +//#include "mem.h" + #ifdef DECLARE_MHT #define GLOBAL @@ -598,8 +602,6 @@ m_endsTrack( 0 ), m_mustVerify( 0 ) { - BGN - MAKE_LINK( this, m_reportLink, report, m_tHypoLinks ); } @@ -610,8 +612,6 @@ void installChild( T_HYPO *child ) { - BGN - PTR_INTO_iTREE_OF< T_HYPO > p = this; p.insertFirstChild( child ); @@ -625,8 +625,8 @@ double getLogLikelihood() { #ifdef TSTBUG - if( m_logLikelihood == DOUBLE_NOT_READY ) - THROW_ERR( "THypo wasn't given a logLikelihood" ); + assert( m_logLikelihood != DOUBLE_NOT_READY ); + // THROW_ERR( "THypo wasn't given a logLikelihood" ); #endif return m_logLikelihood; @@ -641,7 +641,7 @@ REPORT *getReport() { return m_reportLink.getHead(); } virtual void verify() - { THROW_ERR( "Call to T_HYPO::verify()" ) } + { assert(false);}//THROW_ERR( "Call to T_HYPO::verify()" ) } private: @@ -724,8 +724,6 @@ void addTHypo( T_HYPO *tHypo ) { - BGN - m_logLikelihood += tHypo->getLogLikelihood(); MAKE_LINK( this, m_tHypoLinks, @@ -905,8 +903,6 @@ void installTree( T_HYPO *rootNode, int timeOffset = 0 ) { - BGN - T_TREE *tree = new T_TREE( rootNode, m_lastTrackIdUsed++, m_currentTime + timeOffset ); @@ -920,7 +916,7 @@ protected: virtual void measureAndValidate() - { THROW_ERR( "Call to MHT::measureAndValidate()" ) } + { assert(false);}//THROW_ERR( "Call to MHT::measureAndValidate()" ) } public: @@ -979,9 +975,9 @@ inline int T_HYPO::getTrackStamp() { #ifdef TSTBUG - if( m_tree == 0 ) - THROW_ERR( "Trying to get track stamp from " - "uninitialized tHypo" ) + assert( m_tree != 0 ); + // THROW_ERR( "Trying to get track stamp from " + // "uninitialized tHypo" ) #endif return m_tree->getId(); @@ -990,9 +986,9 @@ inline int T_HYPO::getGroupId() { #ifdef TSTBUG - if( m_tree == 0 ) - THROW_ERR( "Trying to get group id from " - "uninitialized tHypo" ) + assert( m_tree != 0 ); + // THROW_ERR( "Trying to get group id from " + // "uninitialized tHypo" ) #endif return m_tree->getGroupId(); diff -ruN MHT_Orig/TRACKING/mht/mht_report.c MHT/TRACKING/mht/mht_report.c --- MHT_Orig/TRACKING/mht/mht_report.c 1995-04-27 09:27:01.000000000 -0500 +++ MHT/TRACKING/mht/mht_report.c 2009-12-03 22:50:04.000000000 -0600 @@ -59,7 +59,6 @@ void REPORT::setAllGroupIds( int groupId ) { - BGN PTR_INTO_iDLIST_OF< REPORT > reportPtr; PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; @@ -92,7 +91,6 @@ void REPORT::checkGroupIds() { - BGN PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; T_TREE *tree; @@ -101,8 +99,8 @@ { tree = (*tHypoPtr).getTree(); - if( tree->getGroupId() != m_groupId ) - THROW_ERR( "Bad group id for report" ) + assert( tree->getGroupId() == m_groupId ); + // THROW_ERR( "Bad group id for report" ) } } @@ -112,27 +110,26 @@ void REPORT::describe( int spaces ) { - BGN PTR_INTO_LINKS_TO< T_HYPO > tHypoPtr; int k; - Indent( spaces ); cout << "REPORT "; print(); cout << endl; + Indent( spaces ); std::cout << "REPORT "; print(); std::cout << std::endl; - Indent( spaces ); cout << "| tHypo's:"; + Indent( spaces ); std::cout << "| tHypo's:"; k = 0; LOOP_LINKS( tHypoPtr, m_tHypoLinks ) { if( k++ >= 3 ) { - cout << endl; - Indent( spaces ); cout << "| "; + std::cout << std::endl; + Indent( spaces ); std::cout << "| "; k = 0; } - cout << " "; (*tHypoPtr).print(); + std::cout << " "; (*tHypoPtr).print(); } - cout << endl; + std::cout << std::endl; } diff -ruN MHT_Orig/TRACKING/mht/mht_track.c MHT/TRACKING/mht/mht_track.c --- MHT_Orig/TRACKING/mht/mht_track.c 1995-04-27 09:27:01.000000000 -0500 +++ MHT/TRACKING/mht/mht_track.c 2009-12-03 21:48:59.000000000 -0600 @@ -47,61 +47,60 @@ void T_HYPO::describe( int spaces, int depth ) { - BGN PTR_INTO_LINKS_TO< G_HYPO > gHypoPtr; int i, k; Indent( spaces - 1); for( i = 0; i < depth; i++ ) - cout << " |"; - cout << " **T_HYPO "; print(); cout << endl; + std::cout << " |"; + std::cout << " **T_HYPO "; print(); std::cout << std::endl; Indent( spaces - 1 ); for( i = 0; i <= depth; i++ ) - cout << " |"; - cout << " track = " << getTrackStamp(); - cout << ", time = " << m_timeStamp; - cout << ", group id = " << getGroupId(); - cout << endl; + std::cout << " |"; + std::cout << " track = " << getTrackStamp(); + std::cout << ", time = " << m_timeStamp; + std::cout << ", group id = " << getGroupId(); + std::cout << std::endl; Indent( spaces - 1 ); for( i = 0; i <= depth; i++ ) - cout << " |"; + std::cout << " |"; if( m_reportLink.isEmpty() ) - cout << " NO REPORT"; + std::cout << " NO REPORT"; else { - cout << " report = "; (*m_reportLink).print(); + std::cout << " report = "; (*m_reportLink).print(); } - cout << ", logLikelihood = " << m_logLikelihood; + std::cout << ", logLikelihood = " << m_logLikelihood; if( ! m_mustVerify ) - cout << ", NEED NOT VERIFY"; + std::cout << ", NEED NOT VERIFY"; if( m_endsTrack ) - cout << ", ENDS TRACK"; - cout << endl; + std::cout << ", ENDS TRACK"; + std::cout << std::endl; Indent( spaces - 1 ); for( i = 0; i <= depth; i++ ) - cout << " |"; - cout << " gHypo's:"; + std::cout << " |"; + std::cout << " gHypo's:"; k = 0; LOOP_LINKS( gHypoPtr, m_gHypoLinks ) { if( k++ >= 3 ) { - cout << endl; + std::cout << std::endl; Indent( spaces - 1 ); for( i = 0; i <= depth; i++ ) - cout << " |"; - cout << " "; + std::cout << " |"; + std::cout << " "; k = 0; } - cout << " "; (*gHypoPtr).print(); + std::cout << " "; (*gHypoPtr).print(); } - cout << endl; + std::cout << std::endl; } /*-------------------------------------------------------------------* @@ -110,7 +109,6 @@ void T_HYPO::describeTree( int spaces, int depth ) { - BGN PTR_INTO_iTREE_OF< T_HYPO > childPtr; diff -ruN MHT_Orig/TRACKING/mht/pqueue.code MHT/TRACKING/mht/pqueue.code --- MHT_Orig/TRACKING/mht/pqueue.code 1995-04-27 09:32:35.000000000 -0500 +++ MHT/TRACKING/mht/pqueue.code 2009-12-03 23:07:06.000000000 -0600 @@ -52,18 +52,16 @@ template< class TYPE > void PQUEUE_OF< TYPE >::put( const TYPE &info ) { - BGN - int i; m_numObjects++; #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to put() " - "onto unallocated priority queue" ) - if( m_numObjects >= m_size ) - THROW_ERR( "Priority queue overflow" ) + assert( m_data != 0 ); + // THROW_ERR( "Trying to put() " + // "onto unallocated priority queue" ) + assert( m_numObjects < m_size ); + // THROW_ERR( "Priority queue overflow" ) #endif for( i = m_numObjects; @@ -82,8 +80,6 @@ template< class TYPE > void PQUEUE_OF< TYPE >::heapify( int i ) { - BGN - int left = i << 1; int right = left + 1; int largest = i; diff -ruN MHT_Orig/TRACKING/mht/pqueue.h MHT/TRACKING/mht/pqueue.h --- MHT_Orig/TRACKING/mht/pqueue.h 1995-04-27 09:27:01.000000000 -0500 +++ MHT/TRACKING/mht/pqueue.h 2009-12-04 10:08:47.000000000 -0600 @@ -92,6 +92,7 @@ #define PQUEUE_H #include "except.h" +#include template< class TYPE > class PQUEUE_OF @@ -122,11 +123,9 @@ void resize( int size ) { - BGN - #ifdef TSTBUG - if( ! isEmpty() ) - THROW_ERR( "Priority queue is not empty" ) + assert( isEmpty() ); + // THROW_ERR( "Priority queue is not empty" ) #endif size++; @@ -149,16 +148,14 @@ TYPE get() { - BGN - TYPE info; #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to get() " - "from unallocated priority queue" ) - if( isEmpty() ) - THROW_ERR( "Priority queue underflow" ); + assert( m_data != 0 ); + // THROW_ERR( "Trying to get() " + // "from unallocated priority queue" ) + assert( ! isEmpty() ); + // THROW_ERR( "Priority queue underflow" ); #endif info = m_data[ 1 ]; @@ -170,14 +167,12 @@ TYPE peek() { - BGN - #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to peek() " - "into unallocated priority queue" ) - if( isEmpty() ) - THROW_ERR( "Priority queue underflow" ); + assert( m_data != 0 ); + // THROW_ERR( "Trying to peek() " + // "into unallocated priority queue" ) + assert( ! isEmpty() ); + // THROW_ERR( "Priority queue underflow" ); #endif return m_data[ 1 ]; diff -ruN MHT_Orig/TRACKING/mht/queue.h MHT/TRACKING/mht/queue.h --- MHT_Orig/TRACKING/mht/queue.h 1995-04-27 09:27:02.000000000 -0500 +++ MHT/TRACKING/mht/queue.h 2009-12-03 22:25:17.000000000 -0600 @@ -85,6 +85,7 @@ #define QUEUE_H #include "except.h" +#include template< class TYPE > class QUEUE_OF @@ -118,11 +119,9 @@ void resize( int size ) { - BGN - #ifdef TSTBUG - if( ! isEmpty() ) - THROW_ERR( "Queue is not empty" ) + assert( isEmpty() ); + // THROW_ERR( "Queue is not empty" ) #endif size += 2; @@ -145,11 +144,9 @@ void put( const TYPE &info ) { - BGN - #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to put() onto unallocated queue" ) + assert( m_data != 0 ); + // THROW_ERR( "Trying to put() onto unallocated queue" ) #endif m_data[ m_writePos++ ] = info; @@ -157,26 +154,24 @@ m_writePos = 0; #ifdef TSTBUG - if( m_writePos == m_readPos ) - THROW_ERR( "Queue overflow" ) + assert( m_writePos != m_readPos ); + // THROW_ERR( "Queue overflow" ) #endif } TYPE get() { - BGN - #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to get() from unallocated queue" ) + assert( m_data != 0 ); + // THROW_ERR( "Trying to get() from unallocated queue" ) #endif if( ++m_readPos >= m_size ) m_readPos = 0; #ifdef TSTBUG - if( m_readPos == m_writePos ) - THROW_ERR( "Queue underflow" ); + assert( m_readPos != m_writePos ); + // THROW_ERR( "Queue underflow" ); #endif return m_data[ m_readPos ]; @@ -184,11 +179,9 @@ TYPE peek() { - BGN - #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to peek() into unallocated queue" ) + assert( m_data != 0 ); + // THROW_ERR( "Trying to peek() into unallocated queue" ) #endif int readPos; @@ -198,8 +191,8 @@ readPos = 0; #ifdef TSTBUG - if( readPos == m_writePos ) - THROW_ERR( "Queue underflow" ); + assert( readPos != m_writePos ); + // THROW_ERR( "Queue underflow" ); #endif return m_data[ readPos ]; diff -ruN MHT_Orig/TRACKING/mht/stack.h MHT/TRACKING/mht/stack.h --- MHT_Orig/TRACKING/mht/stack.h 1995-04-27 09:27:02.000000000 -0500 +++ MHT/TRACKING/mht/stack.h 2009-12-03 22:24:06.000000000 -0600 @@ -85,6 +85,7 @@ #define STACK_H #include "except.h" +#include template< class TYPE > class STACK_OF @@ -115,11 +116,9 @@ void resize( int size ) { - BGN - #ifdef TSTBUG - if( ! isEmpty() ) - THROW_ERR( "Stack is not empty" ) + assert( isEmpty() ); + // THROW_ERR( "Stack is not empty" ) #endif if( size > m_size ) @@ -136,13 +135,11 @@ void put( const TYPE &info ) { - BGN - #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to put() onto unallocated stack" ) - if( m_top >= m_size ) - THROW_ERR( "Stack overflow" ); + assert( m_data != 0 ); + //THROW_ERR( "Trying to put() onto unallocated stack" ) + assert( m_top < m_size ); + //THROW_ERR( "Stack overflow" ); #endif m_data[ m_top++ ] = info; @@ -150,13 +147,11 @@ TYPE get() { - BGN - #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to get() from unallocated stack" ) - if( m_top == 0 ) - THROW_ERR( "Stack underflow" ); + assert( m_data != 0 ); + // THROW_ERR( "Trying to get() from unallocated stack" ) + assert( m_top != 0 ); + // THROW_ERR( "Stack underflow" ); #endif return m_data[ --m_top ]; @@ -164,13 +159,11 @@ TYPE peek() { - BGN - #ifdef TSTBUG - if( m_data == 0 ) - THROW_ERR( "Trying to peek() into unallocated stack" ) - if( m_top == 0 ) - THROW_ERR( "Stack underflow" ); + assert( m_data != 0 ); + // THROW_ERR( "Trying to peek() into unallocated stack" ) + assert( m_top != 0 ); + // THROW_ERR( "Stack underflow" ); #endif return m_data[ m_top - 1 ]; diff -ruN MHT_Orig/TRACKING/mht/tree.c MHT/TRACKING/mht/tree.c --- MHT_Orig/TRACKING/mht/tree.c 1995-04-27 09:27:02.000000000 -0500 +++ MHT/TRACKING/mht/tree.c 2009-12-04 11:35:09.000000000 -0600 @@ -50,8 +50,6 @@ TREEnode *TREEnode::XgetFirstLeaf() const { - BGN - TREEnode const*node; for( node = this; ! node->isLeaf(); node = node->XgetFirstChild() ) @@ -67,8 +65,6 @@ TREEnode *TREEnode::XgetLastLeaf() const { - BGN - TREEnode const*node; for( node = this; ! node->isLeaf(); node = node->XgetLastChild() ) @@ -84,7 +80,7 @@ TREEnode *TREEnode::XgetRoot() const { - BGN + TREEnode const*node; @@ -105,7 +101,7 @@ TREEnode *TREEnode::XgetPreOrderNext() const { - BGN + TREEnode const*node; @@ -130,7 +126,7 @@ TREEnode *TREEnode::XgetPostOrderNext() const { - BGN + TREEnode const*node; @@ -149,7 +145,7 @@ void TREEnode::XinsertParent( TREEnode *node ) { - BGN + node->m_parent = m_parent; Xprepend( node ); @@ -167,7 +163,7 @@ int TREEnode::getDepth() const { - BGN + TREEnode const*node; int depth; @@ -198,31 +194,31 @@ DLISTnode::check(); checkNotOnList(); - if( ! m_childList.isEmpty() ) - THROW_ERR( "Tree node has children but isn't on tree" ) + assert( m_childList.isEmpty() ); + // THROW_ERR( "Tree node has children but isn't on tree" ) return; } for( node = this; node->isNode(); node = node->m_parent ) { - if( node->m_parent == node ) - THROW_ERR( "Tree node has children but isn't on tree" ) + assert( node->m_parent != node ); + // THROW_ERR( "Tree node has children but isn't on tree" ) } node->DLISTnode::check(); - if( node->m_parent != node ) - THROW_ERR( "Corrupted tree -- node->m_parent != node" ) - if( ! node->m_childList.isEmpty() && - ! node->m_childList.hasOneMember() ) - THROW_ERR( "Tree has more than one root" ) + assert( node->m_parent == node ); + // THROW_ERR( "Corrupted tree -- node->m_parent != node" ) + assert( node->m_childList.isEmpty() || + node->m_childList.hasOneMember() ); + // THROW_ERR( "Tree has more than one root" ) if( node->m_childList.hasOneMember() ) { node->m_childList.check(); - if( (*node->m_childList).m_parent != node ) - THROW_ERR( "Corrupted tree root -- doesn't point to parent" ) + assert( (*node->m_childList).m_parent == node ); + // THROW_ERR( "Corrupted tree root -- doesn't point to parent" ) (*node->m_childList).XrcrsvCheck(); } } @@ -236,15 +232,15 @@ void TREEnode::XrcrsvCheck() const { - BGN + PTR_INTO_iDLIST_OF< TREEnode > child; m_childList.check(); LOOP_DLIST( child, *(iDLIST_OF< TREEnode > *)&m_childList ) { - if( (*child).m_parent != this ) - THROW_ERR( "Corrupted tree node -- doesn't point to parent" ) + assert( (*child).m_parent == this ); + // THROW_ERR( "Corrupted tree node -- doesn't point to parent" ) (*child).XrcrsvCheck(); } } @@ -256,7 +252,7 @@ void TREEnode::XrcrsvCopy( const TREEnode *node ) { - BGN + TREEnode *newNode; @@ -283,7 +279,7 @@ int TREEbase::getHeight() const { - BGN + int height; TREEnode const*node; @@ -304,14 +300,17 @@ void TREEbase::removeRoot() { - BGN + TREEnode *oldRoot; checkNotEmpty(); oldRoot = XgetRoot(); - oldRoot->checkHasOneChild(); + // I think this check is invalid. + // The splice will work, no matter how many children exists. + // I can't see a reason why there has to be one and only one child. + //oldRoot->checkHasOneChild(); m_vnode.m_childList.splice( oldRoot->m_childList ); delete oldRoot; diff -ruN MHT_Orig/TRACKING/mht/tree.h MHT/TRACKING/mht/tree.h --- MHT_Orig/TRACKING/mht/tree.h 2008-11-24 10:22:55.000000000 -0600 +++ MHT/TRACKING/mht/tree.h 2009-12-04 10:04:25.000000000 -0600 @@ -684,6 +684,7 @@ #include "except.h" #include "list.h" +#include /*-------------------------------------------------------------------* | Declarations of stuff found in this file. @@ -828,58 +829,58 @@ #endif #ifdef TSTBUG - + // NOTE: all assertions have to negate the boolean expression. + // from the original if statements tied to the THROW_ERR statements. void checkOnTree() const - { if( ! isOnTree() ) THROW_ERR( "Node must be on tree" ) } + { assert( isOnTree() );}// THROW_ERR( "Node must be on tree" ) } void checkNotOnTree() const - { if( isOnTree() ) THROW_ERR( "Node mustn't be on tree" ) } + { assert( ! isOnTree() );}// THROW_ERR( "Node mustn't be on tree" ) } void checkIsLeaf() const - { if( ! isLeaf() ) THROW_ERR( "Node must be leaf" ) } + { assert( isLeaf() );}// THROW_ERR( "Node must be leaf" ) } void checkNotLeaf() const - { if( isLeaf() ) THROW_ERR( "Node mustn't be leaf" ) } + { assert( ! isLeaf() );}// THROW_ERR( "Node mustn't be leaf" ) } void checkIsRoot() const - { if( ! isRoot() ) THROW_ERR( "Node must be root" ) } + { assert( isRoot() );}// THROW_ERR( "Node must be root" ) } void checkNotRoot() const - { if( isRoot() ) THROW_ERR( "Node mustn't be root" ) } + { assert( ! isRoot() );}// THROW_ERR( "Node mustn't be root" ) } void checkIsFirstSibling() const { - if( ! isFirstSibling() ) - THROW_ERR( "Node must be first sibling" ) + assert( isFirstSibling() ); + // THROW_ERR( "Node must be first sibling" ) } void checkNotFirstSibling() const { - if( isFirstSibling() ) - THROW_ERR( "Node mustn't be first sibling" ) + assert( ! isFirstSibling() ); + // THROW_ERR( "Node mustn't be first sibling" ) } void checkIsLastSibling() const { - if( ! isLastSibling() ) - THROW_ERR( "Node must be last sibling" ) + assert( isLastSibling() ); + // THROW_ERR( "Node must be last sibling" ) } void checkNotLastSibling() const { - if( isLastSibling() ) - THROW_ERR( "Node mustn't be last sibling" ) + assert( ! isLastSibling() ); + // THROW_ERR( "Node mustn't be last sibling" ) } void checkHasOneChild() const { - if( ! hasOneChild() ) - THROW_ERR( "Node must have one and only one child" ) + assert( hasOneChild() ); + // THROW_ERR( "Node must have one and only one child" ) } void checkNotHasOneChild() const { - if( hasOneChild() ) - THROW_ERR( "Node mustn't have one and only child" ) + assert( ! hasOneChild() ); + // THROW_ERR( "Node mustn't have one and only child" ) } #else - void checkOnTree() const {} void checkNotOnTree() const {} void checkIsLeaf() const {} @@ -892,7 +893,6 @@ void checkNotLastSibling() const {} void checkHasOneChild() const {} void checkNotHasOneChild() const {} - #endif private: @@ -927,7 +927,7 @@ protected: virtual DLISTnode *XmakeCopy() const - { BGN return new dummyTREEnode( *this ); } + { return new dummyTREEnode( *this ); } public: @@ -946,39 +946,39 @@ #define MEMBERS_FOR_TREEnode( TYPE ) \ TYPE *getParent() const \ - { BGN checkNotRoot(); return (TYPE *)XgetParent(); } \ + { checkNotRoot(); return (TYPE *)XgetParent(); } \ TYPE *getPrevSibling() const \ - { BGN checkNotFirstSibling(); return (TYPE *)XgetPrevSibling(); } \ + { checkNotFirstSibling(); return (TYPE *)XgetPrevSibling(); } \ TYPE *getNextSibling() const \ - { BGN checkNotLastSibling(); return (TYPE *)XgetNextSibling(); } \ + { checkNotLastSibling(); return (TYPE *)XgetNextSibling(); } \ TYPE *getFirstChild() const \ - { BGN checkNotLeaf(); return (TYPE *)XgetFirstChild(); } \ + { checkNotLeaf(); return (TYPE *)XgetFirstChild(); } \ TYPE *getLastChild() const \ - { BGN checkNotLeaf(); return (TYPE *)XgetLastChild(); } \ + { checkNotLeaf(); return (TYPE *)XgetLastChild(); } \ TYPE *getFirstLeaf() const \ - { BGN checkOnTree(); return (TYPE *)XgetFirstLeaf(); } \ + { checkOnTree(); return (TYPE *)XgetFirstLeaf(); } \ TYPE *getLastLeaf() const \ - { BGN checkOnTree(); return (TYPE *)XgetLastLeaf(); } \ + { checkOnTree(); return (TYPE *)XgetLastLeaf(); } \ TYPE *getRoot() const \ - { BGN checkOnTree(); return (TYPE *)XgetRoot(); } \ + { checkOnTree(); return (TYPE *)XgetRoot(); } \ TYPE *getPreOrderNext() const \ - { BGN checkOnTree(); return (TYPE *)XgetPreOrderNext(); } \ + { checkOnTree(); return (TYPE *)XgetPreOrderNext(); } \ TYPE *getPostOrderNext() const \ - { BGN checkOnTree(); return (TYPE *)XgetPostOrderNext(); } \ + { checkOnTree(); return (TYPE *)XgetPostOrderNext(); } \ void insertParent( TYPE *node ) \ - { BGN checkOnTree(); XinsertParent( node ); } \ + { checkOnTree(); XinsertParent( node ); } \ void insertPrevSibling( TYPE *node ) \ - { BGN checkOnTree(); checkNotRoot(); XinsertPrevSibling( node ); }\ + { checkOnTree(); checkNotRoot(); XinsertPrevSibling( node ); }\ void insertNextSibling( TYPE *node ) \ - { BGN checkOnTree(); checkNotRoot(); XinsertNextSibling( node ); }\ + { checkOnTree(); checkNotRoot(); XinsertNextSibling( node ); }\ void insertFirstChild( TYPE *node ) \ - { BGN checkOnTree(); XinsertFirstChild( node ); } \ + { checkOnTree(); XinsertFirstChild( node ); } \ void insertLastChild( TYPE *node ) \ - { BGN checkOnTree(); XinsertLastChild( node ); } \ + { checkOnTree(); XinsertLastChild( node ); } \ TYPE *makeCopy() const \ - { BGN return (TYPE *)XmakeCopy(); } \ + { return (TYPE *)XmakeCopy(); } \ virtual DLISTnode *XmakeCopy() const \ - { BGN return new TYPE( *this ); } \ + { return new TYPE( *this ); } \ /*-------------------------------------------------------------------* | TREEbase -- base class for all trees @@ -996,7 +996,7 @@ TREEbase(): m_vnode() {} TREEbase( const TREEbase &tree ): m_vnode() - { BGN XcopyTree( tree ); } + { XcopyTree( tree ); } virtual ~TREEbase() {} @@ -1026,9 +1026,9 @@ #ifdef TSTBUG void checkEmpty() const - { if( ! isEmpty() ) THROW_ERR( "Tree must be empty" ) } + { assert( isEmpty() );}// THROW_ERR( "Tree must be empty" ); } void checkNotEmpty() const - { if( isEmpty() ) THROW_ERR( "Tree mustn't be empty" ) } + { assert( ! isEmpty() );}// THROW_ERR( "Tree mustn't be empty" ); } #else void checkEmpty() const {} void checkNotEmpty() const {} @@ -1050,7 +1050,7 @@ TREEtmplt( const TREEtmplt< TYPE > &tree ): \ TREEbase( tree ) {} \ TREEtmplt< TYPE > &operator=( const TREEtmplt< TYPE > &tree ) \ - { BGN removeAll(); XcopyTree( tree ); return *this; } \ + { removeAll(); XcopyTree( tree ); return *this; } \ /*-------------------------------------------------------------------* | PTR_INTO_TREEbase -- base class for all PTR_INTO_xTREE's @@ -1101,7 +1101,6 @@ m_dummy(), m_ptr( ptr.m_ptr ) { - BGN ptr.checkNotRemoved(); } @@ -1148,21 +1147,19 @@ int isEqualTo( const PTR_INTO_TREEbase &ptr ) const { return m_ptr == ptr.m_ptr; } - int getDepth() { BGN return m_ptr->getDepth(); } + int getDepth() { return m_ptr->getDepth(); } - void gotoParent() { BGN m_ptr = m_ptr->XgetParent(); } - void gotoPrevSibling() { BGN m_ptr = m_ptr->XgetPrevSibling(); } - void gotoNextSibling() { BGN m_ptr = m_ptr->XgetNextSibling(); } - void gotoFirstChild() { BGN m_ptr = m_ptr->XgetFirstChild(); } - void gotoLastChild() { BGN m_ptr = m_ptr->XgetLastChild(); } - void gotoPreOrderNext() { BGN m_ptr = m_ptr->XgetPreOrderNext(); } + void gotoParent() { m_ptr = m_ptr->XgetParent(); } + void gotoPrevSibling() { m_ptr = m_ptr->XgetPrevSibling(); } + void gotoNextSibling() { m_ptr = m_ptr->XgetNextSibling(); } + void gotoFirstChild() { m_ptr = m_ptr->XgetFirstChild(); } + void gotoLastChild() { m_ptr = m_ptr->XgetLastChild(); } + void gotoPreOrderNext() { m_ptr = m_ptr->XgetPreOrderNext(); } void gotoPostOrderNext() - { BGN m_ptr = m_ptr->XgetPostOrderNext(); } + { m_ptr = m_ptr->XgetPostOrderNext(); } void removeSubtree() { - BGN - checkValid(); m_dummy.XcopyLinks( *m_ptr ); @@ -1171,94 +1168,93 @@ } #ifdef TSTBUG - + // NOTE: The boolean in the assertions needed to be negated from the original + // boolean for the ifs that were tied to the THROW_ERR statements. void checkInitialized() const { - if( ! isInitialized() ) - THROW_ERR( "Pointer into tree must be initialized" ) + assert( isInitialized() ); + // THROW_ERR( "Pointer into tree must be initialized" ); } void checkNotInitialized() const { - if( isInitialized() ) - THROW_ERR( "Pointer into tree mustn't be initialized" ) + assert( ! isInitialized() ); + // THROW_ERR( "Pointer into tree mustn't be initialized" ); } void checkValid() const { - if( ! isValid() ) - THROW_ERR( "Pointer into tree must be valid" ) + assert( isValid() ); + // THROW_ERR( "Pointer into tree must be valid" ); } void checkNotValid() const { - if( isValid() ) - THROW_ERR( "Pointer into tree mustn't be valid" ) + assert( ! isValid() ); + // THROW_ERR( "Pointer into tree mustn't be valid" ); } void checkRemoved() const { - if( ! isRemoved() ) - THROW_ERR( "Pointer into tree must point to removed node" ) + assert( isRemoved() ); + // THROW_ERR( "Pointer into tree must point to removed node" ); } void checkNotRemoved() const { - if( isRemoved() ) - THROW_ERR( "Pointer into tree mustn't point to " - "removed node" ) + assert( ! isRemoved() ); + // THROW_ERR( "Pointer into tree mustn't point to removed node" ); } void checkIsAtRoot() const { - if( ! isAtRoot() ) - THROW_ERR( "Pointer into tree must be at root" ) + assert( isAtRoot() ); + // THROW_ERR( "Pointer into tree must be at root" ); } void checkNotAtRoot() const { - if( isAtRoot() ) - THROW_ERR( "Pointer into tree mustn't be at root" ) + assert( ! isAtRoot() ); + //THROW_ERR( "Pointer into tree mustn't be at root" ); } void checkIsAtFirstSibling() const { - if( ! isAtFirstSibling() ) - THROW_ERR( "Pointer into tree must be at first sibling" ) + assert( isAtFirstSibling() ); + //THROW_ERR( "Pointer into tree must be at first sibling" ); } void checkNotAtFirstSibling() const { - if( isAtFirstSibling() ) - THROW_ERR( "Pointer into tree mustn't be at first sibling" ) + assert( ! isAtFirstSibling() ); + //THROW_ERR( "Pointer into tree mustn't be at first sibling" ); } void checkIsAtLastSibling() const { - if( ! isAtLastSibling() ) - THROW_ERR( "Pointer into tree must be at last sibling" ) + assert( isAtLastSibling() ); + //THROW_ERR( "Pointer into tree must be at last sibling" ) } void checkNotAtLastSibling() const { - if( isAtLastSibling() ) - THROW_ERR( "Pointer into tree mustn't be at last sibling" ) + assert( ! isAtLastSibling() ); + //THROW_ERR( "Pointer into tree mustn't be at last sibling" ) } void checkIsAtLeaf() const { - if( ! isAtLastSibling() ) - THROW_ERR( "Pointer into tree must be at leaf" ) + assert( isAtLastSibling() ); + // THROW_ERR( "Pointer into tree must be at leaf" ) } void checkNotAtLeaf() const { - if( isAtLastSibling() ) - THROW_ERR( "Pointer into tree mustn't be at leaf" ) + assert( ! isAtLastSibling() ); + // THROW_ERR( "Pointer into tree mustn't be at leaf" ) } #else - void checkInitialized() const {} void checkNotInitialized() const {} void checkValid() const {} @@ -1273,7 +1269,6 @@ void checkNotAtLastSibling() const {} void checkIsAtLeaf() const {} void checkNotAtLeaf() const {} - #endif }; @@ -1296,27 +1291,27 @@ PTRtmplt( const PTRtmplt< TYPE > &ptr ): \ PTR_INTO_TREEbase( ptr ) {} \ void set( TREEtmplt< TYPE > &tree ) \ - { BGN Xset( tree ); } \ + { Xset( tree ); } \ void set( TREEtmplt< TYPE > &tree, START_AT_ROOTversion ) \ - { BGN Xset( tree, START_AT_ROOT ); } \ + { Xset( tree, START_AT_ROOT ); } \ void set( TREEtmplt< TYPE > &tree, START_AT_FIRST_LEAFversion ) \ - { BGN Xset( tree, START_AT_FIRST_LEAF ); } \ + { Xset( tree, START_AT_FIRST_LEAF ); } \ void set( TREEtmplt< TYPE > &tree, START_AT_LAST_LEAFversion ) \ - { BGN Xset( tree, START_AT_LAST_LEAF ); } \ + { Xset( tree, START_AT_LAST_LEAF ); } \ void set( const PTRtmplt< TYPE > &ptr ) \ - { BGN Xset( ptr ); } \ + { Xset( ptr ); } \ PTRtmplt< TYPE > &operator=( TREEtmplt< TYPE > &tree ) \ - { BGN set( tree ); return *this; } \ + { set( tree ); return *this; } \ PTRtmplt< TYPE > &operator=( const PTRtmplt< TYPE > &ptr ) \ - { BGN set( ptr ); return *this; } \ + { set( ptr ); return *this; } \ PTRtmplt< TYPE > &operator++() \ - { BGN gotoNextSibling(); return *this; } \ + { gotoNextSibling(); return *this; } \ PTRtmplt< TYPE > &operator--() \ - { BGN gotoPrevSibling(); return *this; } \ + { gotoPrevSibling(); return *this; } \ int operator==( const PTRtmplt< TYPE > ptr ) const \ - { BGN return isEqualTo( ptr ); } \ + { return isEqualTo( ptr ); } \ int operator!=( const PTRtmplt< TYPE > ptr ) const \ - { BGN return ! isEqualTo( ptr ); } \ + { return ! isEqualTo( ptr ); } \ /*-------------------------------------------------------------------* | Templates for store-by-value trees @@ -1354,32 +1349,26 @@ TYPE *getRoot() const { - BGN - checkNotEmpty(); return &((vTREE_NODE_OF< TYPE > *)XgetRoot())->m_info; } TYPE *getFirstLeaf() const { - BGN - checkNotEmpty(); return &((vTREE_NODE_OF< TYPE > *)XgetFirstLeaf())->m_info; } TYPE *getLastLeaf() const { - BGN - checkNotEmpty(); return &((vTREE_NODE_OF< TYPE > *)XgetLastLeaf())->m_info; } void insertRoot( const TYPE &info ) - { BGN XinsertRoot( new vTREE_NODE_OF< TYPE >( info ) ); } + { XinsertRoot( new vTREE_NODE_OF< TYPE >( info ) ); } TYPE &operator*() const - { BGN return *getRoot(); } + { return *getRoot(); } }; template< class TYPE > @@ -1395,53 +1384,41 @@ TYPE *get() const { - BGN - checkValid(); return &((vTREE_NODE_OF< TYPE > *)Xget())->m_info; } void insertParent( const TYPE &info ) { - BGN - checkValid(); XinsertParent( new vTREE_NODE_OF< TYPE >( info ) ); } void insertPrevSibling( const TYPE &info ) { - BGN - checkValid(); XinsertPrevSibling( new vTREE_NODE_OF< TYPE >( info ) ); } void insertNextSibling( const TYPE &info ) { - BGN - checkValid(); XinsertNextSibling( new vTREE_NODE_OF< TYPE >( info ) ); } void insertFirstChild( const TYPE &info ) { - BGN - checkValid(); XinsertFirstChild( new vTREE_NODE_OF< TYPE >( info ) ); } void insertLastChild( const TYPE &info ) { - BGN - checkValid(); XinsertLastChild( new vTREE_NODE_OF< TYPE >( info ) ); } - TYPE &operator*() const { BGN return *get(); } + TYPE &operator*() const { return *get(); } }; /*-------------------------------------------------------------------* @@ -1480,32 +1457,26 @@ TYPE *getRoot() const { - BGN - checkNotEmpty(); return ((ptrTREE_NODE_OF< TYPE > *)XgetRoot())->m_info; } TYPE *getFirstLeaf() const { - BGN - checkNotEmpty(); return ((ptrTREE_NODE_OF< TYPE > *)XgetFirstLeaf())->m_info; } TYPE *getLastLeaf() const { - BGN - checkNotEmpty(); return ((ptrTREE_NODE_OF< TYPE > *)XgetLastLeaf())->m_info; } void insertRoot( TYPE &info ) - { BGN XinsertRoot( new ptrTREE_NODE_OF< TYPE >( info ) ); } + { XinsertRoot( new ptrTREE_NODE_OF< TYPE >( info ) ); } TYPE &operator*() const - { BGN return *getRoot(); } + { return *getRoot(); } }; template< class TYPE > @@ -1521,53 +1492,41 @@ TYPE *get() const { - BGN - checkValid(); return ((ptrTREE_NODE_OF< TYPE > *)Xget())->m_info; } void insertParent( TYPE &info ) { - BGN - checkValid(); XinsertParent( new ptrTREE_NODE_OF< TYPE >( info ) ); } void insertPrevSibling( TYPE &info ) { - BGN - checkValid(); XinsertPrevSibling( new ptrTREE_NODE_OF< TYPE >( info ) ); } void insertNextSibling( TYPE &info ) { - BGN - checkValid(); XinsertNextSibling( new ptrTREE_NODE_OF< TYPE >( info ) ); } void insertFirstChild( TYPE &info ) { - BGN - checkValid(); XinsertFirstChild( new ptrTREE_NODE_OF< TYPE >( info ) ); } void insertLastChild( TYPE &info ) { - BGN - checkValid(); XinsertLastChild( new ptrTREE_NODE_OF< TYPE >( info ) ); } - TYPE &operator*() const { BGN return *get(); } + TYPE &operator*() const { return *get(); } }; /*-------------------------------------------------------------------* @@ -1582,15 +1541,15 @@ MEMBERS_FOR_TREEbase( iTREE_OF, TYPE ) TYPE *getRoot() const - { BGN checkNotEmpty(); return (TYPE *)XgetRoot(); } + { checkNotEmpty(); return (TYPE *)XgetRoot(); } TYPE *getFirstLeaf() const - { BGN checkNotEmpty(); return (TYPE *)XgetFirstLeaf(); } + { checkNotEmpty(); return (TYPE *)XgetFirstLeaf(); } TYPE *getLastLeaf() const - { BGN checkNotEmpty(); return (TYPE *)XgetLastLeaf(); } + { checkNotEmpty(); return (TYPE *)XgetLastLeaf(); } void insertRoot( TYPE *node ) - { BGN XinsertRoot( node ); } + { XinsertRoot( node ); } TYPE &operator*() const - { BGN return *getRoot(); } + { return *getRoot(); } }; template< class TYPE > @@ -1605,33 +1564,31 @@ PTR_INTO_iTREE_OF( TYPE *node ): PTR_INTO_TREEbase( node ) { - BGN - node->checkOnTree(); } operator TYPE*() { return get(); } TYPE *get() const - { BGN checkValid(); return (TYPE *)Xget(); } + { checkValid(); return (TYPE *)Xget(); } void set( TYPE *ptr ) - { BGN Xset( ptr ); } + { Xset( ptr ); } void insertParent( TYPE *node ) - { BGN checkValid(); XinsertParent( node ); } + { checkValid(); XinsertParent( node ); } void insertPrevSibling( TYPE *node ) - { BGN checkValid(); XinsertPrevSibling( node ); } + { checkValid(); XinsertPrevSibling( node ); } void insertNextSibling( TYPE *node ) - { BGN checkValid(); XinsertNextSibling( node ); } + { checkValid(); XinsertNextSibling( node ); } void insertFirstChild( TYPE *node ) - { BGN checkValid(); XinsertFirstChild( node ); } + { checkValid(); XinsertFirstChild( node ); } void insertLastChild( TYPE *node ) - { BGN checkValid(); XinsertLastChild( node ); } + { checkValid(); XinsertLastChild( node ); } TYPE &operator*() const - { BGN return *get(); } + { return *get(); } int operator==( const TYPE *ptr ) const - { BGN return isEqualTo( ptr ); } + { return isEqualTo( ptr ); } int operator!=( const TYPE *ptr ) const - { BGN return ! isEqualTo( ptr ); } + { return ! isEqualTo( ptr ); } }; /*-------------------------------------------------------------------* diff -ruN MHT_Orig/TRACKING/mht/vector.h MHT/TRACKING/mht/vector.h --- MHT_Orig/TRACKING/mht/vector.h 1995-04-27 09:27:02.000000000 -0500 +++ MHT/TRACKING/mht/vector.h 2009-12-04 12:38:47.000000000 -0600 @@ -82,6 +82,8 @@ #define VECTOR_H #include "except.h" +#include +#include // for memset() template< class TYPE > class VECTOR_OF @@ -125,21 +127,17 @@ ~VECTOR_OF() { - BGN - delete [] m_buf; } TYPE &operator[]( int index ) { - BGN - #ifdef TSTBUG - if( m_buf == 0 ) - THROW_ERR( "Trying to index into unallocated vector" ) - if( m_lowIndex > index || index > m_highIndex ) - THROW_ERR( "Index " << index - << " out of bounds in vector" ) + // NOTE: the assertion booleans have been negated from their original if statements. + assert( m_buf != 0 ); + // THROW_ERR("Trying to index into unallocated vector") + assert( m_lowIndex <= index && index <= m_highIndex ); + // THROW_ERR("Index out of bounds in vector" << index ) #endif return m_data[ index ]; @@ -147,8 +145,6 @@ void resize( int highIndex ) { - BGN - int newSize = highIndex + 1; if( newSize > m_size ) @@ -165,8 +161,6 @@ void resize( int lowIndex, int highIndex ) { - BGN - int newSize = highIndex - lowIndex + 1; if( newSize > m_size ) @@ -183,8 +177,6 @@ void clear() { - BGN - if( m_buf != 0 ) memset( m_buf, 0, (m_highIndex - m_lowIndex + 1) * sizeof( TYPE ) ); diff -ruN MHT_Orig/TRACKING/tracking/makefile MHT/TRACKING/tracking/makefile --- MHT_Orig/TRACKING/tracking/makefile 2008-11-25 04:27:44.000000000 -0600 +++ MHT/TRACKING/tracking/makefile 2009-12-04 13:19:40.000000000 -0600 @@ -16,15 +16,14 @@ C++ = g++ #C++FLAGS = -O #C++FLAGS = -O -D__SGICC__ -DSDBG -C++FLAGS = -O -I../mht +C++FLAGS = -O -I$(INC) build = $(C++) $(C++FLAGS) -o $@ touch = touch $@ trackCorners: param.h motionModel.h $(INC)/assign.h \ - trackCorners.o motionModel.o - $(build) trackCorners.o motionModel.o \ - -L../mht -lmht -lm + trackCorners.o motionModel.o $(INC)/libmht.a + $(build) trackCorners.o motionModel.o -L$(INC) -lmht -lm motionModel.o: motionModel.c motionModel.h param.h \ $(INC)/except.h $(INC)/mdlmht.h $(INC)/matrix.h\ diff -ruN MHT_Orig/TRACKING/tracking/motionModel.c MHT/TRACKING/tracking/motionModel.c --- MHT_Orig/TRACKING/tracking/motionModel.c 2008-11-24 10:58:37.000000000 -0600 +++ MHT/TRACKING/tracking/motionModel.c 2009-12-03 23:21:04.000000000 -0600 @@ -80,7 +80,7 @@ CORNER_TRACK *findTrack( int id ) { -BGN + PTR_INTO_iDLIST_OF< CORNER_TRACK > p; CORNER_TRACK *newTrack; @@ -119,7 +119,7 @@ double logLikelihood, int modelType, int frame) { -BGN + CORNER_TRACK *track; // printf("Verifying trackId=%d r_x=%lf r_y=%lf s_x=%lf s_y=%lf frame=%d\n", @@ -136,7 +136,7 @@ void CORNER_TRACK_MHT::measure() { -BGN + PTR_INTO_ptrDLIST_OF< T_HYPO > tHypoPtr; PTR_INTO_iDLIST_OF< CORNER > cornerPtr; @@ -179,7 +179,7 @@ void CONSTVEL_STATE::setup( double processVariance, const MATRIX &R ) { - BGN + /* don't do this more than once */ if( m_hasBeenSetup ) @@ -311,7 +311,7 @@ MDL_STATE *mdlState, MDL_REPORT *mdlReport ) { -BGN + CONSTVEL_STATE *state = (CONSTVEL_STATE *) mdlState; CONSTPOS_REPORT *report = (CONSTPOS_REPORT *) mdlReport; double dx,dy; @@ -335,7 +335,7 @@ return (MDL_STATE*) newState; } default: - THROW_ERR("Too many calls to CONSTVEL_MDL::getNewState()"); + assert(false);//("Too many calls to CONSTVEL_MDL::getNewState()"); } } @@ -603,7 +603,7 @@ m_R( 2, 2 ), m_startP( 4, 4 ) { - BGN + printf("\nSTARTING A NEW CONSTVEL_MDL\n"); double pVx = positionMeasureVarianceX; @@ -641,7 +641,7 @@ int getTrackColor( int trackId ) { - BGN + static unsigned char color[] = { @@ -654,7 +654,7 @@ void CORNER_TRACK_MHT::describe(int spaces) { - BGN + PTR_INTO_ptrDLIST_OF< T_HYPO > tHypoPtr; PTR_INTO_iDLIST_OF< GROUP > groupPtr; @@ -840,10 +840,10 @@ } } corr = corr / (9.0 * reportSigma * stateSigma); - if (corr < -1.0 || corr > 1.0) { - fprintf(stderr, "Error in corr calculation\n"); - exit(1); - } + assert(corr >= -1.0 && corr <= 1.0);// { + // fprintf(stderr, "Error in corr calculation\n"); + // exit(1); + // } if (corr > maxCorr) maxCorr = corr; #ifdef DEBUG3 diff -ruN MHT_Orig/TRACKING/tracking/motionModel.h MHT/TRACKING/tracking/motionModel.h --- MHT_Orig/TRACKING/tracking/motionModel.h 2008-11-24 10:51:18.000000000 -0600 +++ MHT/TRACKING/tracking/motionModel.h 2009-12-03 23:18:43.000000000 -0600 @@ -215,7 +215,6 @@ m_frameNo(f) { -BGN m_z.set( x, y); m_int[0] = i1; m_int[4] = i5; m_int[1] = i2; m_int[5] = i6; @@ -523,7 +522,7 @@ void cleanup() { - BGN + if( m_hasBeenSetup ) { @@ -543,19 +542,19 @@ int getNumSkipped() { return m_numSkipped;} double getLogLikelihoodCoef() - { BGN checkSetup(); return m_logLikelihoodCoef; } - MATRIX &getPrediction() { BGN checkSetup(); return *m_x1; } - MATRIX &getNextP() { BGN checkSetup(); return *m_nextP; } - MATRIX &getSinv() { BGN checkSetup(); return *m_Sinv; } - MATRIX &getW() { BGN checkSetup(); return *m_W; } + { checkSetup(); return m_logLikelihoodCoef; } + MATRIX &getPrediction() { checkSetup(); return *m_x1; } + MATRIX &getNextP() { checkSetup(); return *m_nextP; } + MATRIX &getSinv() { checkSetup(); return *m_Sinv; } + MATRIX &getW() { checkSetup(); return *m_W; } #ifdef TSTBUG void checkSetup() { - if( ! m_hasBeenSetup ) - THROW_ERR( "Trying to get derived info from a CONSTPOS state" - " that hasn't been setup()" ) + assert( m_hasBeenSetup ); + // THROW_ERR( "Trying to get derived info from a CONSTPOS state" + // " that hasn't been setup()" ) } #else @@ -577,12 +576,12 @@ void setDX(double val) { m_x( 1 )=val; } void setDY(double val) { m_x( 3 )=val; } - double getX1() { BGN checkSetup(); return (*m_x1)( 0 ); } - double getDX1() { BGN checkSetup(); return (*m_x1)( 1 ); } - double getY1() { BGN checkSetup(); return (*m_x1)( 2 ); } - double getDY1() { BGN checkSetup(); return (*m_x1)( 3 ); } + double getX1() { checkSetup(); return (*m_x1)( 0 ); } + double getDX1() { checkSetup(); return (*m_x1)( 1 ); } + double getY1() { checkSetup(); return (*m_x1)( 2 ); } + double getDY1() { checkSetup(); return (*m_x1)( 3 ); } - double getDS() { BGN checkSetup(); return m_ds; } + double getDS() { checkSetup(); return m_ds; } }; /*-------------------------------------------------------------------* diff -ruN MHT_Orig/TRACKING/tracking/trackCorners.c MHT/TRACKING/tracking/trackCorners.c --- MHT_Orig/TRACKING/tracking/trackCorners.c 2008-11-24 10:53:33.000000000 -0600 +++ MHT/TRACKING/tracking/trackCorners.c 2009-12-04 13:55:04.000000000 -0600 @@ -1,10 +1,12 @@ -#include -#include +#include +#include #include -#include +#include +#include // for std::cout, std::endl, std::cerr #include "param.h" // contains values of needed parameters #include "motionModel.h" +#include // for std::runtime_error /* * External Variables */ @@ -18,8 +20,8 @@ int main(int argc, char **argv) { - void read_param(char*); - void writeCornerTrackFile(char *name); + void read_param(const char*); + void writeCornerTrackFile(const char *name); void readCorners(iDLIST_OF *in); int numPixels; iDLIST_OF *inputData; @@ -31,7 +33,7 @@ if ( argc < 2 ) { - std::cerr<<"Usage:"<< argv[0]<<" OutDataFile -p paramFile"<< "InDataFile" << std::endl; + std::cerr<<"Usage:"<< argv[0]<<" OutDataFile -p paramFile < InDataFile" << std::endl; exit( -1 ); } @@ -49,13 +51,13 @@ * Read the parameters */ - char *paramFile; + const char *paramFile; if (argc > 2) { if (argv[2][0] =='-' && argv[2][1] == 'p') paramFile = argv[3]; printf("%s %s\n",argv[3],paramFile); } else { - paramFile="Parameters"; + paramFile = "Parameters"; } read_param(paramFile); @@ -160,18 +162,21 @@ * a comment. So skip the comments. *----------------------------------------------------------*/ -void read_param(char* paramFile) +void read_param(const char* paramFile) { -BGN + FILE *fp; fp = fopen( paramFile, "r" ); // cout << "Open Parameter File :" < *inputData) { -BGN + int i; PTR_INTO_iDLIST_OF cptr; PTR_INTO_iDLIST_OF ptr; @@ -452,6 +457,12 @@ sprintf(fname,"%s.%d",basename,i++); // printf("Reading file %s\n",fname); inDataFile = fopen( fname, "r" ); + + if (inDataFile <= 0) + { + throw std::runtime_error("Could not open the input data file...\n"); + } + int j=0; while (fgets(str,strSize,inDataFile) && j