source: trunk/test_more/compare.cpp @ 3779

Last change on this file since 3779 was 3779, checked in by bradbell, 4 years ago

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: cf5ca238670f67655fbbf3e23727437f7ed7b182
end hash code: 5661e2a629cceb77e7b703225bc1f3f8cf422129

commit 5661e2a629cceb77e7b703225bc1f3f8cf422129
Author: Brad Bell <bradbell@…>
Date: Fri Jan 1 04:23:41 2016 -0700

push_git2svn.py: Include changes in copyright date when checking for difference.

commit f0e9d149dc00ccf410a268389e3dcfd95499b863
Author: Brad Bell <bradbell@…>
Date: Fri Jan 1 03:57:09 2016 -0700

Advance copyright year to 2016.

commit 01d25679b7baddca878129635b0758f4ebb263fb
Author: Brad Bell <bradbell@…>
Date: Fri Jan 1 03:54:41 2016 -0700

download.omh: improve the no documentation download instructions.

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1// $Id: compare.cpp 3779 2016-01-01 11:26:11Z bradbell $
2/* --------------------------------------------------------------------------
3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
4
5CppAD is distributed under multiple licenses. This distribution is under
6the terms of the
7                    Eclipse Public License Version 1.0.
8
9A copy of this license is included in the COPYING file of this distribution.
10Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
11-------------------------------------------------------------------------- */
12
13/*
14Check comparison operators between AD< AD<Base> > and Base, int
15*/
16# include <cppad/cppad.hpp>
17
18namespace {
19        template <class Type>
20        bool Compare(void)
21        {       bool ok = true;
22                using CppAD::AD;
23
24                Type      middle = 4;
25                AD<double> three = 3;
26                AD<double> four  = 4;
27                AD<double> five  = 5;
28
29                // AD<double> > Type
30                ok &= ! (three  >  middle);
31                ok &= ! (four   >  middle);
32                ok &=   (five   >  middle);
33                // Type > AD<double>
34                ok &=   (middle >  three );
35                ok &= ! (middle >  four  );
36                ok &= ! (middle >  five  );
37
38                // AD<double> >= Type
39                ok &= ! (three  >= middle);
40                ok &=   (four   >= middle);
41                ok &=   (five   >= middle);
42                // Type > AD<double>
43                ok &=   (middle >= three );
44                ok &=   (middle >= four  );
45                ok &= ! (middle >= five  );
46
47                // AD<double> < Type
48                ok &=   (three  <  middle);
49                ok &= ! (four   <  middle);
50                ok &= ! (five   <  middle);
51                // Type > AD<double>
52                ok &= ! (middle <  three );
53                ok &= ! (middle <  four  );
54                ok &=   (middle <  five  );
55
56                // AD<double> <= Type
57                ok &=   (three  <= middle);
58                ok &=   (four   <= middle);
59                ok &= ! (five   <= middle);
60                // Type > AD<double>
61                ok &= ! (middle <= three );
62                ok &=   (middle <= four  );
63                ok &=   (middle <= five  );
64
65                return ok;
66        }
67}
68bool Compare(void)
69{       bool ok = true;
70        ok     &= Compare<int>();
71        ok     &= Compare<double>();
72        ok     &= Compare< CppAD::AD<double> >();
73        return ok;
74}
Note: See TracBrowser for help on using the repository browser.