gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 39ae937d 1/2: Library (arithmetic.c): Correcte


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 39ae937d 1/2: Library (arithmetic.c): Corrected the order of some operators
Date: Sun, 20 Aug 2023 15:37:00 -0400 (EDT)

branch: master
commit 39ae937dedfd74f3d220734bdac376837780da2c
Author: Faezeh Bidjarchian <fbidjarchian@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Library (arithmetic.c): Corrected the order of some operators
    
    Until now, the order in "size and position" operators did not match the
    order within the book. Also, there were some typos in the book and the
    libraries.
    
    With this commit, The order of these operators and the typos have been
    corrected.
---
 bin/arithmetic/main.c     |  4 +--
 doc/gnuastro.texi         | 14 ++++----
 lib/arithmetic.c          | 90 +++++++++++++++++++++++------------------------
 lib/blank.c               | 20 +++++------
 lib/checkset.c            | 30 ++++++++--------
 lib/data.c                |  4 +--
 lib/git.c                 |  2 +-
 lib/gnuastro/arithmetic.h | 10 +++---
 lib/statistics.c          |  6 ++--
 9 files changed, 91 insertions(+), 89 deletions(-)

diff --git a/bin/arithmetic/main.c b/bin/arithmetic/main.c
index af34df13..407a3842 100644
--- a/bin/arithmetic/main.c
+++ b/bin/arithmetic/main.c
@@ -45,10 +45,10 @@ main (int argc, char *argv[])
   /* Read the input parameters. */
   ui_read_check_inputs_setup(argc, argv, &p);
 
-  /* Run MakeProfiles */
+  /* Run MakeProfiles. */
   arithmetic(&p);
 
-  /* Free any allocated space */
+  /* Free any allocated space. */
   freeandreport(&p, &t1);
 
   /* Return successfully.*/
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 6fcfcd06..7def4ef8 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -2222,7 +2222,7 @@ In this tutorial, we will just use these three filters.
 Later, you may need to download more filters.
 To do that, you can use the shell's @code{for} loop to download them all in 
series (one after the other@footnote{Note that you only have one port to the 
internet, so downloading in parallel will actually be slower than downloading 
in series.}) with one command like the one below for the WFC3 filters.
 Put this command instead of the three @code{wget} commands above.
-Recall that all the extra spaces, back-slashes (@code{\}), and new lines can 
be ignored if you are typing on the lines on the terminal.
+Recall that all the extra spaces, backslashes (@code{\}), and new lines can be 
ignored if you are typing on the lines on the terminal.
 
 @example
 $ for f in f105w f125w f140w f160w; do \
@@ -19227,8 +19227,8 @@ You now have a stack of two dishes on the table in 
front of you.
 @item
 @command{/} (division) is a binary operator, so pull out the top two elements 
of the stack (top-most is @command{2}, then @command{11}) and divide the second 
one by the first.
 In the kitchen metaphor, the @command{/} operator can be visualized as a 
microwave that takes two dishes.
-But unlike the oven (@code{+} operator) before, the order of inputs matters 
(they are on top of each other: with the top dish holder being the nominator 
and the bottom one being the denominator).
-Again, you look to your stack of dishes on the table.
+But unlike the oven (@code{+} operator) before, the order of inputs matters 
(they are on top of each other: with the top dish holder being the numerator 
and the bottom one being the denominator).
+Again, you look at your stack of dishes on the table.
 
 You pick up the top one (with value 2 inside of it) and put it in the 
microwave's bottom (denominator) dish holder.
 Then you go back to your stack of dishes on the table and pick up the top dish 
(with value 11 inside of it) and put that in the top (nominator) dish holder.
@@ -35081,6 +35081,8 @@ When space cannot be allocated, this function will 
abort the program with a mess
 @code{funcname} (name of the function calling this function) and 
@code{varname} (name of variable that needs this space) will be used in this 
error message if they are not @code{NULL}.
 In most modern compilers, you can use the generic @code{__func__} variable for 
@code{funcname}.
 In this way, you do not have to manually copy and paste the function name or 
worry about it changing later (@code{__func__} was standardized in C99).
+To use this function effectively and avoid memory leaks, make sure to free the 
allocated array after you are done with it.
+Also, be mindful of any functions that make use of this function as they 
should also free any allocated arrays to maintain memory management and prevent 
issues with the system.
 @end deftypefun
 
 @deftypefun {void *} gal_pointer_allocate_ram_or_mmap (uint8_t @code{type}, 
size_t @code{size}, int @code{clear}, size_t @code{minmapsize}, char 
@code{**mmapname}, int @code{quietmmap}, const char @code{*funcname}, const 
char @code{*varname})
@@ -36048,14 +36050,14 @@ If @code{freevalue} is not zero, also free the string 
within the nodes.
 
 @deftypefun {gal_list_str_t *} gal_list_str_extract (char @code{*string})
 Extract space-separated components of the input string.
-If any space element should be kept (and not considered as a delimiter between 
two tokens), precede it with a back-slash (@code{\}).
+If any space element should be kept (and not considered as a delimiter between 
two tokens), precede it with a backslash (@code{\}).
 @end deftypefun
 
 @deftypefun {char *} gal_list_str_cat (gal_list_str_t @code{*list}, char 
@code{delimiter})
 Concatenate (append) the input list of strings into a single string where each 
node is separated from the next with the given @code{delimiter}.
 The space for the output string is allocated by this function and should be 
freed when you have finished with it.
 
-If there is any delimiter characters are present in any of the elements, a 
back-slash (@code{\}) will be printed before the SPACE character.
+If there is any delimiter characters are present in any of the elements, a 
backslash (@code{\}) will be printed before the SPACE character.
 This is necessary, otherwise, a function like @code{gal_list_str_extract} will 
not be able to extract the elements back into separate elements in a list.
 @end deftypefun
 
@@ -42958,7 +42960,7 @@ By default Gnuastro will compile with the @option{-O3} 
optimization flag.
 @cindex Buffers (Emacs)
 @cindex Emacs buffers
 @item
-All Gnuastro hand-written text files (C source code, Texinfo documentation 
source, and version control commit messages) should not exceed @strong{75} 
characters per line.
+All Gnuastro hand-written text files (C source code, Texinfo documentation 
source, and version control commit messages) should normally be no more than 
@strong{75} characters per line.
 Monitors today are certainly much wider, but with this limit, reading the 
functions becomes much more easier.
 Also for the developers, it allows multiple files (or multiple views of one 
file) to be displayed beside each other on wide monitors.
 
diff --git a/lib/arithmetic.c b/lib/arithmetic.c
index 6a2b0c77..700f49ef 100644
--- a/lib/arithmetic.c
+++ b/lib/arithmetic.c
@@ -57,7 +57,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Headers for each binary operator. Since they heavily involve macros,
    their compilation can be very large if they are in a single function and
    file. So there is a separate C source and header file for each of these
-   functions.*/
+   functions. */
 #include <gnuastro-internal/arithmetic-lt.h>
 #include <gnuastro-internal/arithmetic-le.h>
 #include <gnuastro-internal/arithmetic-gt.h>
@@ -255,7 +255,7 @@ arithmetic_bitwise_not(int flags, gal_data_t *in)
      empty (we can have tables and images with 0 rows or pixels!). */
   if(in->size==0 || in->array==NULL) return in;
 
-  /* Check the type */
+  /* Check the type. */
   switch(in->type)
     {
     case GAL_TYPE_FLOAT32:
@@ -357,7 +357,7 @@ arithmetic_abs(int flags, gal_data_t *in)
 
     /* For the signed types, we actually have to go over the data and
        calculate the absolute value. There are unique functions for
-       different types, so we will be using them.*/
+       different types, so we will be using them. */
     case GAL_TYPE_INT8:    ARITHMETIC_ABS_SGN( int8_t,  abs   );  break;
     case GAL_TYPE_INT16:   ARITHMETIC_ABS_SGN( int16_t, abs   );  break;
     case GAL_TYPE_INT32:   ARITHMETIC_ABS_SGN( int32_t, labs  );  break;
@@ -369,7 +369,7 @@ arithmetic_abs(int flags, gal_data_t *in)
             __func__, in->type);
     }
 
-  /* Clean up and return */
+  /* Clean up and return. */
   if( (flags & GAL_ARITHMETIC_FLAG_FREE) && out!=in)
     gal_data_free(in);
   return out;
@@ -550,14 +550,14 @@ arithmetic_function_unary(int operator, int flags, 
gal_data_t *in)
   int inplace=0;
   gal_data_t *o;
 
-  /* The dataset may be empty. In this case, the output should also be empty
-     (we can have tables and images with 0 rows or pixels!). */
+  /* The dataset may be empty. In this case, the output should also be
+     empty (we can have tables and images with 0 rows or pixels!). */
   if(in->size==0 || in->array==NULL) return in;
 
   /* See if the operation should be done in place. The output of these
      operators is defined in the floating point space. So even if the input
-     is integer type and user requested inplace opereation, if its not a
-     floating point type, it will not be in-place. */
+     is an integer type and user requested in place operation, if it's not
+     a floating point type, it will not be in place. */
   if( (flags & GAL_ARITHMETIC_FLAG_INPLACE)
       && ( in->type==GAL_TYPE_FLOAT32 || in->type==GAL_TYPE_FLOAT64 )
       && ( operator != GAL_ARITHMETIC_OP_RA_TO_DEGREE
@@ -574,7 +574,7 @@ arithmetic_function_unary(int operator, int flags, 
gal_data_t *in)
     }
   else
     {
-      /* Check for operators which have fixed output types */
+      /* Check for operators which have fixed output types. */
       if(         operator == GAL_ARITHMETIC_OP_RA_TO_DEGREE
                || operator == GAL_ARITHMETIC_OP_DEC_TO_DEGREE )
         otype = GAL_TYPE_FLOAT64;
@@ -778,7 +778,7 @@ arithmetic_gsl_initialize(int flags, const char **rng_name,
   /* Setup the random number generator. For 'envseed', we want to pass a
      boolean value: either 0 or 1. However, when we say 'flags &
      GAL_ARITHMETIC_ENVSEED', the returned value is the integer positioning
-     of the envseed bit (for example if its on the fourth bit, the value
+     of the envseed bit (for example if it's on the fourth bit, the value
      will be 8). This can cause problems if it is on the 8th bit (or any
      multiple of 8). So to avoid issues with the bit-positioning of the
      'ENVSEED', we will return the conditional to see if the result of the
@@ -787,7 +787,7 @@ arithmetic_gsl_initialize(int flags, const char **rng_name,
                             rng_name, rng_seed);
 
   /* If '--envseed' was called, we need to add the column counter to the
-     requested seed (so its not the same for all columns. */
+     requested seed (so it is not the same for all columns. */
   if(flags & GAL_ARITHMETIC_FLAG_ENVSEED)
     {
       *rng_seed += colcounter++;
@@ -802,7 +802,7 @@ arithmetic_gsl_initialize(int flags, const char **rng_name,
       printf("   - Random number generator seed: %lu\n", *rng_seed);
     }
 
-  /* Return the GSL random number generator */
+  /* Return the GSL random number generator. */
   return rng;
 }
 
@@ -920,7 +920,7 @@ arithmetic_mknoise(int operator, int flags, gal_data_t *in,
 
 
 
-/* Sanity checks for 'random_from_hist' */
+/* Sanity checks for 'random_from_hist'. */
 static void
 arithmetic_random_from_hist_sanity(gal_data_t **inhist, gal_data_t **inbinc,
                                    gal_data_t *in, int operator)
@@ -961,7 +961,7 @@ arithmetic_random_from_hist_sanity(gal_data_t **inhist, 
gal_data_t **inbinc,
   binc=*inbinc=gal_data_copy_to_new_type_free(binc, GAL_TYPE_FLOAT64);
 
   /* For the 'random-from-hist' operator, we will need to assume that the
-     bins are equally spaced and that they are ascending.*/
+     bins are equally spaced and that they are ascending. */
   if(operator==GAL_ARITHMETIC_OP_RANDOM_FROM_HIST)
     {
       d=binc->array;
@@ -1010,7 +1010,7 @@ arithmetic_random_from_hist(int operator, int flags, 
gal_data_t *in,
      empty (we can have tables and images with 0 rows or pixels!). */
   if(in->size==0 || in->array==NULL) return in;
 
-  /* Basic sanity checks */
+  /* Basic sanity checks. */
   arithmetic_random_from_hist_sanity(&hist, &binc, in,
                                      GAL_ARITHMETIC_OP_RANDOM_FROM_HIST);
 
@@ -1116,7 +1116,7 @@ arithmetic_size(int operator, int flags, gal_data_t *in, 
gal_data_t *arg)
     }
 
 
-  /* Sanity checks on the value of the given argument.*/
+  /* Sanity checks on the value of the given argument. */
   if(arg_val>in->ndim)
     error(EXIT_FAILURE, 0, "%s: size operator's dimension argument "
           "(given %zu) cannot be larger than the dimensions of the "
@@ -1136,7 +1136,7 @@ arithmetic_size(int operator, int flags, gal_data_t *in, 
gal_data_t *arg)
   *(size_t *)(out->array)=in->dsize[in->ndim-arg_val];
 
 
-  /* Clean up and return */
+  /* Clean up and return. */
   if(flags & GAL_ARITHMETIC_FLAG_FREE)
     gal_data_free(in);
   return out;
@@ -1198,7 +1198,7 @@ arithmetic_stitch_sanity_check(gal_data_t *list, 
gal_data_t *fdim)
   dim = list->ndim - fitsdim[0];
 
   /* Go through the list of datasets and make sure the dimensionality is
-     fine.*/
+     fine. */
   c=0;
   for(tmp=list; tmp!=NULL; tmp=tmp->next)
     {
@@ -1327,7 +1327,7 @@ arithmetic_stitch(int flags, gal_data_t *list, gal_data_t 
*fdim)
             list->ndim);
     }
 
-  /* Clean up and return */
+  /* Clean up and return. */
   if(flags & GAL_ARITHMETIC_FLAG_FREE)
     gal_list_data_free(list);
   return out;
@@ -1766,7 +1766,7 @@ struct multioperandparams
         /* Read the necessay values from each input. */                 \
         for(i=0;i<p->dnum;++i) pixs[n++]=a[i][j];                       \
                                                                         \
-        /* If there are any elements, measure the  */                   \
+        /* If there are any elements, do the measurement. */            \
         if(n)                                                           \
           {                                                             \
             /* Calculate the quantile and put it in the output. */      \
@@ -1812,7 +1812,7 @@ struct multioperandparams
         /* Read the necessay values from each input. */                 \
         for(i=0;i<p->dnum;++i) pixs[n++]=a[i][j];                       \
                                                                         \
-        /* If there are any usable elements, measure the  */            \
+        /* If there are any usable elements, do the measurement. */     \
         if(n)                                                           \
           {                                                             \
             /* Calculate the sigma-clip and write it in. */             \
@@ -2052,7 +2052,7 @@ arithmetic_multioperand(int operator, int flags, 
gal_data_t *list,
     }
 
 
-  /* Set the output dataset type */
+  /* Set the output dataset type. */
   switch(operator)
     {
     case GAL_ARITHMETIC_OP_MIN:            otype=list->type;       break;
@@ -2149,7 +2149,7 @@ arithmetic_multioperand(int operator, int flags, 
gal_data_t *list,
    don't need to be checked (the floating point standard will do the job
    for us). It is also not necessary to check blanks in bitwise operators,
    but bitwise operators have their own macro
-   ('BINARY_OP_INCR_OT_RT_LT_SET') which doesn' use 'checkblanks'.*/
+   ('BINARY_OP_INCR_OT_RT_LT_SET') which doesn' use 'checkblanks'. */
 int
 gal_arithmetic_binary_checkblank(gal_data_t *l, gal_data_t *r)
 {
@@ -2272,7 +2272,7 @@ arithmetic_binary(int operator, int flags, gal_data_t *l, 
gal_data_t *r)
     }
 
 
-  /* Simple sanity check on the input sizes */
+  /* Simple sanity check on the input sizes. */
   if( !( (flags & GAL_ARITHMETIC_FLAG_NUMOK) && (l->size==1 || r->size==1))
       && gal_dimension_is_different(l, r) )
     error(EXIT_FAILURE, 0, "%s: the non-number inputs to '%s' don't "
@@ -2292,7 +2292,7 @@ arithmetic_binary(int operator, int flags, gal_data_t *l, 
gal_data_t *r)
      efficient memory and CPU usage. Since the number of operators without
      a fixed output type (like the conditionals) is less, by 'default' we
      will set the output type to 'unsigned char', and if any of the other
-     operatrs are given, it will be chosen based on the input types.*/
+     operatrs are given, it will be chosen based on the input types. */
   otype=arithmetic_binary_out_type(operator, l, r);
 
 
@@ -2303,7 +2303,7 @@ arithmetic_binary(int operator, int flags, gal_data_t *l, 
gal_data_t *r)
 
 
   /* If we want inplace output, set the output pointer to one input. Note
-     that the output type can be different from both inputs.  */
+     that the output type can be different from both inputs. */
   if(flags & GAL_ARITHMETIC_FLAG_INPLACE)
     {
       if     (l->type==otype && out_size==l->size)   o = l;
@@ -2449,7 +2449,7 @@ arithmetic_function_binary_flt(int operator, int flags, 
gal_data_t *il,
     }
 
 
-  /* Simple sanity check on the input sizes */
+  /* Simple sanity check on the input sizes. */
   if( !( (flags & GAL_ARITHMETIC_FLAG_NUMOK) && (il->size==1 || ir->size==1))
       && gal_dimension_is_different(il, ir) )
     error(EXIT_FAILURE, 0, "%s: the input datasets don't have the same "
@@ -2476,7 +2476,7 @@ arithmetic_function_binary_flt(int operator, int flags, 
gal_data_t *il,
 
 
   /* If we want inplace output, set the output pointer to one input. Note
-     that the output type can be different from both inputs.  */
+     that the output type can be different from both inputs. */
   if(flags & GAL_ARITHMETIC_FLAG_INPLACE)
     {
       if     (l->type==final_otype && out_size==l->size)   o = l;
@@ -2880,7 +2880,7 @@ arithmetic_makenew(gal_data_t *sizes)
   dsize=gal_pointer_allocate(GAL_TYPE_SIZE_T, ndim, 1, __func__, "dsize");
   while(tmp!=NULL)
     {
-      /* Set the next pointer and conver this one to size_t.  */
+      /* Set the next pointer and conver this one to size_t. */
       ttmp=tmp->next;
       tmp=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_SIZE_T);
 
@@ -3082,7 +3082,7 @@ gal_arithmetic_load_col(char *str, int searchin, int 
ignorecase,
   /* This is the shortest possible string (with each component being given
      a one character value). Recall that in C, simply putting literal
      strings after each other, will merge them together into one literal
-     string.*/
+     string. */
   char *checkstr = ( GAL_ARITHMETIC_OPSTR_LOADCOL_PREFIX   "a"
                      GAL_ARITHMETIC_OPSTR_LOADCOL_FILE "a" );
 
@@ -3117,7 +3117,7 @@ gal_arithmetic_load_col(char *str, int searchin, int 
ignorecase,
              function. */
           if(filename || hdu) { free(copy); return NULL; };
 
-          /* Set the current position to '\0' (to end the column name) */
+          /* Set the current position to '\0' (to end the column name). */
           *c='\0';
 
           /* Set the HDU's starting pointer. */
@@ -3254,7 +3254,7 @@ gal_arithmetic_set_operator(char *string, size_t 
*num_operands)
   else if( !strcmp(string, "atanh"))
     { op=GAL_ARITHMETIC_OP_ATANH;             *num_operands=1; }
 
-  /* Units conversion functions */
+  /* Units conversion functions. */
   else if (!strcmp(string, "ra-to-degree"))
     { op=GAL_ARITHMETIC_OP_RA_TO_DEGREE;      *num_operands=1;  }
   else if (!strcmp(string, "dec-to-degree"))
@@ -3457,20 +3457,20 @@ gal_arithmetic_set_operator(char *string, size_t 
*num_operands)
     { op=GAL_ARITHMETIC_OP_BOX_VERTICES_ON_SPHERE; *num_operands=4; }
 
   /* Size and position operators. */
-  else if (!strcmp(string, "swap"))
-    { op=GAL_ARITHMETIC_OP_SWAP;              *num_operands=2;  }
+  else if (!strcmp(string, "size"))
+    { op=GAL_ARITHMETIC_OP_SIZE;              *num_operands=2;  }
+  else if (!strcmp(string, "makenew"))
+    { op=GAL_ARITHMETIC_OP_MAKENEW;           *num_operands=-1; }
   else if (!strcmp(string, "index"))
     { op=GAL_ARITHMETIC_OP_INDEX;             *num_operands=1;  }
+   else if (!strcmp(string, "counter"))
+    { op=GAL_ARITHMETIC_OP_COUNTER;           *num_operands=1;  }
   else if (!strcmp(string, "indexonly"))
     { op=GAL_ARITHMETIC_OP_INDEXONLY;         *num_operands=1;  }
-  else if (!strcmp(string, "counter"))
-    { op=GAL_ARITHMETIC_OP_COUNTER;           *num_operands=1;  }
   else if (!strcmp(string, "counteronly"))
     { op=GAL_ARITHMETIC_OP_COUNTERONLY;       *num_operands=1;  }
-  else if (!strcmp(string, "makenew"))
-    { op=GAL_ARITHMETIC_OP_MAKENEW;           *num_operands=-1; }
-  else if (!strcmp(string, "size"))
-    { op=GAL_ARITHMETIC_OP_SIZE;              *num_operands=2;  }
+  else if (!strcmp(string, "swap"))
+    { op=GAL_ARITHMETIC_OP_SWAP;              *num_operands=2;  }
   else if (!strcmp(string, "constant"))
     { op=GAL_ARITHMETIC_OP_CONSTANT;          *num_operands=2;  }
 
@@ -3601,9 +3601,6 @@ gal_arithmetic_operator_string(int operator)
     case GAL_ARITHMETIC_OP_RANDOM_FROM_HIST:return "random-from-hist";
     case GAL_ARITHMETIC_OP_RANDOM_FROM_HIST_RAW:return "random-from-hist-raw";
 
-    case GAL_ARITHMETIC_OP_SIZE:            return "size";
-    case GAL_ARITHMETIC_OP_TRIM:            return "trim";
-    case GAL_ARITHMETIC_OP_TO1D:            return "to-1d";
     case GAL_ARITHMETIC_OP_STITCH:          return "stitch";
 
     case GAL_ARITHMETIC_OP_TO_UINT8:        return "uchar";
@@ -3630,13 +3627,14 @@ gal_arithmetic_operator_string(int operator)
     case GAL_ARITHMETIC_OP_BOX_AROUND_ELLIPSE: return "box-around-ellipse";
     case GAL_ARITHMETIC_OP_BOX_VERTICES_ON_SPHERE: return "vertices-on-sphere";
 
-    case GAL_ARITHMETIC_OP_SWAP:            return "swap";
+    case GAL_ARITHMETIC_OP_SIZE:            return "size";
+    case GAL_ARITHMETIC_OP_MAKENEW:         return "makenew";
     case GAL_ARITHMETIC_OP_INDEX:           return "index";
-    case GAL_ARITHMETIC_OP_CONSTANT:        return "constant";
     case GAL_ARITHMETIC_OP_COUNTER:         return "counter";
     case GAL_ARITHMETIC_OP_INDEXONLY:       return "indexonly";
     case GAL_ARITHMETIC_OP_COUNTERONLY:     return "counteronly";
-    case GAL_ARITHMETIC_OP_MAKENEW:         return "makenew";
+    case GAL_ARITHMETIC_OP_SWAP:            return "swap";
+    case GAL_ARITHMETIC_OP_CONSTANT:        return "constant";
 
     case GAL_ARITHMETIC_OP_POOLMAX:         return "pool-max";
     case GAL_ARITHMETIC_OP_POOLMIN:         return "pool-min";
diff --git a/lib/blank.c b/lib/blank.c
index 78264ebf..0cc98fd2 100644
--- a/lib/blank.c
+++ b/lib/blank.c
@@ -48,7 +48,7 @@ gal_blank_write(void *ptr, uint8_t type)
 {
   switch(type)
     {
-    /* Numeric types */
+    /* Numeric types. */
     case GAL_TYPE_UINT8:   *(uint8_t  *)ptr = GAL_BLANK_UINT8;    break;
     case GAL_TYPE_INT8:    *(int8_t   *)ptr = GAL_BLANK_INT8;     break;
     case GAL_TYPE_UINT16:  *(uint16_t *)ptr = GAL_BLANK_UINT16;   break;
@@ -65,7 +65,7 @@ gal_blank_write(void *ptr, uint8_t type)
       gal_checkset_allocate_copy(GAL_BLANK_STRING, ptr);
       break;
 
-    /* Complex types */
+    /* Complex types. */
     case GAL_TYPE_COMPLEX32:
     case GAL_TYPE_COMPLEX64:
       error(EXIT_FAILURE, 0, "%s: complex types are not yet supported",
@@ -130,7 +130,7 @@ gal_blank_initialize(gal_data_t *input)
 
 
 
-/* Initialize an array to the given type's blank values.*/
+/* Initialize an array to the given type's blank values. */
 void
 gal_blank_initialize_array(void *array, size_t size, uint8_t type)
 {
@@ -340,7 +340,7 @@ gal_blank_is(void *pointer, uint8_t type)
   /* Do the checks based on the type. */
   switch(type)
     {
-    /* Numeric types */
+    /* Numeric types. */
     case GAL_TYPE_UINT8:     return *(uint8_t  *)pointer==GAL_BLANK_UINT8;
     case GAL_TYPE_INT8:      return *(int8_t   *)pointer==GAL_BLANK_INT8;
     case GAL_TYPE_UINT16:    return *(uint16_t *)pointer==GAL_BLANK_UINT16;
@@ -356,7 +356,7 @@ gal_blank_is(void *pointer, uint8_t type)
     case GAL_TYPE_STRING:
       if(!strcmp(pointer,GAL_BLANK_STRING)) return 1; else return 0;
 
-    /* Complex types */
+    /* Complex types. */
     case GAL_TYPE_COMPLEX32:
     case GAL_TYPE_COMPLEX64:
       error(EXIT_FAILURE, 0, "%s: complex types are not yet supported",
@@ -449,7 +449,7 @@ gal_blank_present(gal_data_t *input, int updateflag)
   /* Go over the pixels and check: */
   switch(block->type)
     {
-    /* Numeric types */
+    /* Numeric types. */
     case GAL_TYPE_UINT8:     HAS_BLANK( uint8_t  );    break;
     case GAL_TYPE_INT8:      HAS_BLANK( int8_t   );    break;
     case GAL_TYPE_UINT16:    HAS_BLANK( uint16_t );    break;
@@ -472,13 +472,13 @@ gal_blank_present(gal_data_t *input, int updateflag)
       while(++str<strf);
       break;
 
-    /* Complex types */
+    /* Complex types. */
     case GAL_TYPE_COMPLEX32:
     case GAL_TYPE_COMPLEX64:
       error(EXIT_FAILURE, 0, "%s: complex types are not yet supported",
             __func__);
 
-    /* Bit */
+    /* Bit. */
     case GAL_TYPE_BIT:
       error(EXIT_FAILURE, 0, "%s: bit type datasets are not yet supported",
             __func__);
@@ -596,7 +596,7 @@ blank_flag(gal_data_t *input, int blank1_not0)
       /* Go over the pixels and set the output values. */
       switch(input->type)
         {
-        /* Numeric types */
+        /* Numeric types. */
         case GAL_TYPE_UINT8:     FLAG_BLANK( uint8_t  );    break;
         case GAL_TYPE_INT8:      FLAG_BLANK( int8_t   );    break;
         case GAL_TYPE_UINT16:    FLAG_BLANK( uint16_t );    break;
@@ -1227,7 +1227,7 @@ blank_remove_in_list_merge_flags(gal_data_t *thisdata, 
gal_data_t *flag,
   static int warningprinted=0;
 
   /* Ignore the dataset if it has more than one dimension and 'onlydim0' is
-     called*/
+     called. */
   if(onlydim0 && thisdata->ndim>1 && warningprinted==0)
     {
       warningprinted=1;
diff --git a/lib/checkset.c b/lib/checkset.c
index abed6aa1..16e99b82 100644
--- a/lib/checkset.c
+++ b/lib/checkset.c
@@ -60,12 +60,12 @@ gal_checkset_gsl_rng(uint8_t envseed_bool, const char 
**name,
   /* Let GSL read the environment and convert the type name (as string) to
      'gsl_rng_type'. After this function, 'gsl_rng_default' contains the
      generator's type and 'gsl_rng_default_seed' contains the (possibly)
-     given seed.*/
+     given seed. */
   gsl_rng_env_setup();
 
   /* Allocate the random number generator based on the requested type and
      save its name. If no 'GSL_RNG_TYPE' is set, then use a fixed
-     generator.*/
+     generator. */
   rng=gsl_rng_alloc(secure_getenv("GSL_RNG_TYPE")
                     ? gsl_rng_default
                     : gsl_rng_ranlxs1);
@@ -223,7 +223,7 @@ gal_checkset_ram_available(int quietmmap)
         error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for line",
               __func__, linelen*sizeof *line);
 
-      /* Read it line-by-line until you find the key.  */
+      /* Read it line-by-line until you find the key. */
       while( getline(&line, &linelen, file) != -1
              && (ma == GAL_BLANK_SIZE_T || mf == GAL_BLANK_SIZE_T) )
         {
@@ -530,14 +530,14 @@ gal_checkset_dir_part(char *filename)
 
 /* Given a file name, keep the non-directory part. Note that if there
    is no forward slash in the input name, the full input name is
-   considered to be the notdir output.*/
+   considered to be the notdir output. */
 char *
 gal_checkset_not_dir_part(char *filename)
 {
   size_t i, l;
   char *out, *tmp=filename;
 
-  /* Find the first '/' to identify the directory */
+  /* Find the first '/' to identify the directory. */
   l=strlen(filename);
   for(i=l;i!=0;--i)
     if(filename[i]=='/')
@@ -597,7 +597,7 @@ gal_checkset_suffix_separate(char *name, char **outsuffix)
 /* Given a reference filename, add a format of AAAAA-XXXXXX.CCCC where
    'AAAAA' is the base name of the 'reference' argument, 'XXXXX' is a
    random/unique sequence of characters, and 'YYYYY' is the string given to
-   'suffix'. If 'suffix' is NULL, the suffix of 'reference' will be used.*/
+   'suffix'. If 'suffix' is NULL, the suffix of 'reference' will be used. */
 char *
 gal_checkset_make_unique_suffix(char *reference, char *suffix)
 {
@@ -850,20 +850,20 @@ gal_checkset_dir_0_file_1(struct 
gal_options_common_params *cp, char *name,
             }
           else
             error(EXIT_FAILURE, errno, "%s", name);
-          return 1;                    /* It is a file name, GOOD */
+          return 1;                    /* It is a file name, GOOD. */
         }
-      else                             /* Some strange condition, ABORT */
+      else                             /* Some strange condition, ABORT. */
         error(EXIT_FAILURE, errno, "%s", name);
     }
 
-  if(S_ISDIR(nameinfo.st_mode))        /* It is a directory, BAD */
+  if(S_ISDIR(nameinfo.st_mode))        /* It is a directory, BAD. */
     return 0;
   else if (S_ISREG(nameinfo.st_mode))  /* It is a file, GOOD. */
     {
       gal_checkset_writable_remove(name, basename, cp->keep, cp->dontdelete);
       return 1;
     }
-  else                                 /* Not a file or a dir, ABORT */
+  else                                 /* Not a file or a dir, ABORT. */
     error(EXIT_FAILURE, 0, "%s not a file or a directory", name);
 
   error(EXIT_FAILURE, 0, "%s: a bug! The process should not reach the end "
@@ -887,14 +887,14 @@ gal_checkset_automatic_output(struct 
gal_options_common_params *cp,
   size_t i, l, offset=0;
 
   /* Merge the contents of the input name and suffix name (while also
-     allocating the necessary space).*/
+     allocating the necessary space). */
   out=gal_checkset_malloc_cat(inname, suffix);
 
   /* If there is actually a suffix, replace it with the (possibly) existing
      suffix. */
   if(suffix)
     {
-      /* Start from the end of the input array*/
+      /* Start from the end of the input array. */
       l=strlen(inname);
       for(i=l-1;i!=0;--i)
         {
@@ -920,7 +920,7 @@ gal_checkset_automatic_output(struct 
gal_options_common_params *cp,
           /* The input file names can be compressed names (for example
              '.fits.gz'). Currently the only compressed formats
              (decompressed within CFITSIO) are listed in
-             'gal_fits_name_is_fits' and 'gal_fits_suffix_is_fits'.*/
+             'gal_fits_name_is_fits' and 'gal_fits_suffix_is_fits'. */
           else if(out[i]=='.' && !( ( out[i+1]=='g' && out[i+2]=='z' )
                                     || (out[i+1]=='f' && out[i+2]=='z' )
                                     || out[i+1]=='Z' ) )
@@ -1002,7 +1002,7 @@ checkset_directory_writable(char *dirname)
 
 /* Check if dirname is actually a real directory and that we can
    actually write inside of it. To insure all conditions an actual
-   file will be made */
+   file will be made. */
 void
 gal_checkset_check_dir_write_add_slash(char **dirname)
 {
@@ -1099,7 +1099,7 @@ gal_checkset_timestamp(char *filename, char *newext)
   strftime(suffix, 20, "_%H-%M-%S", now);
 
   /* If parsing a filename, take care of its parent directory and
-     update the extension */
+     update the extension. */
   top=gal_checkset_dir_part(filename);
   rawname=gal_checkset_not_dir_part(filename);
   filename=gal_checkset_suffix_separate(rawname, &oldext);
diff --git a/lib/data.c b/lib/data.c
index ee779f55..beb5d68d 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -120,7 +120,7 @@ gal_data_initialize(gal_data_t *data, void *array, uint8_t 
type,
 
   /* Do the simple copying cases. For the display elements, set them all to
      impossible (negative) values so if not explicitly set by later steps,
-     the default values are used if/when printing.*/
+     the default values are used if/when printing. */
   data->flag       = 0;
   data->status     = 0;
   data->disp_width = -1;
@@ -175,7 +175,7 @@ gal_data_initialize(gal_data_t *data, void *array, uint8_t 
type,
 
           /* Print a warning if the size in this dimension is too
              large. May happen when the user (mistakenly) writes a negative
-             value in this dimension.. */
+             value in this dimension. */
           if (dsize[i] >= data_size_limit / 2)
             fprintf(stderr, "%s: WARNING: dsize[%zu] value %zu is probably "
                     "a mistake: it exceeds the limit %zu", __func__, i,
diff --git a/lib/git.c b/lib/git.c
index baf0add6..26a1ea78 100644
--- a/lib/git.c
+++ b/lib/git.c
@@ -29,7 +29,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #include <gnuastro/git.h>
 
-/* Return the result of Git describe and  */
+/* Return the result of Git describe. */
 char *
 gal_git_describe(void)
 {
diff --git a/lib/gnuastro/arithmetic.h b/lib/gnuastro/arithmetic.h
index 2f98d9bc..1c76b4cb 100644
--- a/lib/gnuastro/arithmetic.h
+++ b/lib/gnuastro/arithmetic.h
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #define __GAL_ARITHMETIC_H__
 
 /* Include other headers if necessary here. Note that other header files
-   must be included before the C++ preparations below */
+   must be included before the C++ preparations below. */
 #include <gnuastro/data.h>
 
 
@@ -36,7 +36,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
    programs, this information is kept in 'gnuastro/config.h'. Note that all
    '.c' files must start with the inclusion of 'config.h' and that
    'gnuastro/config.h' is only created at installation time (not present
-   during the building of Gnuastro).*/
+   during the building of Gnuastro). */
 #ifndef IN_GNUASTRO_BUILD
 #include <gnuastro/config.h>
 #endif
@@ -212,17 +212,17 @@ enum gal_arithmetic_operators
   GAL_ARITHMETIC_OP_TO_FLOAT64,   /* Convert to float64.                   */
 
   GAL_ARITHMETIC_OP_BOX_AROUND_ELLIPSE, /* Width/Height of box over ellipse*/
-  GAL_ARITHMETIC_OP_BOX_VERTICES_ON_SPHERE, /* Vert. from center and width*/
+  GAL_ARITHMETIC_OP_BOX_VERTICES_ON_SPHERE, /* Vert. from center and width */
 
   /* Meta operators */
+  GAL_ARITHMETIC_OP_SIZE,         /* Size of the dataset along an axis.    */
   GAL_ARITHMETIC_OP_MAKENEW,      /* Build a new dataset, containing zeros.*/
-  GAL_ARITHMETIC_OP_CONSTANT,     /* Make a row with given constant. */
-  GAL_ARITHMETIC_OP_SIZE,         /* Size of the dataset along an axis     */
   GAL_ARITHMETIC_OP_INDEX,        /* New with the index (counting from 0). */
   GAL_ARITHMETIC_OP_COUNTER,      /* New with the index (counting from 0). */
   GAL_ARITHMETIC_OP_INDEXONLY,    /* New with the index (counting from 0). */
   GAL_ARITHMETIC_OP_COUNTERONLY,  /* New with the index (counting from 1). */
   GAL_ARITHMETIC_OP_SWAP,         /* Swap the top two operands.            */
+  GAL_ARITHMETIC_OP_CONSTANT,     /* Make a row with given constant.       */
 
   /* Pooling operators. */
   GAL_ARITHMETIC_OP_POOLMAX,      /* The pool-max of desired pixels.       */
diff --git a/lib/statistics.c b/lib/statistics.c
index d255f390..9bc2771c 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -94,7 +94,8 @@ gal_statistics_minimum(gal_data_t *input)
       /* Initialize the output with the maximum possible value. */
       gal_type_max(out->type, out->array);
 
-      /* Parse the full input. */
+      /* Parse the full input. A NaN value will always fail a conditional
+         (as if it was larger); so NaNs will not cause problems here.*/
       GAL_TILE_PARSE_OPERATE( input, out, 0, 1,
                               {*o = *i < *o ? *i : *o; ++n;} );
     }
@@ -123,7 +124,8 @@ gal_statistics_maximum(gal_data_t *input)
       /* Initialize the output with the minimum possible value. */
       gal_type_min(out->type, out->array);
 
-      /* Parse the full input. */
+      /* Parse the full input. A NaN value will always fail a conditional
+         (as if it was smaller); so NaNs will not cause problems here.*/
       GAL_TILE_PARSE_OPERATE(input, out, 0, 1,
                              {*o = *i > *o ? *i : *o; ++n;});
     }



reply via email to

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