1 /* --------------------------------------------------------------------------
2 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-20 Bradley M. Bell
3 
4 CppAD is distributed under the terms of the
5              Eclipse Public License Version 2.0.
6 
7 This Source Code may also be made available under the following
8 Secondary License when the conditions for such availability set forth
9 in the Eclipse Public License, Version 2.0 are satisfied:
10       GNU General Public License, Version 2.0 or later.
11 ---------------------------------------------------------------------------- */
12 
13 // CPPAD_HAS_* defines
14 # include <cppad/configure.hpp>
15 
16 // system include files used for I/O
17 # include <iostream>
18 
19 // memory leak checker
20 # include <cppad/utility/thread_alloc.hpp>
21 
22 // test runner
23 # include <cppad/utility/test_boolofvoid.hpp>
24 
25 // BEGIN_SORT_THIS_LINE_PLUS_1
26 extern bool acosh(void);
27 extern bool acos(void);
28 extern bool AddEq(void);
29 extern bool Add(void);
30 extern bool AddZero(void);
31 extern bool adfun(void);
32 extern bool alloc_openmp(void);
33 extern bool asinh(void);
34 extern bool asin(void);
35 extern bool assign(void);
36 extern bool atan2(void);
37 extern bool atanh(void);
38 extern bool atan(void);
39 extern bool atomic_three(void);
40 extern bool azmul(void);
41 extern bool base_adolc(void);
42 extern bool base_alloc_test(void);
43 extern bool bool_sparsity(void);
44 extern bool check_simple_vector(void);
45 extern bool chkpoint_one(void);
46 extern bool chkpoint_two(void);
47 extern bool compare_change(void);
48 extern bool Compare(void);
49 extern bool CondExpAD(void);
50 extern bool cond_exp_rev(void);
51 extern bool CondExp(void);
52 extern bool copy(void);
53 extern bool Cosh(void);
54 extern bool Cos(void);
55 extern bool cppad_eigen(void);
56 extern bool cppad_vector(void);
57 extern bool dbl_epsilon(void);
58 extern bool dependency(void);
59 extern bool DivEq(void);
60 extern bool Div(void);
61 extern bool DivZeroOne(void);
62 extern bool eigen_mat_inv(void);
63 extern bool erf(void);
64 extern bool expm1(void);
65 extern bool Exp(void);
66 extern bool fabs(void);
67 extern bool ForHess(void);
68 extern bool for_sparse_hes(void);
69 extern bool for_sparse_jac(void);
70 extern bool forward_dir(void);
71 extern bool forward_order(void);
72 extern bool Forward(void);
73 extern bool FromBase(void);
74 extern bool FunCheck(void);
75 extern bool hes_sparsity(void);
76 extern bool ipopt_solve(void);
77 extern bool jacobian(void);
78 extern bool json_graph(void);
79 extern bool log10(void);
80 extern bool log1p(void);
81 extern bool log(void);
82 extern bool mul_cond_rev(void);
83 extern bool mul_cskip(void);
84 extern bool MulEq(void);
85 extern bool mul_level(void);
86 extern bool Mul(void);
87 extern bool mul_zdouble(void);
88 extern bool MulZeroOne(void);
89 extern bool NearEqualExt(void);
90 extern bool Neg(void);
91 extern bool new_dynamic(void);
92 extern bool num_limits(void);
93 extern bool ode_err_control(void);
94 extern bool optimize(void);
95 extern bool parameter(void);
96 extern bool Poly(void);
97 extern bool PowInt(void);
98 extern bool Pow(void);
99 extern bool print_for(void);
100 extern bool reverse(void);
101 extern bool rev_sparse_jac(void);
102 extern bool RevTwo(void);
103 extern bool RombergOne(void);
104 extern bool Rosen34(void);
105 extern bool Runge45(void);
106 extern bool SimpleVector(void);
107 extern bool SinCos(void);
108 extern bool Sinh(void);
109 extern bool Sin(void);
110 extern bool sparse_hessian(void);
111 extern bool sparse_jacobian(void);
112 extern bool sparse_jac_work(void);
113 extern bool sparse_sub_hes(void);
114 extern bool sparse_vec_ad(void);
115 extern bool Sqrt(void);
116 extern bool std_math(void);
117 extern bool SubEq(void);
118 extern bool subgraph_1(void);
119 extern bool subgraph_2(void);
120 extern bool subgraph_hes2jac(void);
121 extern bool Sub(void);
122 extern bool SubZero(void);
123 extern bool tan(void);
124 extern bool test_vector(void);
125 extern bool to_string(void);
126 extern bool Value(void);
127 extern bool VecADPar(void);
128 extern bool VecAD(void);
129 extern bool VecUnary(void);
130 // END_SORT_THIS_LINE_MINUS_1
131 
132 // tests in local subdirectory
133 extern bool is_pod(void);
134 extern bool json_lexer(void);
135 extern bool json_parser(void);
136 extern bool vector_set(void);
137 
138 // main program that runs all the tests
main(void)139 int main(void)
140 {   std::string group = "test_more/general";
141     size_t      width = 20;
142     CppAD::test_boolofvoid Run(group, width);
143 
144     // This line is used by test_one.sh
145 
146     // BEGIN_SORT_THIS_LINE_PLUS_1
147     Run( acos,            "acos"           );
148     Run( acosh,           "acosh"          );
149     Run( Add,             "Add"            );
150     Run( AddEq,           "AddEq"          );
151     Run( AddZero,         "AddZero"        );
152     Run( adfun,           "adfun"          );
153     Run( asin,            "asin"           );
154     Run( asinh,           "asinh"          );
155     Run( assign,          "assign"         );
156     Run( atan2,           "atan2"          );
157     Run( atan,            "atan"           );
158     Run( atanh,           "atanh"          );
159     Run( atomic_three,    "atomic_three"   );
160     Run( azmul,           "azmul"          );
161     Run( bool_sparsity,   "bool_sparsity"  );
162     Run( check_simple_vector, "check_simple_vector" );
163     Run( chkpoint_one,    "chkpoint_one"   );
164     Run( chkpoint_two,    "chkpoint_two"   );
165     Run( compare_change,  "compare_change" );
166     Run( Compare,         "Compare"        );
167     Run( CondExpAD,       "CondExpAD"      );
168     Run( CondExp,         "CondExp"        );
169     Run( cond_exp_rev,    "cond_exp_rev"   );
170     Run( copy,            "copy"           );
171     Run( Cos,             "Cos"            );
172     Run( Cosh,            "Cosh"           );
173     Run( cppad_vector,    "cppad_vector"   );
174     Run( dbl_epsilon,     "dbl_epsilon"    );
175     Run( dependency,      "dependency"     );
176     Run( Div,             "Div"            );
177     Run( DivEq,           "DivEq"          );
178     Run( DivZeroOne,      "DivZeroOne"     );
179     Run( erf,             "erf"            );
180     Run( Exp,             "Exp"            );
181     Run( expm1,           "expm1"          );
182     Run( fabs,            "fabs"           );
183     Run( ForHess,         "ForHess"        );
184     Run( for_sparse_hes,  "for_sparse_hes" );
185     Run( for_sparse_jac,  "for_sparse_jac" );
186     Run( forward_dir,     "forward_dir"    );
187     Run( Forward,         "Forward"        );
188     Run( forward_order,   "forward_order"  );
189     Run( FromBase,        "FromBase"       );
190     Run( FunCheck,        "FunCheck"       );
191     Run( hes_sparsity,    "hes_sparsity"   );
192     Run( jacobian,        "jacobian"       );
193     Run( json_graph,      "json_graph"     );
194     Run( log10,           "log10"          );
195     Run( log1p,           "log1p"          );
196     Run( log,             "log"            );
197     Run( mul_cond_rev,    "mul_cond_rev"   );
198     Run( mul_cskip,       "Mul_cskip"      );
199     Run( MulEq,           "MulEq"          );
200     Run( mul_level,       "mul_level"      );
201     Run( Mul,             "Mul"            );
202     Run( mul_zdouble,     "mul_zdouble"    );
203     Run( MulZeroOne,      "MulZeroOne"     );
204     Run( NearEqualExt,    "NearEqualExt"   );
205     Run( Neg,             "Neg"            );
206     Run( new_dynamic,     "new_dynamic"    );
207     Run( num_limits,      "num_limits"     );
208     Run( ode_err_control, "ode_err_control");
209     Run( optimize,        "optimize"       );
210     Run( parameter,       "parameter"      );
211     Run( Poly,            "Poly"           );
212     Run( PowInt,          "PowInt"         );
213     Run( Pow,             "Pow"            );
214     Run( print_for,       "print_for"      );
215     Run( reverse,         "reverse"        );
216     Run( rev_sparse_jac,  "rev_sparse_jac" );
217     Run( RevTwo,          "RevTwo"         );
218     Run( RombergOne,      "RombergOne"     );
219     Run( Rosen34,         "Rosen34"        );
220     Run( Runge45,         "Runge45"        );
221     Run( SimpleVector,    "SimpleVector"   );
222     Run( SinCos,          "SinCos"         );
223     Run( Sinh,            "Sinh"           );
224     Run( Sin,             "Sin"            );
225     Run( sparse_hessian,  "sparse_hessian" );
226     Run( sparse_jacobian, "sparse_jacobian");
227     Run( sparse_jac_work, "sparse_jac_work");
228     Run( sparse_sub_hes,  "sparse_sub_hes" );
229     Run( sparse_vec_ad,   "sparse_vec_ad"  );
230     Run( Sqrt,            "Sqrt"           );
231     Run( std_math,        "std_math"       );
232     Run( SubEq,           "SubEq"          );
233     Run( subgraph_1,      "subgraph_1"     );
234     Run( subgraph_2,      "subgraph_2"     );
235     Run( subgraph_hes2jac, "subgraph_hes2jac" );
236     Run( Sub,             "Sub"            );
237     Run( SubZero,         "SubZero"        );
238     Run( tan,             "tan"            );
239     Run( to_string,       "to_string"      );
240     Run( Value,           "Value"          );
241     Run( VecADPar,        "VecADPar"       );
242     Run( VecAD,           "VecAD"          );
243     Run( VecUnary,        "VecUnary"       );
244     // END_SORT_THIS_LINE_MINUS_1
245 #if CPPAD_HAS_ADOLC
246     Run( base_adolc,      "base_adolc"     );
247 # endif
248 #if CPPAD_HAS_IPOPT
249     Run( ipopt_solve,     "ipopt_solve"    );
250 # endif
251 # ifdef CPPAD_OPENMP_TEST
252     Run( alloc_openmp,    "alloc_openmp"   );
253 # endif
254 # if CPPAD_HAS_EIGEN
255     Run( cppad_eigen,     "cppad_eigen"    );
256     Run( eigen_mat_inv,   "eigen_mat_inv"  );
257 # endif
258 # if ! CPPAD_EIGENVECTOR
259     Run( test_vector,     "test_vector"    );
260 # endif
261     // local sub-directory
262     Run( is_pod,         "is_pod"          );
263     Run( json_lexer,     "json_lexer"      );
264     Run( json_parser,    "json_parser"     );
265     Run( vector_set,      "vector_set"     );
266     //
267     // check for memory leak
268     bool memory_ok = CppAD::thread_alloc::free_all();
269     //
270     // Run base_alloc after memory leak check because base_alloc.hpp uses
271     // thread_alloc to allocate memory for static copies of nan.
272     Run( base_alloc_test,  "base_alloc"    );
273     //
274     // print summary at end
275     bool ok = Run.summary(memory_ok);
276     //
277     return static_cast<int>( ! ok );
278 }
279 // END PROGRAM
280