Merged SVN head ...
[libdai.git] / tests / test.cpp
index a4bdcc7..5f24776 100644 (file)
@@ -59,9 +59,12 @@ class TestDAI {
                 q.clear();
                 for( size_t i = 0; i < fg.nrVars(); i++ )
                     q.push_back( Factor(Var(i,2), zero) );
-                logZ = NAN;
+                logZ = 0.0;
                 maxdiff = 0.0;
                 iters = 1;
+                has_logZ = false;
+                has_maxdiff = false;
+                has_iters = false;
             } else
                 obj = newInfAlg( name, fg, opts );
             time += toc() - tic;
@@ -104,8 +107,12 @@ class TestDAI {
                 } catch( Exception &e ) {
                     has_maxdiff = false;
                 }
-                has_iters = false;
-                iters = 0;
+                try {
+                    iters = obj->Iterations();
+                    has_iters = true;
+                } catch( Exception &e ) {
+                    has_iters = false;
+                }
                 q = allBeliefs();
             };
         }
@@ -337,7 +344,7 @@ int main( int argc, char *argv[] ) {
                 }
                 cout.width( 10 );
                 if( piet.has_iters ) {
-                    cout << piet.iters << "  " << endl;
+                    cout << piet.iters << "  ";
                 } else {
                     cout << "N/A         ";
                 }