
Syntax
ok = harmonic_takedown(xout) 
Purpose
This routine does the takedown for splitting the Newton method into sub-intervals.

It is assumed that this function is called by thread zero, and all the other threads have completed their work and are blocked (waiting).

xout
See multi_newton_run .

Source

namespace {
bool multi_newton_takedown(vector<double>& xout)
{     // number of threads in the calculation

// remove duplicates and points that are not solutions
xout.resize(0);
bool   ok = true;

// initialize as more that sub_length_ / 2 from any possible solution
double xlast = - sub_length_;

size_t i;
for(i = 0; i < x.size(); i++)
{     // check for case where this point is lower limit for this
if( fabs(x[i] - xlast) >= sub_length_ )
{     xout.push_back( x[i] );
xlast = x[i];
}
else
{     double fcur, flast, df;
fun_(x[i],   fcur, df);
fun_(xlast, flast, df);
if( fabs(fcur) < fabs(flast) )
{     xout[ xout.size() - 1] = x[i];
xlast                  = x[i];
}
}
}
// check that this thread was ok with the work it did
}

// go down so free memory for other threads before memory for master
{
// call the destructor for vector destructor
// delete the raw memory allocation
void* v_ptr = static_cast<void*>( work_all_[thread_num] );
# else
# endif
// Note that xout corresponds to memroy that is inuse by master
// (so we can only chech have freed all their memory).
{     // check that there is no longer any memory inuse by this thread
}