gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master d9d1651e: Library (arithmetic.h): alt string n


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master d9d1651e: Library (arithmetic.h): alt string names for type conversion operators
Date: Thu, 17 Nov 2022 11:25:28 -0500 (EST)

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

    Library (arithmetic.h): alt string names for type conversion operators
    
    Until now, like all the operators of Arithmetic, the type conversion
    operators of Arithmetic only had a single format. However, when writing
    column metadata in plain-text, we allow for two different formats (for
    example 'i16' or 'int16'). The fact that the short formats weren't
    available in Arithmetic was annoying.
    
    With this commit, the same short strings can now be used to identify the
    type conversion operators of Arithmetic (a single operator can be called
    with two different names on the command-line).
    
    This was added after a discussion with Samane Raji.
---
 NEWS                         | 12 ++++++++++++
 doc/announce-acknowledge.txt |  1 +
 doc/gnuastro.texi            | 27 ++++++++++++++++++---------
 lib/arithmetic.c             | 20 ++++++++++----------
 4 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index d2550a3f..58bc7f39 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,18 @@ See the end of the file for license conditions.
        SDSS). This was suggested by Giulia Golini.
      - nanomaggy-to-counts: convert nanomaggy to counts. This was suggested
        by Giulia Golini.
+   - Alternative (shorter) names for existing operators, added after
+     discussion with Samane Raji.
+     - u8:  same as 'uint8'   (to convert to unsigned 8-bit integers).
+     - i8:  same as 'int8'    (to convert to signed 8-bit integers).
+     - u16: same as 'uint16'  (to convert to unsigned 16-bit integers).
+     - i16: same as 'int16'   (to convert to signed 16-bit integers).
+     - u32: same as 'uint32'  (to convert to unsigned 32-bit integers).
+     - i32: same as 'int32'   (to convert to signed 32-bit integers).
+     - u64: same as 'uint64'  (to convert to unsigned 64-bit integers).
+     - i64: same as 'int64'   (to convert to signed 64-bit integers).
+     - f32: same as 'float32' (to convert to 32-bit floating point).
+     - f64: same as 'float64' (to convert to 64-bit floating point).
 
    Crop:
    --append: if the output file already exists, append the cropped image
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 7bb4529a..f425f60a 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -3,6 +3,7 @@ Alphabetically ordered list to acknowledge in the next release.
 Alejandro Serrano Borlaff
 Sepideh Eskandarlou
 Giulia Golini
+Samane Raji
 Elham Saremi
 Michael Stein
 
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 0e0a9ed7..65ad864f 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -17725,35 +17725,43 @@ You can do this with the @code{float32} operator 
described below.
 
 @table @command
 
-@item uint8
+@item  u8
+@itemx uint8
 Convert the type of the popped operand to 8-bit unsigned integer type (see 
@ref{Numeric data types}).
 The internal conversion of C will be used.
 
-@item int8
+@item i8
+@itemx int8
 Convert the type of the popped operand to 8-bit signed integer type (see 
@ref{Numeric data types}).
 The internal conversion of C will be used.
 
-@item uint16
+@item u16
+@itemx uint16
 Convert the type of the popped operand to 16-bit unsigned integer type (see 
@ref{Numeric data types}).
 The internal conversion of C will be used.
 
-@item int16
+@item i16
+@itemx int16
 Convert the type of the popped operand to 16-bit signed integer (see 
@ref{Numeric data types}).
 The internal conversion of C will be used.
 
-@item uint32
+@item u32
+@itemx uint32
 Convert the type of the popped operand to 32-bit unsigned integer type (see 
@ref{Numeric data types}).
 The internal conversion of C will be used.
 
-@item int32
+@item i32
+@itemx int32
 Convert the type of the popped operand to 32-bit signed integer type (see 
@ref{Numeric data types}).
 The internal conversion of C will be used.
 
-@item uint64
+@item u64
+@itemx uint64
 Convert the type of the popped operand to 64-bit unsigned integer (see 
@ref{Numeric data types}).
 The internal conversion of C will be used.
 
-@item float32
+@item f32
+@itemx float32
 Convert the type of the popped operand to 32-bit (single precision) floating 
point (see @ref{Numeric data types}).
 The internal conversion of C will be used.
 For example, if @file{f64.fits} is a 64-bit floating point image, and you want 
to store it as a 32-bit floating point image, you can use the command below 
(the second command is to show that the output file consumes half the storage)
@@ -17763,7 +17771,8 @@ $ astarithmetic f64.fits float32 --output=f32.fits
 $ ls -lh f64.fits f32.fits
 @end example
 
-@item float64
+@item f64
+@itemx float64
 Convert the type of the popped operand to 64-bit (double precision) floating 
point (see @ref{Numeric data types}).
 The internal conversion of C will be used.
 @end table
diff --git a/lib/arithmetic.c b/lib/arithmetic.c
index 7c29d9ee..8bae6156 100644
--- a/lib/arithmetic.c
+++ b/lib/arithmetic.c
@@ -3144,25 +3144,25 @@ gal_arithmetic_set_operator(char *string, size_t 
*num_operands)
     { op=GAL_ARITHMETIC_OP_BITNOT;            *num_operands=1;  }
 
   /* Type conversion. */
-  else if (!strcmp(string, "uint8"))
+  else if (!strcmp(string, "uint8")   || !strcmp(string, "u8"))
     { op=GAL_ARITHMETIC_OP_TO_UINT8;          *num_operands=1;  }
-  else if (!strcmp(string, "int8"))
+  else if (!strcmp(string, "int8")    || !strcmp(string, "i8"))
     { op=GAL_ARITHMETIC_OP_TO_INT8;           *num_operands=1;  }
-  else if (!strcmp(string, "uint16"))
+  else if (!strcmp(string, "uint16")  || !strcmp(string, "u16"))
     { op=GAL_ARITHMETIC_OP_TO_UINT16;         *num_operands=1;  }
-  else if (!strcmp(string, "int16"))
+  else if (!strcmp(string, "int16")   || !strcmp(string, "i16"))
     { op=GAL_ARITHMETIC_OP_TO_INT16;          *num_operands=1;  }
-  else if (!strcmp(string, "uint32"))
+  else if (!strcmp(string, "uint32")  || !strcmp(string, "u32"))
     { op=GAL_ARITHMETIC_OP_TO_UINT32;         *num_operands=1;  }
-  else if (!strcmp(string, "int32"))
+  else if (!strcmp(string, "int32")   || !strcmp(string, "i32"))
     { op=GAL_ARITHMETIC_OP_TO_INT32;          *num_operands=1;  }
-  else if (!strcmp(string, "uint64"))
+  else if (!strcmp(string, "uint64")  || !strcmp(string, "u64"))
     { op=GAL_ARITHMETIC_OP_TO_UINT64;         *num_operands=1;  }
-  else if (!strcmp(string, "int64"))
+  else if (!strcmp(string, "int64")   || !strcmp(string, "i64"))
     { op=GAL_ARITHMETIC_OP_TO_INT64;          *num_operands=1;  }
-  else if (!strcmp(string, "float32"))
+  else if (!strcmp(string, "float32") || !strcmp(string, "f32"))
     { op=GAL_ARITHMETIC_OP_TO_FLOAT32;        *num_operands=1;  }
-  else if (!strcmp(string, "float64"))
+  else if (!strcmp(string, "float64") || !strcmp(string, "f64"))
     { op=GAL_ARITHMETIC_OP_TO_FLOAT64;        *num_operands=1;  }
 
   /* Constants. */



reply via email to

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