<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Speed Test for Both Simple and Fast Representations</title>
<meta name="description" id="description" content="Speed Test for Both Simple and Fast Representations"/>
<meta name="keywords" id="keywords" content=" "/>
<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='_ipopt_ode_speed.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="ipopt_nlp_ode_check.cpp.xml" target="_top">Prev</a>
</td><td><a href="old_atomic.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>Appendix</option>
<option>deprecated</option>
<option>cppad_ipopt_nlp</option>
<option>ipopt_ode_speed.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>Appendix-&gt;</option>
<option>Faq</option>
<option>Theory</option>
<option>glossary</option>
<option>Bib</option>
<option>Bugs</option>
<option>WishList</option>
<option>whats_new</option>
<option>deprecated</option>
<option>compare_c</option>
<option>License</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>deprecated-&gt;</option>
<option>include_deprecated</option>
<option>FunDeprecated</option>
<option>omp_max_thread</option>
<option>TrackNewDel</option>
<option>omp_alloc</option>
<option>memory_leak</option>
<option>epsilon</option>
<option>test_vector</option>
<option>cppad_ipopt_nlp</option>
<option>old_atomic</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>cppad_ipopt_nlp-&gt;</option>
<option>ipopt_nlp_get_started.cpp</option>
<option>ipopt_nlp_ode</option>
<option>ipopt_ode_speed.cpp</option>
</select>
</td>
<td>ipopt_ode_speed.cpp</td>
<td>Headings</td>
</tr></table><br/>


<center><b><big><big>Speed Test for Both Simple and Fast Representations</big></big></b></center>
<code><font color="blue"><pre style='display:inline'> 
# include &quot;../example/ode_run.hpp&quot;
# include &quot;../example/ode_simple.hpp&quot;
# include &quot;../example/ode_fast.hpp&quot;
# include &lt;cassert&gt;
# include &lt;cstring&gt;

# if CPPAD_HAS_GETTIMEOFDAY &amp; CPPAD_NO_MICROSOFT
# include &lt;sys/time.h&gt;
# else
# include &lt;ctime&gt;
# endif

namespace {
	double current_second(void)
	{
# if CPPAD_HAS_GETTIMEOFDAY &amp; CPPAD_NOT_MICOROSOFT
		struct timeval value;
		gettimeofday(&amp;value, 0);
		return double(value.tv_sec) + double(value.tv_usec) * 1e-6;
# else
		return (double) clock() / (double) CLOCKS_PER_SEC;
# endif
	}
}

double ode_speed(const char* name, size_t&amp; count)
{
	// determine simple and retape flags
	bool simple = true, retape = true;
	if( std::strcmp(name, &quot;simple_retape_no&quot;) == 0 )
	{	simple = true; retape = false; }
	else if( std::strcmp(name, &quot;simple_retape_yes&quot;) == 0 )
	{	simple = true; retape = true; }
	else if( std::strcmp(name, &quot;fast_retape_no&quot;) == 0 )
	{	simple = false; retape = false; }
	else if( std::strcmp(name, &quot;fast_retape_yes&quot;) == 0 )
	{	simple = false; retape = true; }
	else	assert(false);

	size_t i;
        double s0, s1;
	size_t  c0, c1;

	// solution vector
	NumberVector x;

	// number of time grid intervals between measurement values
	SizeVector N(Nz + 1);
	N[0] = 0;
	for(i = 1; i &lt;= Nz; i++)
	{	N[i] = 10;
		// n   += N[i] * Ny;
	}
	// n += Na;

	s0              = current_second();
	c0              = count_eval_r();
	if( simple )
		ipopt_ode_case&lt;FG_simple&gt;(retape, N, x);
	else	ipopt_ode_case&lt;FG_fast&gt;(retape, N, x);
	s1              = current_second();
	c1              = count_eval_r();
	count           = c1 - c0 - 1;
	return s1 - s0;
}
</pre>

</font></code>


<hr/>Input File: cppad_ipopt/speed/ode_speed.cpp

</body>
</html>
