gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master e7a2db5f: Library (statistics.h): MAD correcte


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master e7a2db5f: Library (statistics.h): MAD corrected for unsigned types
Date: Wed, 3 Jan 2024 05:15:34 -0500 (EST)

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

    Library (statistics.h): MAD corrected for unsigned types
    
    Until now, in the low-level MAD calculation function
    ('statistics_mad_in_sorted_no_blank'), I had forgot to include a 'break' in
    the 'case' statement for unsigned types! As a result, when the inputs where
    unsigned, it would always go to the 'default' scenario, resulting in a zero
    MAD value! This would later cause problems in the newly added MAD-clipping
    functions (where they would complain about the size).
    
    With this commit, the 'break's have been added so each unsigned type is
    converted to its respective larger signed type properly.
    
    This issue was found with the help of Alberto Moreno Signes.
---
 THANKS                       |  1 +
 doc/announce-acknowledge.txt |  1 +
 lib/statistics.c             | 14 +++++++-------
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/THANKS b/THANKS
index 361f88c8..0baae919 100644
--- a/THANKS
+++ b/THANKS
@@ -23,6 +23,7 @@ support in Gnuastro. The list is ordered alphabetically (by 
family name).
     Agata Rożek                          a.rozek@ed.ac.uk
     Alan Lefor                           alefor@astr.tohoku.ac.jp
     Alberto Madrigal                     brt.madrigal@gmail.com
+    Alberto Moreno Signes                amoreno@cefca.es
     Alejandro Lumbreras Calle            alumbreras@cefca.es
     Alejandro Serrano Borlaff            asborlaff@ucm.es
     Alessandro Ederoclite                aederocl@gmail.com
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 69be95a7..54cb8bf2 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -1,5 +1,6 @@
 Alphabetically ordered list to acknowledge in the next release.
 
+Alberto Moreno Signes
 Ignacio Ruiz Cejudo
 Rahna Payyasseri Thanduparackal
 Sepideh Eskandarlou
diff --git a/lib/statistics.c b/lib/statistics.c
index 72c3a2c9..6da3470e 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -411,10 +411,10 @@ statistics_mad_in_sorted_no_blank(gal_data_t *sorted, 
gal_data_t *med,
      negative after subtracting the median. */
   switch(sorted->type)
     {
-    case GAL_TYPE_UINT8:  type=GAL_TYPE_INT16;
-    case GAL_TYPE_UINT16: type=GAL_TYPE_INT32;
-    case GAL_TYPE_UINT32: type=GAL_TYPE_INT64;
-    case GAL_TYPE_UINT64: type=GAL_TYPE_INT64;
+    case GAL_TYPE_UINT8:  type=GAL_TYPE_INT16; break;
+    case GAL_TYPE_UINT16: type=GAL_TYPE_INT32; break;
+    case GAL_TYPE_UINT32: type=GAL_TYPE_INT64; break;
+    case GAL_TYPE_UINT64: type=GAL_TYPE_INT64; break;
     default:              type=GAL_TYPE_INVALID; /* Not necessary. */
     }
   use=gal_data_copy_to_new_type(sorted, ( type!=GAL_TYPE_INVALID
@@ -440,7 +440,7 @@ statistics_mad_in_sorted_no_blank(gal_data_t *sorted, 
gal_data_t *med,
     for(i=0;i<sorted->size;++i)
       printf("%-15g    %-15g\n", s[i], u[i]);
     printf("Median: %g\n", ma[0]);
-    printf("MAD: %g\n", Ma[0]);
+    printf("MAD:    %g\n", Ma[0]);
     exit(0);
   } */
 
@@ -2630,8 +2630,8 @@ statistics_clip(gal_data_t *input, float multip, float 
param,
       start=nbs->array;
       while(num<maxnum && size)
         {
-          /* Find the average and Standard deviation, note that both
-             'start' and 'size' will be different in the next round. */
+          /* 'start' and 'size' will be different in the next round
+             (updated within 'CLIPALL'). */
           nbs->array = start;
           nbs->size = oldsize = size;
 



reply via email to

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