gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 78da1575: Library (statistics.h): corrected ty


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 78da1575: Library (statistics.h): corrected typo in new concentration function
Date: Sun, 28 Apr 2024 15:01:55 -0400 (EDT)

branch: master
commit 78da15757fe8be31123125850639ce9dc6340495
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Library (statistics.h): corrected typo in new concentration function
    
    Until now, in the concentration function, we would only scale the input
    values back to their original values when the operation was not done in
    place! But this is wrong: it is only needed when we are doing the operation
    in-place (the non-inplace scenario immediately frees the array). Also, the
    command to correct it was just a copy to scale the input to the range of 0
    to 1! So it was wrong also!
    
    With this commit, both have been fixed.
---
 lib/statistics.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/statistics.c b/lib/statistics.c
index 489b4c2c..bd3bbbfc 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -2408,9 +2408,9 @@ gal_statistics_cfp(gal_data_t *input, gal_data_t *bins, 
int normalize)
     vlow=a[ilow];                                                       \
                                                                         \
     /* If this operation was done in-place, undo the scaling because */ \
-    /* the caller may need to do other operations on the dataset. */    \
-    if(nbs!=input)                                                      \
-      { for(i=0;i<nbs->size;++i) a[i]=(a[i]-min)/(max-min); }           \
+    /* the caller may need to do other operations on the sorted */      \
+    /* dataset without any blanks. */                                   \
+    if(nbs==input) for(i=0;i<nbs->size;++i) a[i]=a[i]*(max-min)+min;    \
   }
 
 gal_data_t *



reply via email to

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