\(\newcommand{\W}[1]{ \; #1 \; }\) \(\newcommand{\R}[1]{ {\rm #1} }\) \(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} }\) \(\newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} }\) \(\newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} }\) \(\newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }\)
base_ordered¶
View page sourceBase Type Requirements for Ordered Comparisons¶
Purpose¶
The following operations
(in the CppAD namespace) are required to use the type
AD
< Base > :
Syntax |
Result |
b = |
\(x > 0\) |
b = |
\(x \geq 0\) |
b = |
\(x < 0\) |
b = |
\(x \leq 0\) |
b = |
\(|x| \geq |y|\). |
where the arguments and return value have the prototypes
const
Base & xconst
Base & ybool
bOrdered Type¶
If the type Base supports ordered operations, these functions should have their corresponding definitions. For example,
namespace CppAD
{inline bool GreaterThanZero
( const
Base & x
)return
( x > 0
);The other functions would replace >
by the corresponding operator.
For example, see
base_alloc .
Not Ordered¶
If the type Base does not support ordering,
one might (but need not) define GreaterThanZero
as follows:
namespace CppAD
{inline bool GreaterThanZero
( const
Base & x
)attempt to use GreaterThanZero with a
Base argument
assert
(0);return x
;The other functions would have the corresponding definition. For example, see complex Ordered .
Special Requirements¶
The following are special requirements when there is no ordered comparison for the base type:
Independent¶
record_compare must be false
in the call to Independent
.
Optimize¶
The no_conditional_skip
option must be present when optimize
is used.
PrintFor¶
The PrintFor operator cannot be used.