densityfit: Fix inconsistent use of iterators
authorAndrey Alekseenko <al42and@gmail.com>
Tue, 20 Oct 2020 16:19:34 +0000 (18:19 +0200)
committerAndrey Alekseenko <al42and@gmail.com>
Wed, 21 Oct 2020 09:34:37 +0000 (11:34 +0200)
and some typos

While both referenceDensity_ and referenceDensity are views into the
same data, it's clearer to use the same variable for both begin()
and end().

src/gromacs/math/densityfit.cpp

index 3301fc73dfa5914f01c2a41a98c4114f4e140b1c..a4bd83430865b249cfd15c3963e907979fe4062a 100644 (file)
@@ -104,7 +104,7 @@ DensitySimilarityInnerProduct::DensitySimilarityInnerProduct(density referenceDe
     const auto numVoxels = gradient_.asConstView().mapping().required_span_size();
     /* the gradient for the inner product measure of fit is constant and does not
      * depend on the compared density, so it is pre-computed here */
-    std::transform(begin(referenceDensity_), end(referenceDensity), begin(gradient_),
+    std::transform(begin(referenceDensity_), end(referenceDensity_), begin(gradient_),
                    [numVoxels](float x) { return x / numVoxels; });
 }
 
@@ -227,7 +227,7 @@ struct CrossCorrelationEvaluationHelperValues
     real referenceSquaredSum = 0;
     //! The sum of the squared compared density voxel values
     real comparisonSquaredSum = 0;
-    //! The covariance of the refernce and the compared density
+    //! The covariance of the reference and the compared density
     real covariance = 0;
 };
 
@@ -267,7 +267,7 @@ CrossCorrelationEvaluationHelperValues evaluateHelperValues(DensitySimilarityMea
 class CrossCorrelationGradientAtVoxel
 {
 public:
-    //! Set up the gradident calculation with pre-computed values
+    //! Set up the gradient calculation with pre-computed values
     CrossCorrelationGradientAtVoxel(const CrossCorrelationEvaluationHelperValues& preComputed) :
         prefactor_(evaluatePrefactor(preComputed.comparisonSquaredSum, preComputed.referenceSquaredSum)),
         comparisonPrefactor_(preComputed.covariance / preComputed.comparisonSquaredSum),
@@ -344,7 +344,7 @@ real DensitySimilarityCrossCorrelation::similarity(density comparedDensity)
 
     // To avoid numerical instability due to large squared density value sums
     // division is re-written to avoid multiplying two large numbers
-    // as product of two seperate divisions of smaller numbers
+    // as product of two separate divisions of smaller numbers
     const real covarianceSqrt = sqrt(fabs(helperValues.covariance));
     const int  sign           = helperValues.covariance > 0 ? 1 : -1;
     return sign * (covarianceSqrt / sqrt(helperValues.referenceSquaredSum))