[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 441d684a: Installation: fix GSL Steffen interp
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 441d684a: Installation: fix GSL Steffen interpolation bug |
Date: |
Thu, 3 Mar 2022 18:13:14 -0500 (EST) |
branch: master
commit 441d684a338a8b8640e3ab33786ab64d7962ca69
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Installation: fix GSL Steffen interpolation bug
Until now, Gnuastro compiled the interpolation library based on the GSL
Steffen interpolation without a proper check flag in the configuration
files. This resulted in the following error message when one tried to use
the 'gal_interpolate_1d_make_gsl_spline' function with the
'GAL_INTERPOLATE_1D_STEFFEN' option:
gal_interpolate_1d_make_gsl_spline: Steffen interpolation isn't
available in the system's GNU Scientific Library (GSL). Please install
a more recent GSL (version >= 2.0, released in October 2015) and
rebuild Gnuastro
With this commit, we have defined the 'GAL_CONFIG_HAVE_GSL_INTERP_STEFFEN'
and 'HAVE_GSL_STEFFEN' flags in the configuration and library Makefiles, to
check if the host machine can handle the Steffen interpolation from GSL.
Also, the interpolation example in the Gnuastro manual has been updated to
reflect changes on the 'gal_interpolate_1d_make_gsl_spline'
arguments. Additionally, a sample 'table.txt' file was added to the
example, and the build step using the 'astbuildprog' program was
demonstrated too.
This fixes bug#62127
---
NEWS | 4 +++
configure.ac | 9 ++++--
doc/gnuastro.texi | 63 ++++++++++++++++++++++++++++++---------
lib/Makefile.am | 1 +
lib/gnuastro-internal/config.h.in | 2 ++
lib/interpolate.c | 2 +-
6 files changed, 64 insertions(+), 17 deletions(-)
diff --git a/NEWS b/NEWS
index bfd1e797..2a8a5a81 100644
--- a/NEWS
+++ b/NEWS
@@ -229,6 +229,10 @@ See the end of the file for license conditions.
bug #62112: NoiseChisel crash when '--checktiles' and
'--continueaftercheck' called together; reported by Giulia
Golini.
+ bug #62127: GNU Scientific Library's 1D Steffen interpolation method
+ (that guarantees monotonicity) not used in Gnuastro's
+ library, even if it is present and found at configure time;
+ found and fixed by Pedram Ashofteh Ardakani.
diff --git a/configure.ac b/configure.ac
index d192a000..4e1e7bb5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,6 +12,7 @@
# Original author:
# Mohammad Akhlaghi <mohammad@akhlaghi.org>
# Contributing author(s):
+# Pedram Ashofteh Ardakani <pedramardakani@pm.me>
# Copyright (C) 2015-2022 Free Software Foundation, Inc.
#
# Gnuastro is free software: you can redistribute it and/or modify it
@@ -511,9 +512,13 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <gsl/gsl_interp.h>]],
[[const gsl_interp_type *itype=gsl_interp_steffen;]])],
[AC_MSG_RESULT(yes)
- gsl_version_old=no],
+ gsl_version_old=no; has_gsl_steffen=1;],
[AC_MSG_RESULT(no)
- gsl_version_old=yes; anywarnings=yes;])
+ gsl_version_old=yes; has_gsl_steffen=0; anywarnings=yes;])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_HAVE_GSL_INTERP_STEFFEN],
+ [$has_gsl_steffen],
+ [GSL has the Steffen interpolation])
+AC_SUBST(HAVE_GSL_STEFFEN, [$has_gsl_steffen])
# If the CFITSIO library has the 'fits_is_reentrant' function (it was added
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index c2d59900..bf843ec2 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -6388,7 +6388,7 @@ In this section we explain each program and any specific
note that might be nece
@end menu
@node GNU Scientific Library, CFITSIO, Mandatory dependencies, Mandatory
dependencies
-@subsubsection GNU Scientific library
+@subsubsection GNU Scientific Library
@cindex GNU Scientific Library
The @url{http://www.gnu.org/software/gsl/, GNU Scientific Library}, or GSL, is
a large collection of functions that are very useful in scientific
applications, for example integration, random number generation, and Fast
Fourier Transform among many others.
@@ -26083,13 +26083,13 @@ char *gnuastro_version=GAL_CONFIG_VERSION;
@end deffn
-@deffn Macro GAL_CONFIG_HAVE_LIBGIT2
-Libgit2 is an optional dependency of Gnuastro (see @ref{Optional
dependencies}).
-When it is installed and detected at configure time, this macro will have a
value of @code{1} (one).
-Otherwise, it will have a value of @code{0} (zero).
-Gnuastro also comes with some wrappers to make it easier to use libgit2 (see
@ref{Git wrappers}).
+@deffn Macro GAL_CONFIG_HAVE_GSL_INTERP_STEFFEN
+GNU Scientific Library (GSL) is a mandatory dependency of Gnuastro (see
@ref{GNU Scientific Library}).
+The Steffen interpolation function that can be used in Gnuastro was introduced
in GSL version 2.0 (released in October 2015).
+This macro will have a value of @code{1} if the host GSL contains this feature
at configure time, and @code{0} otherwise.
@end deffn
+
@deffn Macro GAL_CONFIG_HAVE_FITS_IS_REENTRANT
@cindex CFITSIO
This macro will have a value of 1 when the CFITSIO of the host system has the
@code{fits_is_reentrant} function (available from CFITSIO version 3.30).
@@ -26103,18 +26103,22 @@ However, only more recent versions of WCSLIB also
provide its version number.
If the WCSLIB that is installed on the system provides its version (through
the possibly existing @code{wcslib_version} function), this macro will have a
value of one, otherwise it will have a value of zero.
@end deffn
+
@deffn Macro GAL_CONFIG_HAVE_WCSLIB_DIS_H
This macro has a value of 1 if the host's WCSLIB has the @file{wcslib/dis.h}
header for distortion-related operations.
@end deffn
+
@deffn Macro GAL_CONFIG_HAVE_WCSLIB_MJDREF
This macro has a value of 1 if the host's WCSLIB reads and stores the
@file{MJDREF} FITS header keyword as part of its core @code{wcsprm} structure.
@end deffn
+
@deffn Macro GAL_CONFIG_HAVE_WCSLIB_OBSFIX
This macro has a value of 1 if the host's WCSLIB supports the @code{OBSFIX}
feature (used by @code{wcsfix} function to parse the input WCS for known
errors).
@end deffn
+
@deffn Macro GAL_CONFIG_HAVE_PTHREAD_BARRIER
The POSIX threads standard define barriers as an optional requirement.
Therefore, some operating systems choose to not include it.
@@ -26134,6 +26138,15 @@ Their values are commonly either 4 or 8 for 32-bit and
64-bit systems.
You can also get this value with the expression `@code{sizeof size_t}' for
example without having to include this header.
@end deffn
+
+@deffn Macro GAL_CONFIG_HAVE_LIBGIT2
+Libgit2 is an optional dependency of Gnuastro (see @ref{Optional
dependencies}).
+When it is installed and detected at configure time, this macro will have a
value of @code{1} (one).
+Otherwise, it will have a value of @code{0} (zero).
+Gnuastro also comes with some wrappers to make it easier to use libgit2 (see
@ref{Git wrappers}).
+@end deffn
+
+
@node Multithreaded programming, Library data types, Configuration
information, Gnuastro library
@subsection Multithreaded programming (@file{threads.h})
@@ -32991,12 +33004,24 @@ Once @code{gsl_spline} has been initialized by this
function, the
interpolation can be evaluated for any X value within the non-blank range
of the input using @code{gsl_spline_eval} or @code{gsl_spline_eval_e}.
-For example in the small program below, we read the first two columns of
-the table in @file{table.txt} and feed them to this function to later estimate
-the values in the second column for three selected points. You can use
-@ref{BuildProgram} to compile and run this function, see @ref{Library demo
-programs} for more.
+For example in the small program below (@file{sample-interp.c}), we read the
first two columns of the table in @file{table.txt} and feed them to this
function to later estimate the values in the second column for three selected
points.
+You can use @ref{BuildProgram} to compile and run this function, see
@ref{Library demo programs} for more.
+
+Contents of the @file{table.txt} file:
+@example
+@verbatim
+$ cat table.txt
+0 0
+1 2
+3 6
+4 8
+6 12
+8 16
+9 18
+@end verbatim
+@end example
+Contents of the @file{sample-interp.c} file:
@cindex first-in-first-out
@example
#include <stdio.h>
@@ -33014,15 +33039,15 @@ main(void)
gal_list_str_t *cols=NULL;
/* Change the values based on your input table. */
- double points[]=@{1.8, 2.5, 10.3@};
+ double points[]=@{1.8, 2.5, 7@};
/* Read the first two columns from `tab.txt'.
IMPORTANT: the list is first-in-first-out, so the output
column order is the inverse of the input order. */
gal_list_str_add(&cols, "1", 0);
gal_list_str_add(&cols, "2", 0);
- Y=gal_table_read("table.txt", NULL, cols, GAL_TABLE_SEARCH_NAME,
- 0, -1, 1, NULL);
+ Y=gal_table_read("table.txt", NULL, NULL, cols,
+ GAL_TABLE_SEARCH_NAME, 0, 1, -1, 1, NULL);
X=Y->next;
/* Allocate the GSL interpolation accelerator and make the
@@ -33049,6 +33074,16 @@ main(void)
@end example
@end deftypefun
+@noindent
+Compile and run this program with @ref{BuildProgram} to see the interpolation
results for the three points within the program.
+@example
+$ astbuildprog sample-interp.c --quiet
+1.800000: 3.600000
+2.500000: 5.000000
+7.000000: 14.000000
+@end example
+
+
@deftypefun void gal_interpolate_1d_blank (gal_data_t @code{*in}, int
@code{type_1d})
Fill the blank elements of @code{in} using the rest of the elements and the
given interpolation. The interpolation scheme can be set through
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e5a523fd..e438a909 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -147,6 +147,7 @@ gnuastro/config.h: Makefile $(internaldir)/config.h.in
-e 's|@SIZEOF_LONG[@]|$(SIZEOF_LONG)|g' \
-e 's|@HAVE_LIBGIT2[@]|$(HAVE_LIBGIT2)|g' \
-e 's|@SIZEOF_SIZE_T[@]|$(SIZEOF_SIZE_T)|g' \
+ -e 's|@HAVE_GSL_STEFFEN[@]|$(HAVE_GSL_STEFFEN)|g' \
-e 's|@HAVE_WCSLIB_DIS_H[@]|$(HAVE_WCSLIB_DIS_H)|g' \
-e 's|@HAVE_WCSLIB_MJDREF[@]|$(HAVE_WCSLIB_MJDREF)|g' \
-e 's|@HAVE_WCSLIB_OBSFIX[@]|$(HAVE_WCSLIB_OBSFIX)|g' \
diff --git a/lib/gnuastro-internal/config.h.in
b/lib/gnuastro-internal/config.h.in
index 68e29888..eaff909a 100644
--- a/lib/gnuastro-internal/config.h.in
+++ b/lib/gnuastro-internal/config.h.in
@@ -4,6 +4,7 @@ Functions dealing with general aspects of all Gnuastro.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
+ Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Copyright (C) 2016-2022 Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
@@ -38,6 +39,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#define GAL_CONFIG_HAVE_LIBGIT2 @HAVE_LIBGIT2@
+#define GAL_CONFIG_HAVE_GSL_INTERP_STEFFEN @HAVE_GSL_STEFFEN@
#define GAL_CONFIG_HAVE_FITS_IS_REENTRANT @HAVE_FITS_IS_REENTRANT@
#define GAL_CONFIG_HAVE_WCSLIB_VERSION @HAVE_WCSLIB_VERSION@
#define GAL_CONFIG_HAVE_WCSLIB_DIS_H @HAVE_WCSLIB_DIS_H@
diff --git a/lib/interpolate.c b/lib/interpolate.c
index 948c30ed..2361ed17 100644
--- a/lib/interpolate.c
+++ b/lib/interpolate.c
@@ -563,7 +563,7 @@ gal_interpolate_1d_make_gsl_spline(gal_data_t *X,
gal_data_t *Y, int type_1d)
case GAL_INTERPOLATE_1D_AKIMA_PERIODIC:
itype=gsl_interp_akima_periodic; break;
case GAL_INTERPOLATE_1D_STEFFEN:
-#if HAVE_DECL_GSL_INTERP_STEFFEN
+#if GAL_CONFIG_HAVE_GSL_INTERP_STEFFEN
itype=gsl_interp_steffen; break;
#else
error(EXIT_FAILURE, 0, "%s: Steffen interpolation isn't available "
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 441d684a: Installation: fix GSL Steffen interpolation bug,
Mohammad Akhlaghi <=