Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 39da2e642be5eb48375f19991c31eb2c > files > 732

cppad-doc-20100101.4-1.fc14.noarch.rpm

<?xml version='1.0'?>
<?xml-stylesheet type='text/xsl' href='pmathml.xsl'?>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Program That Runs the Speed Examples</title>
<meta name="description" id="description" content="Program That Runs the Speed Examples"/>
<meta name="keywords" id="keywords" content=" speed example program "/>
<style type='text/css'>
body { color : black }
body { background-color : white }
A:link { color : blue }
A:visited { color : purple }
A:active { color : purple }
</style>
<script type='text/javascript' language='JavaScript' src='_speed_example.cpp_xml.js'>
</script>
</head>
<body>
<table><tr>
<td>
<a href="http://www.coin-or.org/CppAD/" target="_top"><img border="0" src="_image.gif"/></a>
</td>
<td><a href="example.cpp.xml" target="_top">Prev</a>
</td><td><a href="luvecad.xml" target="_top">Next</a>
</td><td>
<select onchange='choose_across0(this)'>
<option>Index-&gt;</option>
<option>contents</option>
<option>reference</option>
<option>index</option>
<option>search</option>
<option>external</option>
</select>
</td>
<td>
<select onchange='choose_up0(this)'>
<option>Up-&gt;</option>
<option>CppAD</option>
<option>Example</option>
<option>ExampleUtility</option>
<option>speed_example.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>CppAD-&gt;</option>
<option>Install</option>
<option>Introduction</option>
<option>AD</option>
<option>ADFun</option>
<option>library</option>
<option>Example</option>
<option>configure</option>
<option>Appendix</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>Example-&gt;</option>
<option>General</option>
<option>ExampleUtility</option>
<option>ListAllExamples</option>
<option>test_vector</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>ExampleUtility-&gt;</option>
<option>Example.cpp</option>
<option>speed_example.cpp</option>
<option>LuVecAD</option>
</select>
</td>
<td>speed_example.cpp</td>
<td>Headings</td>
</tr></table><br/>








<center><b><big><big>Program That Runs the Speed Examples</big></big></b></center>
<code><font color="blue"><pre style='display:inline'> 

# include &lt;cppad/cppad.hpp&gt;

// various example routines
extern bool det_of_minor(void);
extern bool det_by_lu(void);
extern bool det_by_minor(void);
extern bool ode_evaluate(void);
extern bool sparse_evaluate(void);
extern bool speed_test(void);

namespace {
	// function that runs one test
	static size_t Run_ok_count    = 0;
	static size_t Run_error_count = 0;
	bool Run(bool TestOk(void), std::string name)
	{	bool ok      = true;
		size_t width =  20;         
		std::cout.width( width );
		std::cout.setf( std::ios_base::left );
		std::cout &lt;&lt; name;
		//
		ok &amp;= name.size() &lt; width;
		ok &amp;= TestOk();
		if( ok )
		{	std::cout &lt;&lt; &quot;OK&quot; &lt;&lt; std::endl;
			Run_ok_count++;
		}
		else
		{	std::cout &lt;&lt; &quot;Error&quot; &lt;&lt; std::endl;
			Run_error_count++;
		}
		return ok;
	}
}

// main program that runs all the tests
int main(void)
{	bool ok = true;
	using std::cout;
	using std::endl;

	ok &amp;= Run(det_of_minor,          &quot;det_of_minor&quot;   );
	ok &amp;= Run(det_by_minor,         &quot;det_by_minor&quot;    );
	ok &amp;= Run(det_by_lu,               &quot;det_by_lu&quot;    );
	ok &amp;= Run(ode_evaluate,         &quot;ode_evaluate&quot;    );
	ok &amp;= Run(sparse_evaluate,   &quot;sparse_evaluate&quot;    );

	// check for memory leak in previous calculations
	if( CPPAD_TRACK_COUNT() != 0 )
		cout &lt;&lt; &quot;Error: memroy leak detected&quot; &lt;&lt; endl;

	assert( ok || (Run_error_count &gt; 0) );
	if( ok )
		cout &lt;&lt; &quot;The &quot; &lt;&lt; int(Run_ok_count) &lt;&lt; &quot; tests above passed.&quot;;
	else	cout &lt;&lt; int(Run_error_count) &lt;&lt; &quot; tests above failed.&quot;;
	cout &lt;&lt; endl;

	bool speed_test_ok = speed_test();
	if( speed_test_ok )
		cout &lt;&lt; &quot;speed_test also passed correctness test&quot; &lt;&lt; endl;
	else
	{	cout &lt;&lt; &quot;speed_test failed its correctness test (OK if &quot;;
		cout &lt;&lt; &quot;other processes are running at same time)&quot; &lt;&lt; endl;
	}

	return static_cast&lt;int&gt;( ! ok );
}
</pre>
</font></code>


<hr/>Input File: speed/example/example.cpp

</body>
</html>