gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 2dea9a7 011/125: All binary operator types set


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 2dea9a7 011/125: All binary operator types set at configure time
Date: Sun, 23 Apr 2017 22:36:26 -0400 (EDT)

branch: master
commit 2dea9a7808e35d6ab8905010581487841aeafda0
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    All binary operator types set at configure time
    
    Until now the default binary operator types were treated differently from
    the non-default types. But now, they are treated exactly the same as the
    non-default types. This allows greater generality and also makes the
    programming easier, since no type is different from the others.
    
    The options specifying the native binary operator types are also now
    described in the manual.
---
 configure.ac                 | 278 ++++++++++++++++++++++++++++++-------------
 doc/gnuastro.texi            |  49 ++++++++
 lib/Makefile.am              |  18 +--
 lib/config.h.in              |  31 +++--
 lib/data-arithmetic-binary.h | 215 ++++++++++++++++++---------------
 5 files changed, 392 insertions(+), 199 deletions(-)

diff --git a/configure.ac b/configure.ac
index 037d841..2bda5cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,76 +259,184 @@ AC_DEFINE_UNQUOTED([CONF_SHOWFMT], [" %-20s"],
 
 
 
-# Enable the types
-AC_ARG_ENABLE([arith-char],
-              [AS_HELP_STRING([--enable-arith-char],
-                    [Enable direct arithmetic on char.])],
-             [AS_IF([test "x$enable_arith_char" != xno],
-                     [enable_arith_char=1], [enable_arith_char=0])],
-              [enable_arith_char=0])
-AC_DEFINE_UNQUOTED([GAL_CONFIG_ARITH_CHAR], [$enable_arith_char],
-                   [Direct arithmetic on char data.])
-AC_SUBST(HAVE_ARITH_CHAR, [$enable_arith_char])
-
-AC_ARG_ENABLE([arith-ushort],
-              [AS_HELP_STRING([--enable-arith-ushort],
-                    [Enable direct arithmetic on ushort.])],
-             [AS_IF([test "x$enable_arith_ushort" != xno],
-                     [enable_arith_ushort=1], [enable_arith_ushort=0])],
-              [enable_arith_ushort=0])
-AC_DEFINE_UNQUOTED([GAL_CONFIG_ARITH_USHORT], [$enable_arith_ushort],
-                   [Direct arithmetic on unsigned short data.])
-AC_SUBST(HAVE_ARITH_USHORT, [$enable_arith_ushort])
-
-AC_ARG_ENABLE([arith-short],
-              [AS_HELP_STRING([--enable-arith-short],
-                    [Enable direct arithmetic on short.])],
-             [AS_IF([test "x$enable_arith_short" != xno],
-                     [enable_arith_short=1], [enable_arith_short=0])],
-              [enable_arith_short=0])
-AC_DEFINE_UNQUOTED([GAL_CONFIG_ARITH_SHORT], [$enable_arith_short],
-                   [Direct arithmetic on short data.])
-AC_SUBST(HAVE_ARITH_SHORT, [$enable_arith_short])
-
-AC_ARG_ENABLE([arith-uint],
-              [AS_HELP_STRING([--enable-arith-uint],
-                    [Enable direct arithmetic on uint.])],
-             [AS_IF([test "x$enable_arith_uint" != xno],
-                     [enable_arith_uint=1], [enable_arith_uint=0])],
-              [enable_arith_uint=0])
-AC_DEFINE_UNQUOTED([GAL_CONFIG_ARITH_UINT], [$enable_arith_uint],
-                   [Direct arithmetic on unsigned int data.])
-AC_SUBST(HAVE_ARITH_UINT, [$enable_arith_uint])
-
-AC_ARG_ENABLE([arith-int],
-              [AS_HELP_STRING([--enable-arith-int],
-                    [Enable direct arithmetic on int.])],
-             [AS_IF([test "x$enable_arith_int" != xno],
-                     [enable_arith_int=1], [enable_arith_int=0])],
-              [enable_arith_int=0])
-AC_DEFINE_UNQUOTED([GAL_CONFIG_ARITH_INT], [$enable_arith_int],
-                   [Direct arithmetic on int data.])
-AC_SUBST(HAVE_ARITH_INT, [$enable_arith_int])
-
-AC_ARG_ENABLE([arith-ulong],
-              [AS_HELP_STRING([--enable-arith-ulong],
-                    [Enable direct arithmetic on unsigned long.])],
-             [AS_IF([test "x$enable_arith_ulong" != xno],
-                     [enable_arith_ulong=1], [enable_arith_ulong=0])],
-              [enable_arith_ulong=0])
-AC_DEFINE_UNQUOTED([GAL_CONFIG_ARITH_ULONG], [$enable_arith_ulong],
-                   [Direct arithmetic on unsigned long data.])
-AC_SUBST(HAVE_ARITH_ULONG, [$enable_arith_ulong])
-
-AC_ARG_ENABLE([arith-longlong],
-              [AS_HELP_STRING([--enable-arith-longlong],
-                    [Enable direct arithmetic on long long.])],
-             [AS_IF([test "x$enable_arith_longlong" != xno],
-                     [enable_arith_longlong=1], [enable_arith_longlong=0])],
-              [enable_arith_longlong=0])
-AC_DEFINE_UNQUOTED([GAL_CONFIG_ARITH_LONGLONG], [$enable_arith_longlong],
-                   [Direct arithmetic on long long data.])
-AC_SUBST(HAVE_ARITH_LONGLONG, [$enable_arith_longlong])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Choose the types for arithmetic operations. The initial list of values
+# given here specify the default list of types. If they have a value of 1,
+# they will be used unless the user configures with
+# `--disable-bin-op-TYPENAME', or `--enable-bin-op-TYPENAME=no'.
+binop_uchar=1
+binop_char=0
+binop_ushort=0
+binop_short=0
+binop_uint=0
+binop_int=0
+binop_ulong=0
+binop_long=1
+binop_longlong=0
+binop_float=1
+binop_double=1
+
+AC_MSG_CHECKING(whether to compile unsigned char binary data operators)
+AC_ARG_ENABLE([bin-op-uchar],
+              [AS_HELP_STRING([--enable-bin-op-uchar],
+                    [Native binary operators on unsigned char data.])],
+             [AS_IF([test "x$enable_bin_op_uchar" != xno],
+                     [binop_uchar=1], [binop_uchar=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_UCHAR], [$binop_uchar],
+                   [Native binary operations on unsigned char data.])
+AC_SUBST(HAVE_BIN_OP_UCHAR, [$binop_uchar])
+AS_IF([test "x$binop_uchar" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile char binary data operators)
+AC_ARG_ENABLE([bin-op-char],
+              [AS_HELP_STRING([--enable-bin-op-char],
+                    [Native binary operations on char data.])],
+             [AS_IF([test "x$enable_bin_op_char" != xno],
+                     [binop_char=1], [binop_char=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_CHAR], [$binop_char],
+                   [Native binary operations on char data.])
+AC_SUBST(HAVE_BIN_OP_CHAR, [$binop_char])
+AS_IF([test "x$binop_char" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile unsigned short binary data operators)
+AC_ARG_ENABLE([bin-op-ushort],
+              [AS_HELP_STRING([--enable-bin-op-ushort],
+                    [Native binary operators on unsigned short data.])],
+             [AS_IF([test "x$enable_bin_op_ushort" != xno],
+                     [binop_ushort=1], [binop_ushort=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_USHORT], [$binop_ushort],
+                   [Native binary operations on unsigned short data.])
+AC_SUBST(HAVE_BIN_OP_USHORT, [$binop_ushort])
+AS_IF([test "x$binop_ushort" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile short binary data operators)
+AC_ARG_ENABLE([bin-op-short],
+              [AS_HELP_STRING([--enable-bin-op-short],
+                    [Native binary operations on short data.])],
+             [AS_IF([test "x$enable_bin_op_short" != xno],
+                     [binop_short=1], [binop_short=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_SHORT], [$binop_short],
+                   [Native binary operations on short data.])
+AC_SUBST(HAVE_BIN_OP_SHORT, [$binop_short])
+AS_IF([test "x$binop_short" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile unsigned int binary data operators)
+AC_ARG_ENABLE([bin-op-uint],
+              [AS_HELP_STRING([--enable-bin-op-uint],
+                    [Native binary operators on unsigned int data.])],
+             [AS_IF([test "x$enable_bin_op_uint" != xno],
+                     [binop_uint=1], [binop_uint=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_UINT], [$binop_uint],
+                   [Native binary operations on unsigned int data.])
+AC_SUBST(HAVE_BIN_OP_UINT, [$binop_uint])
+AS_IF([test "x$binop_uint" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile int binary data operators)
+AC_ARG_ENABLE([bin-op-int],
+              [AS_HELP_STRING([--enable-bin-op-int],
+                    [Native binary operations on int data.])],
+             [AS_IF([test "x$enable_bin_op_int" != xno],
+                     [binop_int=1], [binop_int=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_INT], [$binop_int],
+                   [Native binary operations on int data.])
+AC_SUBST(HAVE_BIN_OP_INT, [$binop_int])
+AS_IF([test "x$binop_int" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile unsigned long binary data operators)
+AC_ARG_ENABLE([bin-op-ulong],
+              [AS_HELP_STRING([--enable-bin-op-ulong],
+                    [Native binary operators on unsigned long data.])],
+             [AS_IF([test "x$enable_bin_op_ulong" != xno],
+                     [binop_ulong=1], [binop_ulong=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_ULONG], [$binop_ulong],
+                   [Native binary operations on unsigned long data.])
+AC_SUBST(HAVE_BIN_OP_ULONG, [$binop_ulong])
+AS_IF([test "x$binop_ulong" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile long native binary data operators)
+AC_ARG_ENABLE([bin-op-long],
+              [AS_HELP_STRING([--enable-bin-op-long],
+                    [Native binary operations on long data.])],
+             [AS_IF([test "x$enable_bin_op_long" != xno],
+                     [binop_long=1], [binop_long=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_LONG], [$binop_long],
+                   [Native binary operations on long data.])
+AC_SUBST(HAVE_BIN_OP_LONG, [$binop_long])
+AS_IF([test "x$binop_long" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile LONGLONG native binary data operators)
+AC_ARG_ENABLE([bin-op-longlong],
+              [AS_HELP_STRING([--enable-bin-op-longlong],
+                    [Native binary operations on LONGLONG data.])],
+             [AS_IF([test "x$enable_bin_op_longlong" != xno],
+                     [binop_longlong=1], [binop_longlong=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_LONGLONG], [$binop_longlong],
+                   [Native binary operations on LONGLONG data.])
+AC_SUBST(HAVE_BIN_OP_LONG, [$binop_longlong])
+AS_IF([test "x$binop_longlong" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile float native binary data operators)
+AC_ARG_ENABLE([bin-op-float],
+              [AS_HELP_STRING([--enable-bin-op-float],
+                    [Native binary operations on float data.])],
+             [AS_IF([test "x$enable_bin_op_float" != xno],
+                     [binop_float=1], [binop_float=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_FLOAT], [$binop_float],
+                   [Native binary operations on float data.])
+AC_SUBST(HAVE_BIN_OP_FLOAT, [$binop_float])
+AS_IF([test "x$binop_float" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+AC_MSG_CHECKING(whether to compile double native binary data operators)
+AC_ARG_ENABLE([bin-op-double],
+              [AS_HELP_STRING([--enable-bin-op-double],
+                    [Native binary operations on double data.])],
+             [AS_IF([test "x$enable_bin_op_double" != xno],
+                     [binop_double=1], [binop_double=0])], [])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_BIN_OP_DOUBLE], [$binop_double],
+                   [Native binary operations on double data.])
+AC_SUBST(HAVE_BIN_OP_DOUBLE, [$binop_double])
+AS_IF([test "x$binop_double" != x0], [binoptprint=yes], [binoptprint=no])
+AC_MSG_RESULT($binoptprint)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 
@@ -340,91 +448,91 @@ AC_SUBST(HAVE_ARITH_LONGLONG, [$enable_arith_longlong])
 ayes=false
 AC_ARG_ENABLE([convertt],
               [AS_HELP_STRING([--enable-convertt],
-                   [Install ConvertType and other enabled packages only.])],
+                    [Install ConvertType and other enabled packages.])],
              [AS_IF([test "x$enable_convertt" != xno],
                      [enable_convertt=yes; ayes=true])],
               [enable_convertt=notset])
 AC_ARG_ENABLE([convolve],
               [AS_HELP_STRING([--enable-convolve],
-                   [Install Convolve and other enabled packages only.])],
+                    [Install Convolve and other enabled packages.])],
              [AS_IF([test "x$enable_convolve" != xno],
                      [enable_cognvolve=yes; ayes=true])],
               [enable_convolve=notset])
 AC_ARG_ENABLE([cosmiccal],
               [AS_HELP_STRING([--enable-cosmiccal],
-                   [Install CosmicCalculator and other enabled packages 
only.])],
+                    [Install CosmicCalculator and other enabled packages.])],
              [AS_IF([test "x$enable_cosmiccal" != xno],
                      [enable_cosmiccal=yes; ayes=true])],
               [enable_cosmiccal=notset])
 AC_ARG_ENABLE([header],
               [AS_HELP_STRING([--enable-header],
-                   [Install Header and other enabled packages only.])],
+                    [Install Header and other enabled packages.])],
              [AS_IF([test "x$enable_header" != xno],
                      [enable_header=yes; ayes=true])],
               [enable_header=notset])
 AC_ARG_ENABLE([arithmetic],
               [AS_HELP_STRING([--enable-arithmetic],
-                   [Install ImageArithmetic and other enabled packages 
only.])],
+                    [Install ImageArithmetic and other enabled packages.])],
              [AS_IF([test "x$enable_arithmetic" != xno],
                      [enable_arithmetic=yes; ayes=true])],
               [enable_arithmetic=notset])
 AC_ARG_ENABLE([imgcrop],
               [AS_HELP_STRING([--enable-imgcrop],
-                   [Install ImageCrop and other enabled packages only.])],
+                    [Install ImageCrop and other enabled packages.])],
              [AS_IF([test "x$enable_imgcrop" != xno],
                      [enable_imgcrop=yes; ayes=true])],
               [enable_imgcrop=notset])
 AC_ARG_ENABLE([imgstat],
               [AS_HELP_STRING([--enable-imgstat],
-                   [Install ImageStatistics and other enabled packages 
only.])],
+                    [Install ImageStatistics and other enabled packages.])],
              [AS_IF([test "x$enable_imgstat" != xno],
                      [enable_imgstat=yes; ayes=true])],
               [enable_imgstat=notset])
 AC_ARG_ENABLE([imgwarp],
               [AS_HELP_STRING([--enable-imgwarp],
-                   [Install ImageWarp and other enabled packages only.])],
+                    [Install ImageWarp and other enabled packages.])],
              [AS_IF([test "x$enable_imgwarp" != xno],
                      [enable_imgwarp=yes; ayes=true])],
               [enable_imgwarp=notset])
 AC_ARG_ENABLE([mkcatalog],
               [AS_HELP_STRING([--enable-mkcatalog],
-                   [Install MakeCatalog and other enabled packages only.])],
+                    [Install MakeCatalog and other enabled packages.])],
              [AS_IF([test "x$enable_mkcatalog" != xno],
                      [enable_mkcatalog=yes; ayes=true])],
               [enable_mkcatalog=notset])
 AC_ARG_ENABLE([mknoise],
               [AS_HELP_STRING([--enable-mknoise],
-                   [Install MakeNoise and other enabled packages only.])],
+                    [Install MakeNoise and other enabled packages.])],
              [AS_IF([test "x$enable_mknoise" != xno],
                      [enable_mknoise=yes; ayes=true])],
               [enable_mknoise=notset])
 AC_ARG_ENABLE([mkprof],
               [AS_HELP_STRING([--enable-mkprof],
-                   [Install MakeProfile and other enabled packages only.])],
+                    [Install MakeProfile and other enabled packages.])],
              [AS_IF([test "x$enable_mkprof" != xno],
                      [enable_mkprof=yes; ayes=true])],
               [enable_mkprof=notset])
 AC_ARG_ENABLE([noisechisel],
               [AS_HELP_STRING([--enable-noisechisel],
-                   [Install NoiseChisel and other enabled packages only.])],
+                    [Install NoiseChisel and other enabled packages.])],
              [AS_IF([test "x$enable_noisechisel" != xno],
                      [enable_noisechisel=yes; ayes=true])],
               [enable_noisechisel=notset])
 AC_ARG_ENABLE([subtractsky],
               [AS_HELP_STRING([--enable-subtractsky],
-                    [Install SubtractSky and other enabled packages only.])],
+                    [Install SubtractSky and other enabled packages.])],
              [AS_IF([test "x$enable_subtractsky" != xno],
                      [enable_subtractsky=yes; ayes=true])],
               [enable_subtractsky=notset])
 AC_ARG_ENABLE([table],
               [AS_HELP_STRING([--enable-table],
-                    [Install Table and other enabled packages only.])],
+                    [Install Table and other enabled packages.])],
              [AS_IF([test "x$enable_table" != xno],
                      [enable_table=yes; ayes=true])],
               [enable_table=notset])
 #AC_ARG_ENABLE([TEMPLATE],
 #              [AS_HELP_STRING([--enable-TEMPLATE],
-#                  [Install TEMPLATE and other enabled packages only.])],
+#                    [Install TEMPLATE and other enabled packages.])],
 #            [AS_IF([test "x$enable_TEMPLATE" != xno],
 #                     [enable_TEMPLATE=yes; ayes=true])],
 #              [enable_TEMPLATE=notset])
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index d6b8895..10f574d 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -3127,6 +3127,55 @@ Do not build or install the program named 
@file{progname}. This is
 very similar to the @option{--enable-progname}, but will build and
 install all the other programs except this one.
 
address@hidden --enable-bin-op-uchar
address@hidden --enable-bin-op-char
address@hidden --enable-bin-op-ushort
address@hidden --enable-bin-op-short
address@hidden --enable-bin-op-uint
address@hidden --enable-bin-op-int
address@hidden --enable-bin-op-ulong
address@hidden --enable-bin-op-long
address@hidden --enable-bin-op-longlong
address@hidden --enable-bin-op-float
address@hidden --enable-bin-op-double
+Enable the binary data-structure operators to work natively on the
+respective type of data (@option{u} stands for unsigned types). Some types
+are compiled by default, to disable them (or disable any other type),
+either run @option{enable-bin-op-TYPE=no}, or run
address@hidden You can tell which types are acceptable by
+default by inspecting the messages of @command{./configure}.
+
+Binary operators are some of the most common operators to the
address@hidden program or the @code{gal_data_arithmetic} function in
address@hidden library}. To operate most efficiently (as fast as possible
+without using too much of the system resources like memory or CPU), it is
+best to rely on the native types of the input data. For example, if you
+want to add an integer array with a floating point array, using the native
+types, means using the C language's internal type conversion. If we don't
+use the native conversion, then the integer array has to be converted to
+the same type as the floating point array to do the conversion. This will
+consume memory and CPU resources and ultimately slow down the running.
+
+There are many binary operators and in order to have them operate natively
+on of each of the above types, the compiler has to prepare for many
+different conditions. This can greatly slow down the
address@hidden can also greatly increase the file size of the
+library, from a few hundred kilobytes to a few megabytes} (when you run
address@hidden). For example, with only one type, compilation will take
+less than a minute, but if you enable all types, it can take upto an hour
+or more depending on your computer. However, this time that is invested
+once at compilation time will result in great profits each time you run
+Gnuastro programs or libraries, because no internal type conversion will be
+necessary.
+
+Therefore, if you commonly work with very specific data-types, you can add
+them (and remove the default ones you don't need them) with these options
+to speed up your work. Alternatively, GNU/Linux distribution package
+managers who compile once (for all the users who just download the compiled
+programs and executables), can enable all types to help their users.
+
+
+
 @item --enable-gnulibcheck
 @cindex GNU C library
 @cindex Gnulib: GNU Portability Library
diff --git a/lib/Makefile.am b/lib/Makefile.am
index f106b92..89c1c58 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -95,15 +95,19 @@ gnuastro/config.h: Makefile config.h.in
        $(MKDIR_P) gnuastro
        $(SED) -e 's|@address@hidden|$(VERSION)|g'                            \
               -e 's|@address@hidden|$(HAVE_LIBGIT2)|g'                  \
-              -e 's|@address@hidden|$(HAVE_ARITH_CHAR)|g'            \
-              -e 's|@address@hidden|$(HAVE_ARITH_USHORT)|g'        \
-              -e 's|@address@hidden|$(HAVE_ARITH_SHORT)|g'          \
-              -e 's|@address@hidden|$(HAVE_ARITH_UINT)|g'            \
-              -e 's|@address@hidden|$(HAVE_ARITH_INT)|g'              \
-              -e 's|@address@hidden|$(HAVE_ARITH_ULONG)|g'          \
-              -e 's|@address@hidden|$(HAVE_ARITH_LONGLONG)|g'    \
               -e 's|@address@hidden|$(HAVE_WCSLIB_VERSION)|g'    \
               -e 's|@address@hidden|$(HAVE_PTHREAD_BARRIER)|g'  \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_UCHAR)|g'        \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_CHAR)|g'          \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_USHORT)|g'      \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_SHORT)|g'        \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_UINT)|g'          \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_INT)|g'            \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_ULONG)|g'        \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_LONG)|g'          \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_LONGLONG)|g'  \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_FLOAT)|g'        \
+              -e 's|@address@hidden|$(HAVE_BIN_OP_DOUBLE)|g'      \
                $(srcdir)/config.h.in >> address@hidden
        chmod a-w address@hidden
        mv address@hidden $@
diff --git a/lib/config.h.in b/lib/config.h.in
index 5c795fc..8a79b06 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -27,19 +27,28 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-/* Macros. */
-#define GAL_CONFIG_VERSION "@VERSION@"
-#define GAL_CONFIG_HAVE_LIBGIT2 @HAVE_LIBGIT2@
-#define GAL_CONFIG_ARITH_CHAR @HAVE_ARITH_CHAR@
-#define GAL_CONFIG_ARITH_USHORT @HAVE_ARITH_USHORT@
-#define GAL_CONFIG_ARITH_SHORT @HAVE_ARITH_SHORT@
-#define GAL_CONFIG_ARITH_UINT @HAVE_ARITH_UINT@
-#define GAL_CONFIG_ARITH_INT @HAVE_ARITH_INT@
-#define GAL_CONFIG_ARITH_ULONG @HAVE_ARITH_ULONG@
-#define GAL_CONFIG_ARITH_LONGLONG @HAVE_ARITH_LONGLONG@
-#define GAL_CONFIG_HAVE_WCSLIB_VERSION @HAVE_WCSLIB_VERSION@
+/* Configuration macros: */
+
+#define GAL_CONFIG_VERSION              "@VERSION@"
+
+#define GAL_CONFIG_HAVE_LIBGIT2         @HAVE_LIBGIT2@
+
+#define GAL_CONFIG_HAVE_WCSLIB_VERSION  @HAVE_WCSLIB_VERSION@
+
 #define GAL_CONFIG_HAVE_PTHREAD_BARRIER @HAVE_PTHREAD_BARRIER@
 
+#define GAL_CONFIG_BIN_OP_UCHAR         @HAVE_BIN_OP_UCHAR@
+#define GAL_CONFIG_BIN_OP_CHAR          @HAVE_BIN_OP_CHAR@
+#define GAL_CONFIG_BIN_OP_USHORT        @HAVE_BIN_OP_USHORT@
+#define GAL_CONFIG_BIN_OP_SHORT         @HAVE_BIN_OP_SHORT@
+#define GAL_CONFIG_BIN_OP_UINT          @HAVE_BIN_OP_UINT@
+#define GAL_CONFIG_BIN_OP_INT           @HAVE_BIN_OP_INT@
+#define GAL_CONFIG_BIN_OP_ULONG         @HAVE_BIN_OP_ULONG@
+#define GAL_CONFIG_BIN_OP_LONG          @HAVE_BIN_OP_LONG@
+#define GAL_CONFIG_BIN_OP_LONGLONG      @HAVE_BIN_OP_LONGLONG@
+#define GAL_CONFIG_BIN_OP_FLOAT         @HAVE_BIN_OP_FLOAT@
+#define GAL_CONFIG_BIN_OP_DOUBLE        @HAVE_BIN_OP_DOUBLE@
+
 
 
 /* C++ Preparations */
diff --git a/lib/data-arithmetic-binary.h b/lib/data-arithmetic-binary.h
index c9d7336..241d86c 100644
--- a/lib/data-arithmetic-binary.h
+++ b/lib/data-arithmetic-binary.h
@@ -31,7 +31,30 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /************************************************************************/
 /*************      Possibly set binary types to convert    *************/
 /************************************************************************/
-#if GAL_CONFIG_ARITH_CHAR == 1
+#if GAL_CONFIG_BIN_OP_UCHAR == 1
+#define BINARY_LEFT_RIGHT_DONE_UCHAR(LT, RT, OP)                        \
+  case GAL_DATA_TYPE_UCHAR:                                             \
+    BINARY_OPERATOR_FOR_TYPE(LT, RT, unsigned char, OP);                \
+    break;
+#define BINARY_LEFT_DONE_UCHAR(LT, OP)                                  \
+    case GAL_DATA_TYPE_UCHAR:                                           \
+      BINARY_LEFT_RIGHT_DONE(LT, unsigned char, OP);                    \
+      break;
+#define BINARY_MULTISWITCH_UCHAR(OP)                                    \
+    case GAL_DATA_TYPE_UCHAR:                                           \
+      BINARY_LEFT_DONE(unsigned char, OP);                              \
+      break;
+#else
+#define BINARY_LEFT_RIGHT_DONE_UCHAR(LT, RT, OP)
+#define BINARY_LEFT_DONE_UCHAR(LT, OP)
+#define BINARY_MULTISWITCH_UCHAR(OP)
+#endif
+
+
+
+
+
+#if GAL_CONFIG_BIN_OP_CHAR == 1
 #define BINARY_LEFT_RIGHT_DONE_CHAR(LT, RT, OP)                         \
   case GAL_DATA_TYPE_CHAR:                                              \
     BINARY_OPERATOR_FOR_TYPE(LT, RT, char, OP);                         \
@@ -54,18 +77,18 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-#if GAL_CONFIG_ARITH_USHORT == 1
-#define BINARY_LEFT_RIGHT_DONE_USHORT(LT, RT, OP)                         \
-  case GAL_DATA_TYPE_USHORT:                                              \
-    BINARY_OPERATOR_FOR_TYPE(LT, RT, unsigned short, OP);                 \
+#if GAL_CONFIG_BIN_OP_USHORT == 1
+#define BINARY_LEFT_RIGHT_DONE_USHORT(LT, RT, OP)                       \
+  case GAL_DATA_TYPE_USHORT:                                            \
+    BINARY_OPERATOR_FOR_TYPE(LT, RT, unsigned short, OP);               \
     break;
-#define BINARY_LEFT_DONE_USHORT(LT, OP)                                   \
-    case GAL_DATA_TYPE_USHORT:                                            \
-      BINARY_LEFT_RIGHT_DONE(LT, unsigned short, OP);                     \
+#define BINARY_LEFT_DONE_USHORT(LT, OP)                                 \
+    case GAL_DATA_TYPE_USHORT:                                          \
+      BINARY_LEFT_RIGHT_DONE(LT, unsigned short, OP);                   \
       break;
-#define BINARY_MULTISWITCH_USHORT(OP)                                     \
-    case GAL_DATA_TYPE_USHORT:                                            \
-      BINARY_LEFT_DONE(unsigned short, OP);                               \
+#define BINARY_MULTISWITCH_USHORT(OP)                                   \
+    case GAL_DATA_TYPE_USHORT:                                          \
+      BINARY_LEFT_DONE(unsigned short, OP);                             \
       break;
 #else
 #define BINARY_LEFT_RIGHT_DONE_USHORT(LT, RT, OP)
@@ -77,18 +100,18 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-#if GAL_CONFIG_ARITH_SHORT == 1
-#define BINARY_LEFT_RIGHT_DONE_SHORT(LT, RT, OP)                         \
-  case GAL_DATA_TYPE_SHORT:                                              \
-    BINARY_OPERATOR_FOR_TYPE(LT, RT, short, OP);                         \
+#if GAL_CONFIG_BIN_OP_SHORT == 1
+#define BINARY_LEFT_RIGHT_DONE_SHORT(LT, RT, OP)                        \
+  case GAL_DATA_TYPE_SHORT:                                             \
+    BINARY_OPERATOR_FOR_TYPE(LT, RT, short, OP);                        \
     break;
-#define BINARY_LEFT_DONE_SHORT(LT, OP)                                   \
-    case GAL_DATA_TYPE_SHORT:                                            \
-      BINARY_LEFT_RIGHT_DONE(LT, short, OP);                             \
+#define BINARY_LEFT_DONE_SHORT(LT, OP)                                  \
+    case GAL_DATA_TYPE_SHORT:                                           \
+      BINARY_LEFT_RIGHT_DONE(LT, short, OP);                            \
       break;
-#define BINARY_MULTISWITCH_SHORT(OP)                                     \
-    case GAL_DATA_TYPE_SHORT:                                            \
-      BINARY_LEFT_DONE(short, OP);                                       \
+#define BINARY_MULTISWITCH_SHORT(OP)                                    \
+    case GAL_DATA_TYPE_SHORT:                                           \
+      BINARY_LEFT_DONE(short, OP);                                      \
       break;
 #else
 #define BINARY_LEFT_RIGHT_DONE_SHORT(LT, RT, OP)
@@ -100,7 +123,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-#if GAL_CONFIG_ARITH_UINT == 1
+#if GAL_CONFIG_BIN_OP_UINT == 1
 #define BINARY_LEFT_RIGHT_DONE_UINT(LT, RT, OP)                         \
   case GAL_DATA_TYPE_UINT:                                              \
     BINARY_OPERATOR_FOR_TYPE(LT, RT, unsigned int, OP);                 \
@@ -123,18 +146,18 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-#if GAL_CONFIG_ARITH_INT == 1
-#define BINARY_LEFT_RIGHT_DONE_INT(LT, RT, OP)                         \
-  case GAL_DATA_TYPE_INT:                                              \
-    BINARY_OPERATOR_FOR_TYPE(LT, RT, int, OP);                         \
+#if GAL_CONFIG_BIN_OP_INT == 1
+#define BINARY_LEFT_RIGHT_DONE_INT(LT, RT, OP)                          \
+  case GAL_DATA_TYPE_INT:                                               \
+    BINARY_OPERATOR_FOR_TYPE(LT, RT, int, OP);                          \
     break;
-#define BINARY_LEFT_DONE_INT(LT, OP)                                   \
-    case GAL_DATA_TYPE_INT:                                            \
-      BINARY_LEFT_RIGHT_DONE(LT, int, OP);                             \
+#define BINARY_LEFT_DONE_INT(LT, OP)                                    \
+    case GAL_DATA_TYPE_INT:                                             \
+      BINARY_LEFT_RIGHT_DONE(LT, int, OP);                              \
       break;
-#define BINARY_MULTISWITCH_INT(OP)                                     \
-    case GAL_DATA_TYPE_INT:                                            \
-      BINARY_LEFT_DONE(int, OP);                                       \
+#define BINARY_MULTISWITCH_INT(OP)                                      \
+    case GAL_DATA_TYPE_INT:                                             \
+      BINARY_LEFT_DONE(int, OP);                                        \
       break;
 #else
 #define BINARY_LEFT_RIGHT_DONE_INT(LT, RT, OP)
@@ -146,7 +169,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-#if GAL_CONFIG_ARITH_ULONG == 1
+#if GAL_CONFIG_BIN_OP_ULONG == 1
 #define BINARY_LEFT_RIGHT_DONE_ULONG(LT, RT, OP)                        \
     case GAL_DATA_TYPE_ULONG:                                           \
       BINARY_OPERATOR_FOR_TYPE(LT, RT, unsigned long, OP);              \
@@ -169,7 +192,30 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-#if GAL_CONFIG_ARITH_LONGLONG == 1
+#if GAL_CONFIG_BIN_OP_LONG == 1
+#define BINARY_LEFT_RIGHT_DONE_LONG(LT, RT, OP)                         \
+    case GAL_DATA_TYPE_LONG:                                            \
+      BINARY_OPERATOR_FOR_TYPE(LT, RT, long, OP);                       \
+      break;
+#define BINARY_LEFT_DONE_LONG(LT, OP)                                   \
+    case GAL_DATA_TYPE_LONG:                                            \
+      BINARY_LEFT_RIGHT_DONE(LT, long, OP);                             \
+      break;
+#define BINARY_MULTISWITCH_LONG(OP)                                     \
+    case GAL_DATA_TYPE_LONG:                                            \
+      BINARY_LEFT_DONE(long, OP);                                       \
+      break;
+#else
+#define BINARY_LEFT_RIGHT_DONE_LONG(LT, RT, OP)
+#define BINARY_LEFT_DONE_LONG(LT, OP)
+#define BINARY_MULTISWITCH_LONG(OP)
+#endif
+
+
+
+
+
+#if GAL_CONFIG_BIN_OP_LONGLONG == 1
 #define BINARY_LEFT_RIGHT_DONE_LONGLONG(LT, RT, OP)                     \
     case GAL_DATA_TYPE_LONGLONG:                                        \
       BINARY_OPERATOR_FOR_TYPE(LT, RT, LONGLONG, OP);                   \
@@ -192,48 +238,30 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
-#if GAL_ONLY_FLOAT_FOR_FAST_DEBUG == 1
-
-#define BINARY_LEFT_RIGHT_DONE_UCHAR(LT, RT, OP)
-#define BINARY_LEFT_DONE_UCHAR(LT, OP)
-#define BINARY_MULTISWITCH_UCHAR(OP)
-
-#define BINARY_LEFT_RIGHT_DONE_LONG(LT, RT, OP)
-#define BINARY_LEFT_DONE_LONG(LT, OP)
-#define BINARY_MULTISWITCH_LONG(OP)
-
-#define BINARY_LEFT_RIGHT_DONE_DOUBLE(LT, RT, OP)
-#define BINARY_LEFT_DONE_DOUBLE(LT, OP)
-#define BINARY_MULTISWITCH_DOUBLE(OP)
-
-#else
-
-#define BINARY_LEFT_RIGHT_DONE_UCHAR(LT, RT, OP)                        \
-    case GAL_DATA_TYPE_UCHAR:                                           \
-      BINARY_OPERATOR_FOR_TYPE(LT, RT, unsigned char, OP);              \
+#if GAL_CONFIG_BIN_OP_FLOAT == 1
+#define BINARY_LEFT_RIGHT_DONE_FLOAT(LT, RT, OP)                        \
+    case GAL_DATA_TYPE_FLOAT:                                           \
+      BINARY_OPERATOR_FOR_TYPE(LT, RT, float, OP);                      \
       break;
-#define BINARY_LEFT_DONE_UCHAR(LT, OP)                                  \
-    case GAL_DATA_TYPE_UCHAR:                                           \
-      BINARY_LEFT_RIGHT_DONE(LT, unsigned char, OP);                    \
+#define BINARY_LEFT_DONE_FLOAT(LT, OP)                                  \
+    case GAL_DATA_TYPE_FLOAT:                                           \
+      BINARY_LEFT_RIGHT_DONE(LT, float, OP);                            \
       break;
-#define BINARY_MULTISWITCH_UCHAR(OP)                                    \
-    case GAL_DATA_TYPE_UCHAR:                                           \
-      BINARY_LEFT_DONE(unsigned char, OP);                              \
+#define BINARY_MULTISWITCH_FLOAT(OP)                                    \
+    case GAL_DATA_TYPE_FLOAT:                                           \
+      BINARY_LEFT_DONE(float, OP);                                      \
       break;
+#else
+#define BINARY_LEFT_RIGHT_DONE_FLOAT(LT, RT, OP)
+#define BINARY_LEFT_DONE_FLOAT(LT, OP)
+#define BINARY_MULTISWITCH_FLOAT(OP)
+#endif
+
+
+
 
-#define BINARY_LEFT_RIGHT_DONE_LONG(LT, RT, OP)                         \
-    case GAL_DATA_TYPE_LONG:                                            \
-      BINARY_OPERATOR_FOR_TYPE(LT, RT, long, OP);                       \
-      break;
-#define BINARY_LEFT_DONE_LONG(LT, OP)                                   \
-    case GAL_DATA_TYPE_LONG:                                            \
-      BINARY_LEFT_RIGHT_DONE(LT, long, OP);                             \
-      break;
-#define BINARY_MULTISWITCH_LONG(OP)                                     \
-    case GAL_DATA_TYPE_LONG:                                            \
-      BINARY_LEFT_DONE(long, OP);                                       \
-      break;
 
+#if GAL_CONFIG_BIN_OP_DOUBLE == 1
 #define BINARY_LEFT_RIGHT_DONE_DOUBLE(LT, RT, OP)                       \
     case GAL_DATA_TYPE_DOUBLE:                                          \
       BINARY_OPERATOR_FOR_TYPE(LT, RT, double, OP);                     \
@@ -246,7 +274,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
     case GAL_DATA_TYPE_DOUBLE:                                          \
       BINARY_LEFT_DONE(double, OP);                                     \
       break;
-
+#else
+#define BINARY_LEFT_RIGHT_DONE_DOUBLE(LT, RT, OP)
+#define BINARY_LEFT_DONE_DOUBLE(LT, OP)
+#define BINARY_MULTISWITCH_DOUBLE(OP)
 #endif
 
 
@@ -268,6 +299,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
+
+
+
+
 /************************************************************************/
 /*************          Binary conversion macros        *****************/
 /************************************************************************/
@@ -288,21 +323,17 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
   switch(o->type)                                                       \
     {                                                                   \
                                                                         \
-    case GAL_DATA_TYPE_FLOAT:                                           \
-      BINARY_OPERATOR_FOR_TYPE(LT, RT, float, OP);                      \
-      break;                                                            \
-                                                                        \
     BINARY_LEFT_RIGHT_DONE_UCHAR(LT, RT, OP)                            \
-    BINARY_LEFT_RIGHT_DONE_LONG(LT, RT, OP)                             \
-    BINARY_LEFT_RIGHT_DONE_DOUBLE(LT, RT, OP)                           \
-                                                                        \
     BINARY_LEFT_RIGHT_DONE_CHAR(LT, RT, OP)                             \
     BINARY_LEFT_RIGHT_DONE_SHORT(LT, RT, OP)                            \
     BINARY_LEFT_RIGHT_DONE_USHORT(LT, RT, OP)                           \
     BINARY_LEFT_RIGHT_DONE_INT(LT, RT, OP)                              \
     BINARY_LEFT_RIGHT_DONE_UINT(LT, RT, OP)                             \
     BINARY_LEFT_RIGHT_DONE_ULONG(LT, RT, OP)                            \
+    BINARY_LEFT_RIGHT_DONE_LONG(LT, RT, OP)                             \
     BINARY_LEFT_RIGHT_DONE_LONGLONG(LT, RT, OP)                         \
+    BINARY_LEFT_RIGHT_DONE_FLOAT(LT, RT, OP)                            \
+    BINARY_LEFT_RIGHT_DONE_DOUBLE(LT, RT, OP)                           \
                                                                         \
     default:                                                            \
       error(EXIT_FAILURE, 0, "type %d not recognized in "               \
@@ -317,22 +348,17 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
   switch(r->type)                                                       \
     {                                                                   \
                                                                         \
-    case GAL_DATA_TYPE_FLOAT:                                           \
-      BINARY_LEFT_RIGHT_DONE(LT, float, OP);                            \
-      break;                                                            \
-                                                                        \
     BINARY_LEFT_DONE_UCHAR(LT, OP)                                      \
-    BINARY_LEFT_DONE_LONG(LT, OP)                                       \
-    BINARY_LEFT_DONE_DOUBLE(LT, OP)                                     \
-                                                                        \
-                                                                        \
     BINARY_LEFT_DONE_CHAR(LT, OP)                                       \
     BINARY_LEFT_DONE_USHORT(LT, OP)                                     \
     BINARY_LEFT_DONE_SHORT(LT, OP)                                      \
     BINARY_LEFT_DONE_UINT(LT, OP)                                       \
     BINARY_LEFT_DONE_INT(LT, OP)                                        \
     BINARY_LEFT_DONE_ULONG(LT, OP)                                      \
+    BINARY_LEFT_DONE_LONG(LT, OP)                                       \
     BINARY_LEFT_DONE_LONGLONG(LT, OP)                                   \
+    BINARY_LEFT_DONE_FLOAT(LT, OP)                                      \
+    BINARY_LEFT_DONE_DOUBLE(LT, OP)                                     \
                                                                         \
     default:                                                            \
       error(EXIT_FAILURE, 0, "type %d not recognized in "               \
@@ -390,21 +416,18 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
   /* Do the operations based on the different types. */                 \
   switch(l->type)                                                       \
     {                                                                   \
-    case GAL_DATA_TYPE_FLOAT:                                           \
-      BINARY_LEFT_DONE(float, OP);                                      \
-      break;                                                            \
                                                                         \
     BINARY_MULTISWITCH_UCHAR(OP)                                        \
-    BINARY_MULTISWITCH_LONG(OP)                                         \
-    BINARY_MULTISWITCH_DOUBLE(OP)                                       \
-                                                                        \
     BINARY_MULTISWITCH_CHAR(OP)                                         \
     BINARY_MULTISWITCH_USHORT(OP)                                       \
     BINARY_MULTISWITCH_SHORT(OP)                                        \
     BINARY_MULTISWITCH_UINT(OP)                                         \
     BINARY_MULTISWITCH_INT(OP)                                          \
     BINARY_MULTISWITCH_ULONG(OP)                                        \
+    BINARY_MULTISWITCH_LONG(OP)                                         \
     BINARY_MULTISWITCH_LONGLONG(OP)                                     \
+    BINARY_MULTISWITCH_FLOAT(OP)                                        \
+    BINARY_MULTISWITCH_DOUBLE(OP)                                       \
                                                                         \
     default:                                                            \
       error(EXIT_FAILURE, 0, "type %d not recognized in "               \
@@ -414,9 +437,9 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
   /* Clean up. */                                                       \
   if(flags & GAL_DATA_ARITH_FREE)                                       \
     {                                                                   \
-      if     (o==l)            gal_data_free(r);                        \
-      else if(o==r)            gal_data_free(l);                        \
-      else                   { gal_data_free(l); gal_data_free(r); }    \
+      if     (o==l)       gal_data_free(r);                             \
+      else if(o==r)       gal_data_free(l);                             \
+      else              { gal_data_free(l); gal_data_free(r); }         \
     }                                                                   \
 }
 



reply via email to

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