<commit_before>/* $Id$ */
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 <NAME>

CppAD is distributed under multiple licenses. This distribution is under
the terms of the 
                    Eclipse Public License Version 1.0.

A copy of this license is included in the COPYING file of this distribution.
Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
-------------------------------------------------------------------------- */

/*
$begin ad_input.cpp$$
$spell
	Cpp
	cstddef
$$

$section AD Output Operator: Example and Test$$

$index <<, AD example$$
$index input, AD example$$
$index example, AD input$$
$index test, AD input$$

$code
$verbatim%example/ad_input.cpp%0%// BEGIN C++%// END C++%1%$$
$$

$end
*/
// BEGIN C++

# include <cppad/cppad.hpp>

# include <sstream>  // std::istringstream
# include <string>   // std::string

bool ad_input(void)
{	bool ok = true;

	std::string str ("123 456");
	std::istringstream is(str);

	CppAD::AD<double> x(1.), y(2.);

	is >> x >> y;

	ok &= (x == 123.);
	ok &= (y == 456.);

	return ok;
}
// END C++<commit_msg>ad_input.cpp: Show, by example, result of input is a parameter.<commit_after>/* $Id$ */
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 <NAME>

CppAD is distributed under multiple licenses. This distribution is under
the terms of the 
                    Eclipse Public License Version 1.0.

A copy of this license is included in the COPYING file of this distribution.
Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
-------------------------------------------------------------------------- */

/*
$begin ad_input.cpp$$
$spell
	Cpp
	cstddef
$$

$section AD Output Operator: Example and Test$$

$index <<, AD example$$
$index input, AD example$$
$index example, AD input$$
$index test, AD input$$

$code
$verbatim%example/ad_input.cpp%0%// BEGIN C++%// END C++%1%$$
$$

$end
*/
// BEGIN C++

# include <cppad/cppad.hpp>

# include <sstream>  // std::istringstream
# include <string>   // std::string

bool ad_input(void)
{	bool ok = true;

	// create the input string stream is.
	std::string str ("123 456");
	std::istringstream is(str);

	// start and AD<double> recording
	CPPAD_TESTVECTOR( CppAD::AD<double> ) x(1), y(1);
	x[0] = 1.0;
	CppAD::Independent(x);
	CppAD::AD<double> z = x[0];
	ok &= Variable(z);

	// read first number into z and second into y[0] 
	is >> z >> y[0];
	ok   &= Parameter(z);
	ok   &= (z == 123.);
	ok   &= Parameter(y[0]);
	ok   &= (y[0] == 456.);
	//
	// terminate recording starting by call to Independent 
	CppAD::ADFun<double> f(x, y);

	return ok;
}
// END C++
{'fraction_non_alphanumeric': 0.25080271138066357, 'fraction_numerical': 0.019978594363182306, 'mean_word_length': 2.2529002320185616, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3996339', 'n_tokens_mistral': 943, 'n_tokens_neox': 895, 'n_words': 294}