EqualOpSeq

View page source

Check if Two Value are Identically Equal

Syntax

b = EqualOpSeq ( x , y )

Purpose

Determine if two x and y are identically equal; i.e., not only is x == y true, but if they are variables , they correspond have the same operation sequence .

Motivation

Sometimes it is useful to cache information and only recalculate when a function’s arguments change. In the case of AD variables, it may be important not only when the argument values are equal, but when they are related to the independent variables by the same operation sequence. After the assignment

y = x

these two AD objects would not only have equal values, but would also correspond to the same operation sequence.

x

The argument x has prototype

const AD < Base > & x

y

The argument y has prototype

const AD < Base > & y

b

The result b has prototype

bool b

The result is true if and only if one of the following cases holds:

  1. Both x and y are variables and correspond to the same operation sequence.

  2. Both x and y are parameters, Base is an AD type, and EqualOpSeq ( Value ( x ) , Value ( y ) ) is true.

  3. Both x and y are parameters, Base is not an AD type, and x == y is true.

Example

The file equal_op_seq.cpp contains an example and test of EqualOpSeq .