38#include "bertini2/nag_algorithms/common/config.hpp"
45 template<
typename RealType,
typename ComplexType,
typename MetaDataType>
46 struct MidpathChecker :
public detail::Configured<MidPathConfig>
48 using MidPathConfT = MidPathConfig;
49 using AlgConf = detail::Configured<MidPathConfig>;
50 using BoundaryData = SolnCont< MetaDataType >;
51 using PathIndT =
unsigned long long;
54 MidpathChecker() =
default;
61 template<
typename ...T>
62 MidpathChecker( T
const& ...config) : AlgConf(config...)
76 CrossedPath(PathIndT index, PathIndT crossed_with,
bool same_start)
79 crossed_with_.push_back( std::make_pair(crossed_with, same_start) );
84 PathIndT index()
const
89 void crossed_with(std::pair<PathIndT, bool> crossed)
91 crossed_with_.push_back(crossed);
94 void rerun(
bool same_start)
96 rerun_ = rerun_ || !same_start;
107 std::vector< std::pair<PathIndT, bool> > crossed_with_;
121 const auto& SamePointTol()
const
123 return this->
template Get<MidPathConfT>().same_point_tolerance;
134 template <
typename StartSystemT>
135 bool Check(BoundaryData
const& boundary_data, StartSystemT
const& start_system)
137 for (PathIndT ii = 0; ii < boundary_data.size(); ++ii)
139 if ( boundary_data[ii].success_code != SuccessCode::Success)
142 const Vec<ComplexType>& solution_ii = boundary_data[ii].path_point;
143 const auto start_ii = start_system.template StartPoint<ComplexType>(ii);
145 for (PathIndT jj = ii+1; jj < boundary_data.size(); ++jj)
147 if ( boundary_data[jj].success_code != SuccessCode::Success)
150 const Vec<ComplexType>& solution_jj = boundary_data[jj].path_point;
151 const Vec<ComplexType> diff_sol = solution_ii - solution_jj;
153 if ((diff_sol.template lpNorm<Eigen::Infinity>()/solution_ii.template lpNorm<Eigen::Infinity>()) < SamePointTol())
155 bool i_already_stored =
false;
156 bool j_already_stored =
false;
159 const auto start_jj = start_system.template StartPoint<ComplexType>(jj);
160 auto diff_start = start_ii - start_jj;
161 bool same_start = (diff_start.template lpNorm<Eigen::Infinity>() > SamePointTol());
165 for(
auto& v : crossed_paths_)
169 v.crossed_with(std::make_pair(jj,same_start));
170 i_already_stored =
true;
175 v.crossed_with(std::make_pair(ii,same_start));
176 j_already_stored =
true;
182 if(!i_already_stored)
185 crossed_paths_.push_back(tempPath);
187 if(!j_already_stored)
190 crossed_paths_.push_back(tempPath);
202 const std::vector<CrossedPath> GetCrossedPaths()
const
204 return crossed_paths_;
211 std::vector<CrossedPath> crossed_paths_;
Definition midpath_check.hpp:74