gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 5294083: Minor corrections in match and box li


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 5294083: Minor corrections in match and box libraries
Date: Sun, 3 Dec 2017 22:45:05 -0500 (EST)

branch: master
commit 5294083e548ac87da9ef3635721b5299c1991e84
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Minor corrections in match and box libraries
    
    While reviewing the code after the previous commit, a few minor issues were
    found that are now applied.
---
 lib/box.c   | 4 ++--
 lib/match.c | 9 ++++-----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/box.c b/lib/box.c
index 58ef6b5..d913902 100644
--- a/lib/box.c
+++ b/lib/box.c
@@ -92,8 +92,8 @@ gal_box_bound_ellipse(double a, double b, double theta_deg, 
long *width)
      want the final height and width of the box enclosing the
      ellipse. So we have to multiply them by two, then take one from
      them (for the center). */
-  width[0] = 2 * ( (size_t)extent[0] + 1 ) + 1;
-  width[1] = 2 * ( (size_t)extent[1] + 1 ) + 1;
+  width[0] = 2 * ( (long)extent[0] + 1 ) + 1;
+  width[1] = 2 * ( (long)extent[1] + 1 ) + 1;
 }
 
 
diff --git a/lib/match.c b/lib/match.c
index 17de927..382cdfe 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -158,7 +158,7 @@ match_coordinaes_sanity_check(gal_data_t *coord1, 
gal_data_t *coord2,
           gal_list_data_number(coord2));
 
 
-  /* This function currently only works for 2 dimensions. */
+  /* This function currently only works on 1 and 2 dimensional inputs. */
   if(ncoord1>2)
     error(EXIT_FAILURE, 0, "%s: %zu dimension matching requested, this "
           "function currently only matches datasets with a maximum of 2 "
@@ -305,14 +305,13 @@ static double
 match_coordinates_distance(double *delta, int iscircle, size_t ndim,
                            double *aperture, double c, double s)
 {
-  /* In a one dimensional case, the distance is just the absolute value of
-     delta[0]. */
-  if(ndim==1) return fabs(delta[0]);
-
   /* For more than one dimension, we'll need to calculate the distance from
      the deltas (differences) in each dimension. */
   switch(ndim)
     {
+    case 1:
+      return fabs(delta[0]);
+
     case 2:
       return ( iscircle
                ? sqrt( delta[0]*delta[0] + delta[1]*delta[1] )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]