<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Euclidean Norm Squared: Example and Test</title>
<meta name="description" id="description" content="Euclidean Norm Squared: Example and Test"/>
<meta name="keywords" id="keywords" content=" norm_sq atomic operation Euclidean norm example "/>
<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='_atomic_norm_sq.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="atomic_get_started.cpp.xml" target="_top">Prev</a>
</td><td><a href="atomic_reciprocal.cpp.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>AD</option>
<option>ADValued</option>
<option>atomic</option>
<option>atomic_base</option>
<option>atomic_norm_sq.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>ADValued-&gt;</option>
<option>Arithmetic</option>
<option>std_math_ad</option>
<option>MathOther</option>
<option>CondExp</option>
<option>Discrete</option>
<option>atomic</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>atomic-&gt;</option>
<option>checkpoint</option>
<option>atomic_base</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>atomic_base-&gt;</option>
<option>atomic_ctor</option>
<option>atomic_option</option>
<option>atomic_afun</option>
<option>atomic_forward</option>
<option>atomic_reverse</option>
<option>atomic_for_sparse_jac</option>
<option>atomic_rev_sparse_jac</option>
<option>atomic_rev_sparse_hes</option>
<option>atomic_base_clear</option>
<option>atomic_get_started.cpp</option>
<option>atomic_norm_sq.cpp</option>
<option>atomic_reciprocal.cpp</option>
<option>atomic_tangent.cpp</option>
<option>atomic_mat_mul.cpp</option>
</select>
</td>
<td>atomic_norm_sq.cpp</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Theory</option>
<option>Start Class Definition</option>
<option>Constructor</option>
<option>forward</option>
<option>reverse</option>
<option>for_sparse_jac</option>
<option>rev_sparse_jac</option>
<option>rev_sparse_hes</option>
<option>End Class Definition</option>
<option>Use Atomic Function</option>
<option>---..Constructor</option>
<option>---..Recording</option>
<option>---..forward</option>
<option>---..reverse</option>
<option>---..for_sparse_jac</option>
<option>---..rev_sparse_jac</option>
<option>---..rev_sparse_hes</option>
</select>
</td>
</tr></table><br/>



<center><b><big><big>Euclidean Norm Squared: Example and Test</big></big></b></center>
<br/>
<b><big><a name="Theory" id="Theory">Theory</a></big></b>
<br/>
This example demonstrates using <a href="atomic_base.xml" target="_top"><span style='white-space: nowrap'>atomic_base</span></a>

to define the operation

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>f</mi>
<mo stretchy="false">:</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mi mathvariant='italic'>n</mi>
</msup>
<mo stretchy="false">&#x02192;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mi mathvariant='italic'>m</mi>
</msup>
</mrow></math>

 where

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>n</mi>
<mo stretchy="false">=</mo>
<mn>2</mn>
</mrow></math>

, 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>m</mi>
<mo stretchy="false">=</mo>
<mn>1</mn>
</mrow></math>

, where

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>f</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mn>0</mn>
<mn>2</mn>
</msubsup>
<mo stretchy="false">+</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mn>1</mn>
<mn>2</mn>
</msubsup>
</mrow></math>

<br/>
<b><big><a name="Start Class Definition" id="Start Class Definition">Start Class Definition</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
# include &lt;cppad/cppad.hpp&gt;
namespace {           // isolate items below to this file
using CppAD::vector;  // abbreviate as vector
//
// a utility to compute the union of two sets.
void my_union(
	std::set&lt;size_t&gt;&amp;         result  ,
	const std::set&lt;size_t&gt;&amp;   left    ,
	const std::set&lt;size_t&gt;&amp;   right   )
{	std::set&lt;size_t&gt; temp;
	std::set_union(
		left.begin()              ,
		left.end()                ,
		right.begin()             ,
		right.end()               ,
		std::inserter(temp, temp.begin())
	);
	result.swap(temp);
}
//
class atomic_norm_sq : public CppAD::atomic_base&lt;double&gt; {
</pre></font></code>

<br/>
<br/>
<b><big><a name="Constructor" id="Constructor">Constructor</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
	public:
	// constructor (could use const char* for name)
	atomic_norm_sq(const std::string&amp; name) : 
	CppAD::atomic_base&lt;double&gt;(name)
	{ }
	private:
</pre></font></code>

<br/>
<br/>
<b><big><a name="forward" id="forward">forward</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
	// forward mode routine called by CppAD
	virtual bool forward(
		size_t                    p ,
		size_t                    q ,
		const vector&lt;bool&gt;&amp;      vx ,
		      vector&lt;bool&gt;&amp;      vy ,
		const vector&lt;double&gt;&amp;    tx ,
		      vector&lt;double&gt;&amp;    ty
	)
	{	size_t n = tx.size() / (q+1);
		size_t m = ty.size() / (q+1);
		assert( n == 2 );
		assert( m == 1 );
		assert( p &lt;= q );

		// return flag
		bool ok = q &lt;= 1;

		// Variable information must always be implemented.
		// y_0 is a variable if and only if x_0 or x_1 is a variable.
		if( vx.size() &gt; 0 )
			vy[0] = vx[0] | vx[1];

		// Order zero forward mode must always be implemented.
		// y^0 = f( x^0 ) 
		double x_00 = tx[ 0*(q+1) + 0];        // x_0^0
		double x_10 = tx[ 1*(q+1) + 0];        // x_10
		double f = x_00 * x_00 + x_10 * x_10;  // f( x^0 )
		if( p &lt;= 0 )
			ty[0] = f;   // y_0^0
		if( q &lt;= 0 )
			return ok;
		assert( vx.size() == 0 );

		// Order one forward mode.
		// This case needed if first order forward mode is used.
		// y^1 = f'( x^0 ) x^1
		double x_01 = tx[ 0*(q+1) + 1];   // x_0^1
		double x_11 = tx[ 1*(q+1) + 1];   // x_1^1
		double fp_0 = 2.0 * x_00;         // partial f w.r.t x_0^0
		double fp_1 = 2.0 * x_10;         // partial f w.r.t x_1^0
		if( p &lt;= 1 )
			ty[1] = fp_0 * x_01 + fp_1 * x_11; // f'( x^0 ) * x^1
		if( q &lt;= 1 )
			return ok;

		// Assume we are not using forward mode with order &gt; 1
		assert( ! ok );
		return ok;
	}
</pre></font></code>

<br/>
<br/>
<b><big><a name="reverse" id="reverse">reverse</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
	// reverse mode routine called by CppAD
	virtual bool reverse(
		size_t                    q ,
		const vector&lt;double&gt;&amp;    tx ,
		const vector&lt;double&gt;&amp;    ty ,
		      vector&lt;double&gt;&amp;    px ,
		const vector&lt;double&gt;&amp;    py
	)
	{	size_t n = tx.size() / (q+1);
		size_t m = ty.size() / (q+1);	
		assert( px.size() == n * (q+1) );
		assert( py.size() == m * (q+1) );
		assert( n == 2 );
		assert( m == 1 );
		bool ok = q &lt;= 1;	

		double fp_0, fp_1;
		switch(q)
		{	case 0:
			// This case needed if first order reverse mode is used
			// F ( {x} ) = f( x^0 ) = y^0
			fp_0  =  2.0 * tx[0];  // partial F w.r.t. x_0^0
			fp_1  =  2.0 * tx[1];  // partial F w.r.t. x_0^1
			px[0] = py[0] * fp_0;; // partial G w.r.t. x_0^0
			px[1] = py[0] * fp_1;; // partial G w.r.t. x_0^1
			assert(ok);
			break;

			default:
			// Assume we are not using reverse with order &gt; 1 (q &gt; 0)
			assert(!ok);
		}
		return ok;
	}
</pre></font></code>

<br/>
<br/>
<b><big><a name="for_sparse_jac" id="for_sparse_jac">for_sparse_jac</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
	// forward Jacobian bool sparsity routine called by CppAD
	virtual bool for_sparse_jac(
		size_t                                p ,
		const vector&lt;bool&gt;&amp;                   r ,
		      vector&lt;bool&gt;&amp;                   s )
	{	// This function needed if using f.ForSparseJac 
		// with afun.option( CppAD::atomic_base&lt;double&gt;::bool_sparsity_enum )
		size_t n = r.size() / p;
		size_t m = s.size() / p;
		assert( n == 2 );
		assert( m == 1 );

		// sparsity for S(x) = f'(x) * R 
		// where f'(x) = 2 * [ x_0, x_1 ]
		for(size_t j = 0; j &lt; p; j++)
		{	s[j] = false;
			for(size_t i = 0; i &lt; n; i++)
				s[j] |= r[i * p + j];
		}
		return true; 
	}
	// forward Jacobian set sparsity routine called by CppAD
	virtual bool for_sparse_jac(
		size_t                                p ,
		const vector&lt; std::set&lt;size_t&gt; &gt;&amp;     r ,
		      vector&lt; std::set&lt;size_t&gt; &gt;&amp;     s )
	{	// This function needed if using f.ForSparseJac 
		// with afun.option( CppAD::atomic_base&lt;double&gt;::set_sparsity_enum )
		size_t n = r.size();
		size_t m = s.size();
		assert( n == 2 );
		assert( m == 1 );

		// sparsity for S(x) = f'(x) * R 
		// where f'(x) = 2 * [ x_0, x_1 ]
		my_union(s[0], r[0], r[1]);

		return true; 
	}
</pre></font></code>

<br/>
<br/>
<b><big><a name="rev_sparse_jac" id="rev_sparse_jac">rev_sparse_jac</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
	// reverse Jacobian bool sparsity routine called by CppAD
	virtual bool rev_sparse_jac(
		size_t                                p  ,
		const vector&lt;bool&gt;&amp;                   rt ,
		      vector&lt;bool&gt;&amp;                   st )
	{	// This function needed if using RevSparseJac or optimize
		// with afun.option( CppAD::atomic_base&lt;double&gt;::bool_sparsity_enum )
		size_t n = st.size() / p;
		size_t m = rt.size() / p;
		assert( n == 2 );
		assert( m == 1 );

		// sparsity for S(x)^T = f'(x)^T * R^T 
		// where f'(x)^T = 2 * [ x_0, x_1]^T
		for(size_t j = 0; j &lt; p; j++)
			for(size_t i = 0; i &lt; n; i++)
				st[i * p + j] = rt[j];

		return true; 
	}
	// reverse Jacobian set sparsity routine called by CppAD
	virtual bool rev_sparse_jac(
		size_t                                p  ,
		const vector&lt; std::set&lt;size_t&gt; &gt;&amp;     rt ,
		      vector&lt; std::set&lt;size_t&gt; &gt;&amp;     st )
	{	// This function needed if using RevSparseJac or optimize
		// with afun.option( CppAD::atomic_base&lt;double&gt;::set_sparsity_enum )
		size_t n = st.size();
		size_t m = rt.size();
		assert( n == 2 );
		assert( m == 1 );

		// sparsity for S(x)^T = f'(x)^T * R^T 
		// where f'(x)^T = 2 * [ x_0, x_1]^T
		st[0] = rt[0];
		st[1] = rt[0];

		return true; 
	}
</pre></font></code>

<br/>
<br/>
<b><big><a name="rev_sparse_hes" id="rev_sparse_hes">rev_sparse_hes</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
	// reverse Hessian bool sparsity routine called by CppAD
	virtual bool rev_sparse_hes(
		const vector&lt;bool&gt;&amp;                   vx,
		const vector&lt;bool&gt;&amp;                   s ,
		      vector&lt;bool&gt;&amp;                   t ,
		size_t                                p ,
		const vector&lt;bool&gt;&amp;                   r ,
		const vector&lt;bool&gt;&amp;                   u ,
		      vector&lt;bool&gt;&amp;                   v )
	{	// This function needed if using RevSparseHes
		// with afun.option( CppAD::atomic_base&lt;double&gt;::bool_sparsity_enum )
		size_t m = s.size();
		size_t n = t.size();
		assert( r.size() == n * p );
		assert( u.size() == m * p );
		assert( v.size() == n * p );
		assert( n == 2 );
		assert( m == 1 );

		// There are no cross term second derivatives for this case,
		// so it is not necessary to use vx.

		// sparsity for T(x) = S(x) * f'(x) 
		t[0] = s[0];
		t[1] = s[0];

		// V(x) = f'(x)^T * g''(y) * f'(x) * R  +  g'(y) * f''(x) * R 
		// U(x) = g''(y) * f'(x) * R
		// S(x) = g'(y)
		
		// back propagate the sparsity for U
		size_t j;
		for(j = 0; j &lt; p; j++)
			for(size_t i = 0; i &lt; n; i++)
				v[ i * p + j] = u[j];

		// include forward Jacobian sparsity in Hessian sparsity
		// sparsity for g'(y) * f''(x) * R  (Note f''(x) has same sparsity
		// as the identity matrix)
		if( s[0] )
		{	for(j = 0; j &lt; p; j++)
				for(size_t i = 0; i &lt; n; i++)
					v[ i * p + j] |= r[ i * p + j];
		}

		return true;
	}
	// reverse Hessian set sparsity routine called by CppAD
	virtual bool rev_sparse_hes(
		const vector&lt;bool&gt;&amp;                   vx,
		const vector&lt;bool&gt;&amp;                   s ,
		      vector&lt;bool&gt;&amp;                   t ,
		size_t                                p ,
		const vector&lt; std::set&lt;size_t&gt; &gt;&amp;     r ,
		const vector&lt; std::set&lt;size_t&gt; &gt;&amp;     u ,
		      vector&lt; std::set&lt;size_t&gt; &gt;&amp;     v )
	{	// This function needed if using RevSparseHes
		// with afun.option( CppAD::atomic_base&lt;double&gt;::set_sparsity_enum )
		size_t n = vx.size();
		size_t m = s.size();
		assert( t.size() == n );
		assert( r.size() == n );
		assert( u.size() == m );
		assert( v.size() == n );
		assert( n == 2 );
		assert( m == 1 );

		// There are no cross term second derivatives for this case,
		// so it is not necessary to vx.

		// sparsity for T(x) = S(x) * f'(x) 
		// where f'(x) = 2 * [ x_0, x_1 ]
		t[0] = s[0];
		t[1] = s[0];
	
		// V(x) = f'(x)^T * g''(y) * f'(x) * R  +  g'(y) * f''(x) * R 
		// U(x) = g''(y) * f'(x) * R
		// S(x) = g'(y)
		
		// Compute sparsity for f'(x)^T * U(x)
		// where f'(x)^T = 2 * [ x_0, x_1 ]^T
		v[0] = u[0];
		v[1] = u[0];

		// include sparsity for g'(y) * f''(x) * R
		// where f''(x) = [ 2 , 0 ]
		//                [ 0 , 2 ]
		// note there are no cross terms
		if( s[0] )
		{	for(size_t i = 0; i &lt; n; i++)
				my_union(v[i], v[i], r[i] );
		}

		return true;
	}
</pre></font></code>

<br/>
<br/>
<b><big><a name="End Class Definition" id="End Class Definition">End Class Definition</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
}; // End of atomic_norm_sq class
}  // End empty namespace

</pre></font></code>

<br/>
<br/>
<b><big><a name="Use Atomic Function" id="Use Atomic Function">Use Atomic Function</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
bool norm_sq(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;
	double eps = 10. * CppAD::numeric_limits&lt;double&gt;::epsilon();
</pre></font></code>

<br/>
<br/>
<b><a name="Use Atomic Function.Constructor" id="Use Atomic Function.Constructor">Constructor</a></b>

<code><font color='blue'><pre style='display:inline'> 
	// --------------------------------------------------------------------
	// Create the atomic reciprocal object
	atomic_norm_sq afun(&quot;atomic_norm_sq&quot;);
</pre></font></code>

<br/>
<br/>
<b><a name="Use Atomic Function.Recording" id="Use Atomic Function.Recording">Recording</a></b>

<code><font color='blue'><pre style='display:inline'> 
	// Create the function f(x)
	//
	// domain space vector
	size_t  n  = 2;
	double  x0 = 0.25;
	double  x1 = 0.75;
	vector&lt; <a href="ad.xml" target="_top">AD</a>&lt;double&gt; &gt; ax(n);
	ax[0]      = x0;
	ax[1]      = x1;

	// declare independent variables and start tape recording
	CppAD::<a href="independent.xml" target="_top">Independent</a>(ax);

	// range space vector 
	size_t m = 1;
	vector&lt; <a href="ad.xml" target="_top">AD</a>&lt;double&gt; &gt; ay(m);

	// call user function and store norm_sq(x) in au[0] 
	afun(ax, ay);        // y_0 = x_0 * x_0 + x_1 * x_1

	// create f: x -&gt; y and stop tape recording
	CppAD::<a href="funconstruct.xml" target="_top">ADFun</a>&lt;double&gt; f;
	f.Dependent (ax, ay); 
</pre></font></code>

<br/>
<br/>
<b><a name="Use Atomic Function.forward" id="Use Atomic Function.forward">forward</a></b>

<code><font color='blue'><pre style='display:inline'> 
	// check function value 
	double check = x0 * x0 + x1 * x1;
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>( Value(ay[0]) , check,  eps, eps);

	// check zero order forward mode
	size_t q;
	vector&lt;double&gt; x_q(n), y_q(m);
	q      = 0;
	x_q[0] = x0;
	x_q[1] = x1;
	y_q    = f.<a href="forward.xml" target="_top">Forward</a>(q, x_q);
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(y_q[0] , check,  eps, eps);

	// check first order forward mode
	q      = 1;
	x_q[0] = 0.3;
	x_q[1] = 0.7;
	y_q    = f.<a href="forward.xml" target="_top">Forward</a>(q, x_q);
	check  = 2.0 * x0 * x_q[0] + 2.0 * x1 * x_q[1];
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(y_q[0] , check,  eps, eps);

</pre></font></code>

<br/>
<br/>
<b><a name="Use Atomic Function.reverse" id="Use Atomic Function.reverse">reverse</a></b>

<code><font color='blue'><pre style='display:inline'> 
	// first order reverse mode 
	q     = 1;
	vector&lt;double&gt; w(m), dw(n * q);
	w[0]  = 1.;
	dw    = f.<a href="reverse.xml" target="_top">Reverse</a>(q, w);
	check = 2.0 * x0;
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(dw[0] , check,  eps, eps);
	check = 2.0 * x1;
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(dw[1] , check,  eps, eps);
</pre></font></code>

<br/>
<br/>
<b><a name="Use Atomic Function.for_sparse_jac" id="Use Atomic Function.for_sparse_jac">for_sparse_jac</a></b>

<code><font color='blue'><pre style='display:inline'> 
	// forward mode sparstiy pattern
	size_t p = n;
	CppAD::vectorBool r1(n * p), s1(m * p);
	r1[0] = true;  r1[1] = false; // sparsity pattern identity
	r1[2] = false; r1[3] = true;
	//
	afun.option( CppAD::atomic_base&lt;double&gt;::bool_sparsity_enum );
	s1    = f.ForSparseJac(p, r1);
	ok  &amp;= s1[0] == true;  // f[0] depends on x[0]  
	ok  &amp;= s1[1] == true;  // f[0] depends on x[1]  
	//
	afun.option( CppAD::atomic_base&lt;double&gt;::set_sparsity_enum );
	s1    = f.ForSparseJac(p, r1);
	ok  &amp;= s1[0] == true;  // f[0] depends on x[0]  
	ok  &amp;= s1[1] == true;  // f[0] depends on x[1]  
</pre></font></code>

<br/>
<br/>
<b><a name="Use Atomic Function.rev_sparse_jac" id="Use Atomic Function.rev_sparse_jac">rev_sparse_jac</a></b>

<code><font color='blue'><pre style='display:inline'> 
	// reverse mode sparstiy pattern
	q = m;
	CppAD::vectorBool s2(q * m), r2(q * n);
	s2[0] = true;          // compute sparsity pattern for f[0]
	//
	afun.option( CppAD::atomic_base&lt;double&gt;::bool_sparsity_enum );
	r2    = f.RevSparseJac(q, s2);
	ok  &amp;= r2[0] == true;  // f[0] depends on x[0]  
	ok  &amp;= r2[1] == true;  // f[0] depends on x[1]  
	//
	afun.option( CppAD::atomic_base&lt;double&gt;::set_sparsity_enum );
	r2    = f.RevSparseJac(q, s2);
	ok  &amp;= r2[0] == true;  // f[0] depends on x[0]  
	ok  &amp;= r2[1] == true;  // f[0] depends on x[1]  
</pre></font></code>

<br/>
<br/>
<b><a name="Use Atomic Function.rev_sparse_hes" id="Use Atomic Function.rev_sparse_hes">rev_sparse_hes</a></b>

<code><font color='blue'><pre style='display:inline'> 
	// Hessian sparsity (using previous ForSparseJac call) 
	CppAD::vectorBool s3(m), h(p * n);
	s3[0] = true;        // compute sparsity pattern for f[0]
	//
	afun.option( CppAD::atomic_base&lt;double&gt;::bool_sparsity_enum );
	h     = f.RevSparseHes(p, s3);
	ok  &amp;= h[0] == true;  // partial of f[0] w.r.t. x[0],x[0] is non-zero
	ok  &amp;= h[1] == false; // partial of f[0] w.r.t. x[0],x[1] is zero
	ok  &amp;= h[2] == false; // partial of f[0] w.r.t. x[1],x[0] is zero
	ok  &amp;= h[3] == true;  // partial of f[0] w.r.t. x[1],x[1] is non-zero
	//
	afun.option( CppAD::atomic_base&lt;double&gt;::set_sparsity_enum );
	h     = f.RevSparseHes(p, s3);
	ok  &amp;= h[0] == true;  // partial of f[0] w.r.t. x[0],x[0] is non-zero
	ok  &amp;= h[1] == false; // partial of f[0] w.r.t. x[0],x[1] is zero
	ok  &amp;= h[2] == false; // partial of f[0] w.r.t. x[1],x[0] is zero
	ok  &amp;= h[3] == true;  // partial of f[0] w.r.t. x[1],x[1] is non-zero

	return ok;
}
</pre></font></code>

 

<hr/>Input File: example/atomic/norm_sq.cpp

</body>
</html>
