<commit_before>// $Id$
# ifndef CPPAD_LOCAL_OPTIMIZE_OP_INFO_HPP
# define CPPAD_LOCAL_OPTIMIZE_OP_INFO_HPP

/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 <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.
-------------------------------------------------------------------------- */
/*!
\file op_info.hpp
Create operator information tables
*/

# include <cppad/local/optimize/fast_empty_set.hpp>

// BEGIN_CPPAD_LOCAL__OPTIMIZE_NAMESPACE
namespace CppAD { namespace local { namespace optimize {

/// information that identifies
// a conditional expression and its comparison result.
class cexp_compare {
private:
	/// Conditional expression index, cexp2op[ index_ ]
	/// is the coreresponding operator index.
	size_t index_;

	/// does this correspond to a true or false result for the comparison
	bool   result_;

public:
	/// constructor
	cexp_compare(size_t index, bool result) :
	index_ ( index )  ,
	result_( result )
	{ }

	/// index()
	size_t index(void) const
	{	return index_; }

	/// result()
	bool result(void) const
	{	return result_; }

	/// comparison operator (necessary for set elements)
	bool operator < (const cexp_compare& right) const
	{	size_t left_key  = 2 * index_ + size_t(result_);
		size_t right_key = 2 * right.index_ + size_t( right.result_ );
		return left_key < right_key;
	}
};

inline std::ostream& operator << (std::ostream& os, const cexp_compare& cexp)
{	os << '(' << cexp.index() << ',' << cexp.result() << ')';
	return os;
}

/// information for one operator
struct struct_op_info {
	/// op code
	OpCode op;

	/// arguments
	const addr_t* arg;

	/// Primary (not auxillary) variable index for this operator. If the
	// operator has not results, this is num_var (an invalid variable index).
	size_t i_var;

	/// Number of times an operator is used. This counts using the results
	/// as well as other factors. Being a dependent variable or independent
	/// varialbe gets one use count. Certain other side effects can get a
	// use count. For example, comparision operators may or may not be counted.
	size_t usage;

	/// Is this operator only used once, is its parrent a summation,
	/// and is it a summation. In this case it can be removed as part
	/// of a cumulative summation starting at its parent or above.
	bool csum_connected;

	/// Set of conditional expressions comparisons that usage of this
	/// operator depends on. This set is left empty when usage = 0.
	/// It is also left empty for the result of any VecAD operations.
	fast_empty_set<cexp_compare>  cexp_set;
};<commit_msg>optimize branch: op_info.hpp: change cexp_compare: result() -> compare().<commit_after>// $Id$
# ifndef CPPAD_LOCAL_OPTIMIZE_OP_INFO_HPP
# define CPPAD_LOCAL_OPTIMIZE_OP_INFO_HPP

/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 <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.
-------------------------------------------------------------------------- */
/*!
\file op_info.hpp
Create operator information tables
*/

# include <cppad/local/optimize/fast_empty_set.hpp>

// BEGIN_CPPAD_LOCAL__OPTIMIZE_NAMESPACE
namespace CppAD { namespace local { namespace optimize {

/// information that identifies
// a conditional expression and its comparison result.
class cexp_compare {
private:
	/// Conditional expression index, cexp2op[ index_ ]
	/// is the coreresponding operator index.
	size_t index_;

	/// does this correspond to a true or false result for the comparison
	bool   compare_;

public:
	/// constructor
	cexp_compare(size_t index, bool compare) :
	index_ ( index )  ,
	compare_( compare )
	{ }

	/// index()
	size_t index(void) const
	{	return index_; }

	/// compare()
	bool compare(void) const
	{	return compare_; }

	/// comparison operator (necessary for set elements)
	bool operator < (const cexp_compare& right) const
	{	size_t left_key  = 2 * index_ + size_t(compare_);
		size_t right_key = 2 * right.index_ + size_t( right.compare_ );
		return left_key < right_key;
	}
};

inline std::ostream& operator << (std::ostream& os, const cexp_compare& cexp)
{	os << '(' << cexp.index() << ',' << cexp.compare() << ')';
	return os;
}

/// information for one operator
struct struct_op_info {
	/// op code
	OpCode op;

	/// arguments
	const addr_t* arg;

	/// Primary (not auxillary) variable index for this operator. If the
	// operator has not results, this is num_var (an invalid variable index).
	size_t i_var;

	/// Number of times an operator is used. This counts using the results
	/// as well as other factors. Being a dependent variable or independent
	/// varialbe gets one use count. Certain other side effects can get a
	// use count. For example, comparision operators may or may not be counted.
	size_t usage;

	/// Is this operator only used once, is its parrent a summation,
	/// and is it a summation. In this case it can be removed as part
	/// of a cumulative summation starting at its parent or above.
	bool csum_connected;

	/// Set of conditional expressions comparisons that usage of this
	/// operator depends on. This set is left empty when usage = 0.
	/// It is also left empty for the result of any VecAD operations.
	fast_empty_set<cexp_compare>  cexp_set;
};
{'fraction_non_alphanumeric': 0.14121482498284146, 'fraction_numerical': 0.004118050789293068, 'mean_word_length': 2.8475247524752474, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 10, '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': '796690', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1652, 'n_words': 660}