Source.cpp iostream chrono thread mutex Exponential.h Timer.h int n n EXPONENTIAL::Function< n > using Function = EXPONENTIAL::Function<n> Function TIMER::Timer typedef TIMER::Timer timer timer int exp exp void void CalcRoots (std::mutex &m, const Function< exp > &func, EXPONENTIAL::GA_Options options) CalcRoots std::mutex & m const Function< exp > & func EXPONENTIAL::GA_Options options int exp exp void void SolveX (std::mutex &m, const Function< exp > &func, EXPONENTIAL::GA_Options options, const double &y) SolveX std::mutex & m const Function< exp > & func EXPONENTIAL::GA_Options options const double & y int int main () main #include<iostream> #include<chrono> #include<thread> #include<mutex> #include"Exponential.h" #include"Timer.h" usingnamespaceJRAMPERSAD; template<intn> usingFunction=EXPONENTIAL::Function<n>; typedefTIMER::Timertimer; template<intexp> voidCalcRoots(std::mutex&m,constFunction<exp>&func,EXPONENTIAL::GA_Optionsoptions) { m.lock(); std::cout<<"Startingcalculation...\n"; m.unlock(); timert; autogr=func.get_real_roots(options); t.SetEnd(); m.lock(); std::cout<<"Timetooktocalculateapproxrootvalues:"<<t.GetTimeInS()<<"s\n"; std::cout<<"Approximatevaluesofxwherey=0are:\n"; std::for_each(gr.begin(),gr.end(), [](constauto&val){ std::cout<<"x:"<<val<<'\n'; }); m.unlock(); } template<intexp> voidSolveX(std::mutex&m,constFunction<exp>&func,EXPONENTIAL::GA_Optionsoptions,constdouble&y) { timert; autores=func.solve_x(y,options); t.SetEnd(); m.lock(); std::cout<<"Timetooktocalculateapproxxvalues:"<<t.GetTimeInS()<<"s\n"; std::cout<<"Approximatevaluesofxwherey="<<y<<"are:\n"; std::for_each(res.begin(),res.end(), [](constauto&val){ std::cout<<"x:"<<val<<'\n'; }); m.unlock(); } intmain() { std::vector<int>vec{1,5,4}; Function<2>f{vec}; Function<3>g{{1,-6,11,-6}}; EXPONENTIAL::GA_Optionsoptions; options.mutation_percentage=0.005; options.num_of_generations=10; options.sample_size=50; options.data_size=5000000; options.min_range=-100; options.max_range=100; std::mutexm; std::threadth(CalcRoots<3>,std::ref(m),std::cref(g),options); //std::threadth1(SolveX<3>,std::ref(m),std::cref(g),options,5); //std::threadth2(SolveX<3>,std::ref(m),std::cref(g),options,23); //CalcRoots<3>(m,g); m.lock(); std::cout<<g<<"whenx=4.961015\n"<<"y="<<g.solve_y(4.961015)<<"\n\n"; //std::cout<<g<<"whenx=4.30891\n"<<"y="<<g.solve_y(4.30891)<<"\n\n"; //std::cout<<g<<"whenx=2\n"<<"y="<<g.solve_y(2)<<"\n\n"; //std::cout<<g<<"whenx=3\n"<<"y="<<g.solve_y(3)<<"\n\n"; //std::cout<<"Median:"<<MATH::MEDIAN(gr)<<'\n'; //std::cout<<"Mean:"<<MATH::MEAN(gr)<<'\n'; //std::cout<<"CalculatingRootsforfunctionf(x)="<<g<<'\n'; //std::cout<<"They-interceptofthefunctionf(x)is"<<g.solve_y(0)<<'\n'; std::cout<<"dy/dxoff(x)is"<<g.differential()<<'\n'; m.unlock(); th.join(); //th1.join(); //th2.join(); return0; }