13#ifndef GPR_DISTANCE_H_
14#define GPR_DISTANCE_H_
83double solve_assignment_problem_highs(
const Eigen::MatrixXd& cost_matrix);
128 for (
int i = 0; i < 9; ++i)
136 const double cell[9])
const
144 for (
int i = 0; i < 9; ++i) {
245 bool take_sqrt =
true);
273 std::vector<gpr::FieldMatrixd>& dist);
365 return far_field_radius_;
374 radial_far_field_list_ = enabled;
379 return radial_far_field_list_;
386 return radial_list_entries_;
395 return far_field_radius_ > 0.0 && radial_far_field_list_;
403 static constexpr Eigen::Index kReciprocalSqrtVectorThreshold = 16;
413 static void inverseDistancesToPoint(
const double* data, Eigen::Index cols,
414 Eigen::Index off,
double fx,
double fy,
415 double fz, Eigen::Index n,
double*
out,
423 static void inverseDistancesBetween(
const double* data, Eigen::Index cols,
424 Eigen::Index off_a, Eigen::Index off_b,
425 Eigen::Index n,
double*
out,
436 static void reciprocalSqrtInPlace(
double* r2, Eigen::Index count);
446 static void buildInverseSquaredLengthscales(
458 static bool isActivePairtype(
gpr::Index_t pt, Eigen::Index n_lengthscales)
461 static_cast<Eigen::Index
>(pt) < n_lengthscales;
471 void accumulateCachedSquaredDistances(
475 InverseDistanceCache cache_;
476 double far_field_radius_ = 0.0;
477 bool radial_far_field_list_ =
false;
478 std::uint64_t radial_list_entries_ = 0;
482 std::vector<double> scratch_invr1_;
490 std::vector<double> scratch_invr2_;
void dist_at_cached_sq(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale, gpr::FieldMatrixd &dist_sq)
Like dist_at_cached but returns SQUARED distances (skips final sqrt).
bool hasCachedDistances() const
void dist_at_cached(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale, gpr::FieldMatrixd &dist)
Compute dist_at using cached inverse distances.
void dist_at_vec(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale, std::vector< gpr::FieldMatrixd > &dist)
Similar to dist_at but calculates vector of distances for every pair of moving and frozen atoms.
void cacheInverseDistances(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info)
Pre-compute and cache raw inverse distances for given positions.
void dist_at(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale, gpr::FieldMatrixd &dist, bool take_sqrt=true)
Give the distance between two atomic configurations as defined in the special GPstuff covariance func...
bool selectsRadialFarField(const gpr::AtomsConfiguration &conf) const
void dist_max1Dlog(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist)
Give the maximum difference in the logarithmic inter-atomic distances between atomic configurations C...
void setRadialFarFieldList(bool enabled)
double farFieldRadius() const
bool radialFarFieldList() const
void mindist_interatomic(const gpr::Coord &x, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist)
Give the distance from each moving atom to its nearest neighbour atom in configuration C.
void dist_emd(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist)
Calculates the Earth Mover's Distance between sets of configurations.
std::uint64_t radialListEntries() const
void setFarFieldRadius(double radius)
double range_at(const gpr::Coord &positions, const gpr::AtomsConfiguration &conf_info, const gpr::FieldMatrixd &lengthscale)
void dist_rmsd(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist)
Calculates the aligned Root Mean Square Deviation (RMSD) between sets of configurations.
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
std::vector< int > solve_assignment_indices(const Eigen::MatrixXd &cost_matrix)
Like solve_assignment_problem, but returns the optimal assignment.
double solve_assignment_problem(const Eigen::MatrixXd &cost_matrix)
Solves the assignment problem using the Hungarian algorithm.
std::pair< gpr::Coord, gpr::FieldMatrixIdx > get_canonical_configuration(const gpr::Coord &x_in, const gpr::FieldMatrixIdx &types_in)
double calculate_aligned_rmsd(const gpr::Coord &P, const gpr::Coord &Q)
Eigen::Matrix< Index_t, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixIdx
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
std::vector< double > signature_vec
gpr::Index_t original_index
bool operator<(const AtomSignature &other) const
Methods to calculate distances between atoms.
bool matches(const gpr::Coord &x1, const gpr::Coord &x2, const double cell[9]) const
Whether the cache describes exactly this pair of coordinate sets.
std::vector< std::vector< double > > invr_x1
std::vector< std::vector< double > > invr_x2
std::vector< gpr::Index_t > pair_types
Stores configurations of all atoms in the system.