29 #ifndef CDPL_DESCR_RDFCODECALCULATOR_HPP
30 #define CDPL_DESCR_RDFCODECALCULATOR_HPP
201 template <
typename Iter,
typename Vec>
205 template <
typename Iter>
206 void init(Iter beg, Iter end);
208 double smoothingFactor;
209 double scalingFactor;
211 double radiusIncrement;
212 std::size_t numSteps;
213 std::size_t numEntities;
216 bool distToIntervalCenterRounding;
226 template <
typename T>
228 smoothingFactor(1.0), scalingFactor(1.0), startRadius(0.0), radiusIncrement(0.1), numSteps(99),
229 distToIntervalCenterRounding(false)
232 template <
typename T>
235 smoothingFactor = factor;
238 template <
typename T>
241 scalingFactor = factor;
244 template <
typename T>
247 startRadius = start_radius;
250 template <
typename T>
253 radiusIncrement = radius_inc;
256 template <
typename T>
259 numSteps = num_steps;
262 template <
typename T>
265 return smoothingFactor;
268 template <
typename T>
271 return scalingFactor;
274 template <
typename T>
280 template <
typename T>
283 return radiusIncrement;
286 template <
typename T>
292 template <
typename T>
298 template <
typename T>
304 template <
typename T>
307 distToIntervalCenterRounding = enable;
310 template <
typename T>
313 return distToIntervalCenterRounding;
316 template <
typename T>
317 template <
typename Iter,
typename Vec>
322 double r = startRadius;
324 for (std::size_t i = 0; i <= numSteps; i++,
r += radiusIncrement) {
327 for (std::size_t j = 0; j < numEntities; j++) {
328 for (std::size_t k = j + 1; k < numEntities; k++) {
329 double t =
r - distMatrix(j, k);
331 sum += weightMatrix(j, k) * std::exp(-smoothingFactor * t * t);
335 rdf_code[i] = scalingFactor *
sum;
339 template <
typename T>
340 template <
typename Iter>
343 numEntities = std::distance(beg, end);
345 weightMatrix.resize(numEntities, numEntities,
false);
346 distMatrix.resize(numEntities, numEntities,
false);
350 for (std::size_t i = 0; beg != end; i++) {
351 const EntityType& entity1 = *beg;
354 entity1_pos = coordsFunc(entity1);
356 std::size_t j = i + 1;
358 for (Iter it = ++beg; it != end; ++it, j++) {
359 const EntityType& entity2 = *it;
362 weightMatrix(i, j) = 1.0;
364 weightMatrix(i, j) = weightFunc(entity1, entity2);
367 double dist =
length(entity1_pos - coordsFunc(entity2));
369 if (distToIntervalCenterRounding)
370 dist = std::round((dist - startRadius) / radiusIncrement) * radiusIncrement + startRadius;
372 distMatrix(i, j) = dist;
375 distMatrix(i, j) = 0.0;
Definition of matrix data types.
Definition of vector data types.
Generic implementation of the radial distribution function (RDF) code calculation for sequences of en...
Definition: RDFCodeCalculator.hpp:61
void enableDistanceToIntervalCenterRounding(bool enable)
Allows to specify whether entity pair distances should be rounded to the nearest radius interval cent...
Definition: RDFCodeCalculator.hpp:305
void setSmoothingFactor(double factor)
Allows to specify the smoothing factor used in the calculation of entity pair RDF contributions.
Definition: RDFCodeCalculator.hpp:233
double getRadiusIncrement() const
Returns the radius step size between successive RDF code elements.
Definition: RDFCodeCalculator.hpp:281
void setNumSteps(std::size_t num_steps)
Sets the number of desired radius incrementation steps.
Definition: RDFCodeCalculator.hpp:257
void setEntity3DCoordinatesFunction(const Entity3DCoordinatesFunction &func)
Allows to specify the entity 3D coordinates function.
Definition: RDFCodeCalculator.hpp:299
void setRadiusIncrement(double radius_inc)
Sets the radius step size between successive RDF code elements.
Definition: RDFCodeCalculator.hpp:251
T EntityType
Definition: RDFCodeCalculator.hpp:64
bool distanceToIntervalsCenterRoundingEnabled() const
Tells whether entity pair distances get rounded to the nearest radius interval centers.
Definition: RDFCodeCalculator.hpp:311
void calculate(Iter beg, Iter end, Vec &rdf_code)
Calculates the RDF code of an entity sequence.
Definition: RDFCodeCalculator.hpp:318
std::size_t getNumSteps() const
Returns the number of performed radius incrementation steps.
Definition: RDFCodeCalculator.hpp:287
double getStartRadius() const
Returns the starting value of the radius.
Definition: RDFCodeCalculator.hpp:275
void setScalingFactor(double factor)
Allows to specify the scaling factor for the RDF code elements.
Definition: RDFCodeCalculator.hpp:239
void setStartRadius(double start_radius)
Sets the starting value of the radius.
Definition: RDFCodeCalculator.hpp:245
double getSmoothingFactor() const
Returns the smoothing factor used in the calculation of entity pair RDF contributions.
Definition: RDFCodeCalculator.hpp:263
std::function< const Math::Vector3D &(const EntityType &)> Entity3DCoordinatesFunction
Type of the generic functor class used to store a user-defined entity 3D coordinates function.
Definition: RDFCodeCalculator.hpp:82
RDFCodeCalculator()
Constructs the RDFCodeCalculator instance.
Definition: RDFCodeCalculator.hpp:227
std::function< double(const EntityType &, const EntityType &)> EntityPairWeightFunction
Type of the generic functor class used to store a user-defined entity pair weight function.
Definition: RDFCodeCalculator.hpp:73
void setEntityPairWeightFunction(const EntityPairWeightFunction &func)
Allows to specify a custom entity pair weight function.
Definition: RDFCodeCalculator.hpp:293
double getScalingFactor() const
Returns the scaling factor applied to the RDF code elements.
Definition: RDFCodeCalculator.hpp:269
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int r
Specifies that the stereocenter has r configuration.
Definition: CIPDescriptor.hpp:76
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Definition: VectorExpression.hpp:553
GridElementSum< E >::ResultType sum(const GridExpression< E > &e)
Definition: GridExpression.hpp:416
CVector< double, 3 > Vector3D
A bounded 3 element vector holding floating point values of type double.
Definition: Vector.hpp:1637
The namespace of the Chemical Data Processing Library.