32 #include <type_traits>
35 namespace energybased {
40 const double b[Dim],
double delta[Dim]) {
45 for (
int d = 0; d < Dim; d++) {
47 delta[d] = a[d] - b[d];
50 dist += delta[d] * delta[d];
59 const double b[Dim],
double delta[Dim]) {
61 delta[0] = a[0] - b[0];
62 delta[1] = a[1] - b[1];
65 return sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
68 template<
int Dim,
int K>
70 double dist,
double& force,
double& force_prime) {
75 for (
int i = 1; i < K; i++) {
80 force_prime = (double)(K) / (t * dist);
83 template<
int Dim,
int K>
85 double& force,
double& force_prime) {
88 force_prime = 2.0 / (dist * dist * dist);
89 force = force_prime * dist * 0.5;
92 template<
int Dim,
int K>
94 double& force,
double& force_prime) {
97 force_prime = 1.0 / (dist * dist);
104 force =
log(dist / 1.0);
105 force_prime = 1.0 / dist;
108 template<
int Dim,
int K>
110 double dist,
double& force,
double& force_prime) {
115 for (
int i = 1; i < K; i++) {
120 force_prime = (double)(K) * (t / dist);
123 template<
int Dim,
int K>
125 double& force,
double& force_prime) {
130 force_prime = 2.0 * dist;
133 template<
int Dim,
int K>
135 double& force,
double& force_prime) {
145 inline void RepForceFunctionInvGauss(
const double a[Dim],
const double b[Dim],
double result[Dim])
148 const double force_range = 10.0;
151 const double force_amount = 20.0;
160 for (
int d = 0; d < Dim; d++) {
162 delta[d] = a[d] - b[d];
165 dist += delta[d] * delta[d];
172 double f = (exp(- (dist * dist) / force_range ) * force_amount);
174 double f = exp(-dist * dist * 0.01) * 10.0) / dist;
179 for (
int d = 0; d < Dim; d++) {
180 result[d] = delta[d] * f/dist;