Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD > Class Template Reference

Eigen-based refinement error function. More...

#include <EigenRefinement.h>

Data Structures

struct  DefaultTermVisitor
 Visitor that can be passed to visit all terms. More...
 

Public Types

Public types
using VectorType = Eigen::Matrix< FloatType, Eigen::Dynamic, 1 >
 Vector layout of positions.
 
using ThreeDimensionalVector = Eigen::Matrix< FloatType, 3, 1 >
 Three dimensional vector.
 
using FullDimensionalVector = Eigen::Matrix< FloatType, dimensionality, 1 >
 Three or four dimensional vector (depending on dimensionality)
 
using ThreeDimensionalMatrixType = Eigen::Matrix< FloatType, 3, Eigen::Dynamic >
 Three-row dynamic column matrix.
 
using FullDimensionalMatrixType = Eigen::Matrix< FloatType, dimensionality, Eigen::Dynamic >
 Three or four-row dynamic column matrix.
 
using FloatingPointType = FloatType
 Template argument specifying floating-point type.
 

Public Member Functions

void operator() (const VectorType &parameters, FloatType &value, Eigen::Ref< VectorType > gradient) const
 Calculates the error value and gradient for all contributions. More...
 
double calculateProportionChiralConstraintsCorrectSign (const VectorType &positions) const
 Calculates the number of chiral constraints with correct sign. More...
 
template<typename Visitor >
auto visitTerms (const VectorType &positions, Visitor &&visitor) const
 
template<typename Visitor >
auto visitUnfulfilledConstraints (const DistanceBoundsMatrix &bounds, const VectorType &positions, Visitor &&visitor) const
 Visit all unfulfilled constraints. More...
 
Constructors
 EigenRefinementProblem (const Eigen::MatrixXd &squaredBounds, std::vector< ChiralConstraint > passChiralConstraints, std::vector< DihedralConstraint > passDihedralConstraints)
 
Contribution functions
void distanceContributions (const VectorType &positions, FloatType &error, Eigen::Ref< VectorType > gradient) const
 Adds pairwise distance error and gradient contributions. More...
 
void chiralContributions (const VectorType &positions, FloatType &error, Eigen::Ref< VectorType > gradient) const
 Adds chiral error and gradient contributions. More...
 
void dihedralContributions (const VectorType &positions, FloatType &error, Eigen::Ref< VectorType > gradient) const
 Adds dihedral error and gradient contributions. More...
 
void fourthDimensionContributions (const VectorType &positions, FloatType &error, Eigen::Ref< VectorType > gradient) const
 Adds pairwise distance error and gradient contributions. More...
 

Static Public Member Functions

Static member functions
static std::string name ()
 Get a string representation of the type name. More...
 
static FullDimensionalVector getPosition (const VectorType &positions, const AtomIndex index)
 Copy a full dimensional position of an atom. More...
 
static ThreeDimensionalVector getPosition3D (const VectorType &positions, const AtomIndex index)
 Copy a three-dimensional position of an atom. More...
 
static FullDimensionalVector getAveragePosition (const VectorType &positions, const ChiralConstraint::AtomListType &atomList)
 Calculate the average full-dimensional position of several atoms. More...
 
static ThreeDimensionalVector getAveragePosition3D (const VectorType &positions, const ChiralConstraint::AtomListType &atomList)
 Calculate the average three-dimensional position of several atoms. More...
 

Data Fields

Public members
VectorType upperDistanceBoundsSquared
 Upper distance bounds squared, linearized in i < j.
 
VectorType lowerDistanceBoundsSquared
 Lower distance bounds squared, linearized in i < j.
 
VectorType chiralUpperConstraints
 Chiral upper constraints, in sequence of chiralConstraints.
 
VectorType chiralLowerConstraints
 Chiral lower constraints, in sequence of chiralConstraints.
 
VectorType dihedralConstraintSumsHalved
 Dihedral bounds' averages, in sequence of dihedralConstraints.
 
VectorType dihedralConstraintDiffsHalved
 Dihedral bounds upper minus lower, halved, in sequence.
 
std::vector< ChiralConstraintchiralConstraints
 List of chiral constraints.
 
std::vector< DihedralConstraintdihedralConstraints
 List of dihedral constraints.
 
bool compressFourthDimension = false
 Whether to compress the fourth dimension.
 
bool dihedralTerms = false
 Whether to enable dihedral terms.
 
Signaling members
double proportionChiralConstraintsCorrectSign = 0.0
 

Private Member Functions

Contribution implementations
template<class Visitor >
void distanceContributionsImpl (const VectorType &positions, FloatType &error, Eigen::Ref< VectorType > gradient, Visitor &&visitor) const
 Adds distance error and gradient contributions (non-SIMD)
 
template<typename Visitor >
void chiralContributionsImpl (const VectorType &positions, FloatType &error, Eigen::Ref< VectorType > gradient, Visitor &&visitor) const
 Adds chiral error and gradient contributions.
 
template<class Visitor >
void dihedralContributionsImpl (const VectorType &positions, FloatType &error, Eigen::Ref< VectorType > gradient, Visitor &&visitor) const
 Adds dihedral error and gradient contributions.
 
template<class Visitor = DefaultTermVisitor>
void fourthDimensionContributionsImpl (const VectorType &positions, FloatType &error, Eigen::Ref< VectorType > gradient, Visitor &&visitor={}) const
 Adds fourth dimension error and gradient contributions. More...
 

Detailed Description

template<unsigned dimensionality, typename FloatType, bool SIMD>
class Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >

Eigen-based refinement error function.

Template Parameters
dimensionality3 or 4 spatial dimensions to refine in
FloatTypefloat or double
SIMDWhether to use rewritten implementations that try to take advantage of Eigen's SIMD capabilities

Member Function Documentation

template<unsigned dimensionality, typename FloatType , bool SIMD>
double Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::calculateProportionChiralConstraintsCorrectSign ( const VectorType positions) const
inline

Calculates the number of chiral constraints with correct sign.

Complexity \(\Theta(C)\) where \(C\) is the number of chiral constraints

template<unsigned dimensionality, typename FloatType , bool SIMD>
void Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::chiralContributions ( const VectorType positions,
FloatType &  error,
Eigen::Ref< VectorType gradient 
) const
inline

Adds chiral error and gradient contributions.

Complexity \(\Omega(C)\)

template<unsigned dimensionality, typename FloatType , bool SIMD>
void Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::dihedralContributions ( const VectorType positions,
FloatType &  error,
Eigen::Ref< VectorType gradient 
) const
inline

Adds dihedral error and gradient contributions.

Complexity \(\Omega(D)\)

template<unsigned dimensionality, typename FloatType , bool SIMD>
void Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::distanceContributions ( const VectorType positions,
FloatType &  error,
Eigen::Ref< VectorType gradient 
) const
inline

Adds pairwise distance error and gradient contributions.

Complexity \(\Omega(N^2)\)

template<unsigned dimensionality, typename FloatType , bool SIMD>
void Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::fourthDimensionContributions ( const VectorType positions,
FloatType &  error,
Eigen::Ref< VectorType gradient 
) const
inline

Adds pairwise distance error and gradient contributions.

Complexity \(\Omega(N^2)\)

template<unsigned dimensionality, typename FloatType , bool SIMD>
template<class Visitor = DefaultTermVisitor>
void Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::fourthDimensionContributionsImpl ( const VectorType positions,
FloatType &  error,
Eigen::Ref< VectorType gradient,
Visitor &&  visitor = {} 
) const
inlineprivate

Adds fourth dimension error and gradient contributions.

Complexity \(\Theta(N)\)

template<unsigned dimensionality, typename FloatType , bool SIMD>
static FullDimensionalVector Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::getAveragePosition ( const VectorType positions,
const ChiralConstraint::AtomListType &  atomList 
)
inlinestatic

Calculate the average full-dimensional position of several atoms.

Complexity \(\Theta(A)\) where A is the number of atoms whose positions to average

template<unsigned dimensionality, typename FloatType , bool SIMD>
static ThreeDimensionalVector Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::getAveragePosition3D ( const VectorType positions,
const ChiralConstraint::AtomListType &  atomList 
)
inlinestatic

Calculate the average three-dimensional position of several atoms.

Complexity \(\Theta(A)\) where A is the number of atoms whose positions to average

template<unsigned dimensionality, typename FloatType , bool SIMD>
static FullDimensionalVector Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::getPosition ( const VectorType positions,
const AtomIndex  index 
)
inlinestatic

Copy a full dimensional position of an atom.

Complexity \(\Theta(1)\)

template<unsigned dimensionality, typename FloatType , bool SIMD>
static ThreeDimensionalVector Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::getPosition3D ( const VectorType positions,
const AtomIndex  index 
)
inlinestatic

Copy a three-dimensional position of an atom.

Complexity \(\Theta(1)\)

template<unsigned dimensionality, typename FloatType , bool SIMD>
static std::string Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::name ( )
inlinestatic

Get a string representation of the type name.

Complexity \(\Theta(1)\)

template<unsigned dimensionality, typename FloatType , bool SIMD>
void Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::operator() ( const VectorType parameters,
FloatType &  value,
Eigen::Ref< VectorType gradient 
) const
inline

Calculates the error value and gradient for all contributions.

Parameters
[in]parametersThe linearized positions of all particles
[out]valueThe error function value for the given positional parameters
[out]gradientThe gradient for the given positional parameters
Precondition
parameters must be evenly divisible by the dimensionality
Postcondition
Error is stored in value and gradient in gradient
template<unsigned dimensionality, typename FloatType , bool SIMD>
template<typename Visitor >
auto Scine::Molassembler::DistanceGeometry::EigenRefinementProblem< dimensionality, FloatType, SIMD >::visitUnfulfilledConstraints ( const DistanceBoundsMatrix bounds,
const VectorType positions,
Visitor &&  visitor 
) const
inline

Visit all unfulfilled constraints.

Template Parameters
VisitorType containing a deviationThreshold and result member variable and implementing the following methods:
  • distanceOverThreshold: (unsigned, unsigned, double) -> void
  • chiralOverThreshold: (ChiralConstraint, double) -> void
  • dihedralOverThreshold: (DihedralConstraint, double) -> void
Parameters
boundsdistance bounds instance
positionsparameter positions to the error function
visitorInstance of VisitorType

This function is very helpful in implementing multiple behaviors, like debug or error information on unsatisfied bonds or checking whether all constraints are within their bounds.

Returns
visitor.result

The documentation for this class was generated from the following file: