| 107 | } |
| 108 | } |
| 109 | bool get_started(void) |
| 110 | { // ok |
| 111 | bool ok = true; |
| 112 | // |
| 113 | // eps99 |
| 114 | double eps99 = 99.0 * std::numeric_limits<double>::epsilon(); |
| 115 | // |
| 116 | // nx, ax |
| 117 | size_t nx = 10; |
| 118 | ad_vector ax(nx); |
| 119 | for(size_t j = 0; j < nx; ++j) |
| 120 | ax[j] = 1.0; |
| 121 | CppAD::Independent(ax); |
| 122 | // |
| 123 | // fun |
| 124 | ad_vector ay(1); |
| 125 | ay[0] = ax[0]; |
| 126 | for(size_t j = 1; j < nx; ++j) |
| 127 | ay[0] *= ax[j]; |
| 128 | # if USE_DEFAULT_ADFUN_CONSTRUCTOR |
| 129 | CppAD::ADFun<double> fun; |
| 130 | fun.Dependent(ax, ay); |
| 131 | # else |
| 132 | // This allocates memory for first order Taylor coefficients using thread 0. |
| 133 | // An assert will occur at f.capacity_order(0) in run_one_thread when |
| 134 | // it is called by a different thread. |
| 135 | CppAD::ADFun<double> fun(ax, ay); |
| 136 | # endif |
| 137 | // |
| 138 | // num_threads, f_thread, ok_thread |
| 139 | size_t num_threads = 4; |
| 140 | fun_vector f_thread(num_threads); |
| 141 | b_vector ok_thread(num_threads); |
| 142 | for(size_t thread_num = 0; thread_num < num_threads; ++thread_num) |
| 143 | { f_thread[thread_num] = fun; |
| 144 | ok_thread[thread_num] = true; |
| 145 | } |
| 146 | // |
| 147 | // x |
| 148 | d_vector x(nx); |
| 149 | for(size_t j = 0; j < nx; ++j) |
| 150 | x[j] = 1.0 + 1.0 / double(j+1); |
| 151 | // |
| 152 | // thread_specific_data_ |
| 153 | // must be set for this thread before calling parall_setup or parallel_ad |
| 154 | { size_t thread_num = 0; |
| 155 | thread_specific_data_.reset(new size_t(thread_num) ); |
| 156 | ok &= thread_number() == thread_num; |
| 157 | } |
| 158 | // |
| 159 | // parallel_setup |
| 160 | CppAD::thread_alloc::parallel_setup( |
| 161 | num_threads, in_parallel, thread_number |
| 162 | ); |
| 163 | // |
| 164 | // parallel_ad |
| 165 | CppAD::parallel_ad<double>(); |
| 166 | // |
nothing calls this directly
no test coverage detected