Skip to content

Commit eb7aa75

Browse files
committed
* Update to cmpfit-1.5
- Minor fixes to avoid check Warnings
1 parent 862653f commit eb7aa75

File tree

13 files changed

+2519
-2349
lines changed

13 files changed

+2519
-2349
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ check
2626
check_win
2727
autom4te.cache
2828
aclocal.m4
29-
29+
configure~

configure

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5431,17 +5431,80 @@ printf "%s\n" "$as_me: WARNING: GDAL $GDAL_VERSION found, but required version i
54315431
##################
54325432
## SZIP
54335433
##################
5434-
if test "x$host_os" = "xdarwin"*; then
5435-
if test -d "/usr/local/opt/libaec"; then
5436-
LDFLAGS="-L/usr/local/opt/libaec/lib $LDFLAGS"
5437-
CPPFLAGS="-I/usr/local/opt/libaec/include $CPPFLAGS"
5438-
elif test -d "/opt/homebrew/opt/libaec"; then
5439-
LDFLAGS="-L/opt/homebrew/opt/libaec/lib $LDFLAGS"
5440-
CPPFLAGS="-I/opt/homebrew/opt/libaec/include $CPPFLAGS"
5441-
fi
5434+
# Detect SZIP / libaec
5435+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SZIP / libaec library" >&5
5436+
printf %s "checking for SZIP / libaec library... " >&6; }
5437+
5438+
case "$host_os" in
5439+
darwin*)
5440+
# Homebrew paths
5441+
echo "---------------------"
5442+
echo "-- We are in macOS --"
5443+
echo "---------------------"
5444+
if test -d "/opt/homebrew/opt/libaec"; then
5445+
LDFLAGS="-L/opt/homebrew/opt/libaec/lib $LDFLAGS"
5446+
CPPFLAGS="-I/opt/homebrew/opt/libaec/include $CPPFLAGS"
5447+
elif test -d "/usr/local/opt/libaec"; then
5448+
LDFLAGS="-L/usr/local/opt/libaec/lib $LDFLAGS"
5449+
CPPFLAGS="-I/usr/local/opt/libaec/include $CPPFLAGS"
5450+
fi
5451+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SZ_BufftoBuffCompress in -laec" >&5
5452+
printf %s "checking for SZ_BufftoBuffCompress in -laec... " >&6; }
5453+
if test ${ac_cv_lib_aec_SZ_BufftoBuffCompress+y}
5454+
then :
5455+
printf %s "(cached) " >&6
5456+
else case e in #(
5457+
e) ac_check_lib_save_LIBS=$LIBS
5458+
LIBS="-laec $LIBS"
5459+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5460+
/* end confdefs.h. */
5461+
5462+
/* Override any GCC internal prototype to avoid an error.
5463+
Use char because int might match the return type of a GCC
5464+
builtin and then its argument prototype would still apply.
5465+
The 'extern "C"' is for builds by C++ compilers;
5466+
although this is not generally supported in C code supporting it here
5467+
has little cost and some practical benefit (sr 110532). */
5468+
#ifdef __cplusplus
5469+
extern "C"
5470+
#endif
5471+
char SZ_BufftoBuffCompress (void);
5472+
int
5473+
main (void)
5474+
{
5475+
return SZ_BufftoBuffCompress ();
5476+
;
5477+
return 0;
5478+
}
5479+
_ACEOF
5480+
if ac_fn_c_try_link "$LINENO"
5481+
then :
5482+
ac_cv_lib_aec_SZ_BufftoBuffCompress=yes
5483+
else case e in #(
5484+
e) ac_cv_lib_aec_SZ_BufftoBuffCompress=no ;;
5485+
esac
54425486
fi
5487+
rm -f core conftest.err conftest.$ac_objext conftest.beam \
5488+
conftest$ac_exeext conftest.$ac_ext
5489+
LIBS=$ac_check_lib_save_LIBS ;;
5490+
esac
5491+
fi
5492+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_aec_SZ_BufftoBuffCompress" >&5
5493+
printf "%s\n" "$ac_cv_lib_aec_SZ_BufftoBuffCompress" >&6; }
5494+
if test "x$ac_cv_lib_aec_SZ_BufftoBuffCompress" = xyes
5495+
then :
5496+
HAVE_LIBSZ="yes"
54435497

5444-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SZ_BufftoBuffCompress in -lsz" >&5
5498+
printf "%s\n" "#define HAVE_LIBSZ 1" >>confdefs.h
5499+
5500+
else case e in #(
5501+
e) as_fn_error $? "could not find SZIP (libaec) in Homebrew" "$LINENO" 5 ;;
5502+
esac
5503+
fi
5504+
5505+
;;
5506+
*)
5507+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SZ_BufftoBuffCompress in -lsz" >&5
54455508
printf %s "checking for SZ_BufftoBuffCompress in -lsz... " >&6; }
54465509
if test ${ac_cv_lib_sz_SZ_BufftoBuffCompress+y}
54475510
then :
@@ -5492,12 +5555,16 @@ printf "%s\n" "#define HAVE_LIBSZ 1" >>confdefs.h
54925555

54935556
else case e in #(
54945557
e) as_fn_error $? "could not find SZIP (libaec):
5495-
Debian/Ubuntu: sudo apt install libaec-dev
5496-
RPM-based: sudo dnf install libaec-devel
5497-
macOS: brew install libaec" "$LINENO" 5 ;;
5558+
Debian/Ubuntu: sudo apt install libaec-dev
5559+
RPM-based: sudo dnf install libaec-devel
5560+
macOS: brew install libaec" "$LINENO" 5 ;;
54985561
esac
54995562
fi
55005563

5564+
;;
5565+
esac
5566+
5567+
55015568

55025569
##################
55035570
## LIBZ

configure.ac

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,39 @@ AX_LIB_GDAL2()
3636
##################
3737
## SZIP
3838
##################
39-
if test "x$host_os" = "xdarwin"*; then
40-
if test -d "/usr/local/opt/libaec"; then
41-
LDFLAGS="-L/usr/local/opt/libaec/lib $LDFLAGS"
42-
CPPFLAGS="-I/usr/local/opt/libaec/include $CPPFLAGS"
43-
elif test -d "/opt/homebrew/opt/libaec"; then
44-
LDFLAGS="-L/opt/homebrew/opt/libaec/lib $LDFLAGS"
45-
CPPFLAGS="-I/opt/homebrew/opt/libaec/include $CPPFLAGS"
46-
fi
47-
fi
39+
# Detect SZIP / libaec
40+
AC_MSG_CHECKING([for SZIP / libaec library])
41+
42+
case "$host_os" in
43+
darwin*)
44+
# Homebrew paths
45+
echo "---------------------"
46+
echo "-- We are in macOS --"
47+
echo "---------------------"
48+
if test -d "/opt/homebrew/opt/libaec"; then
49+
LDFLAGS="-L/opt/homebrew/opt/libaec/lib $LDFLAGS"
50+
CPPFLAGS="-I/opt/homebrew/opt/libaec/include $CPPFLAGS"
51+
elif test -d "/usr/local/opt/libaec"; then
52+
LDFLAGS="-L/usr/local/opt/libaec/lib $LDFLAGS"
53+
CPPFLAGS="-I/usr/local/opt/libaec/include $CPPFLAGS"
54+
fi
55+
AC_CHECK_LIB([aec], [SZ_BufftoBuffCompress],
56+
[HAVE_LIBSZ="yes"
57+
AC_DEFINE([HAVE_LIBSZ], [1], [Define if SZIP/libaec is available])],
58+
[AC_MSG_ERROR([could not find SZIP (libaec) in Homebrew])])
59+
;;
60+
*)
61+
AC_CHECK_LIB([sz], [SZ_BufftoBuffCompress],
62+
[HAVE_LIBSZ="yes"
63+
AC_DEFINE([HAVE_LIBSZ], [1], [Define if SZIP/libaec is available])],
64+
[AC_MSG_ERROR([could not find SZIP (libaec):
65+
Debian/Ubuntu: sudo apt install libaec-dev
66+
RPM-based: sudo dnf install libaec-devel
67+
macOS: brew install libaec])])
68+
;;
69+
esac
4870

49-
AC_CHECK_LIB([sz], [SZ_BufftoBuffCompress],
50-
[HAVE_LIBSZ="yes"
51-
AC_DEFINE([HAVE_LIBSZ], [1], [Define if SZIP/libaec is available])],
52-
[AC_MSG_ERROR([could not find SZIP (libaec):
53-
Debian/Ubuntu: sudo apt install libaec-dev
54-
RPM-based: sudo dnf install libaec-devel
55-
macOS: brew install libaec])])
71+
5672

5773
##################
5874
## LIBZ

configure.win

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5431,17 +5431,80 @@ printf "%s\n" "$as_me: WARNING: GDAL $GDAL_VERSION found, but required version i
54315431
##################
54325432
## SZIP
54335433
##################
5434-
if test "x$host_os" = "xdarwin"*; then
5435-
if test -d "/usr/local/opt/libaec"; then
5436-
LDFLAGS="-L/usr/local/opt/libaec/lib $LDFLAGS"
5437-
CPPFLAGS="-I/usr/local/opt/libaec/include $CPPFLAGS"
5438-
elif test -d "/opt/homebrew/opt/libaec"; then
5439-
LDFLAGS="-L/opt/homebrew/opt/libaec/lib $LDFLAGS"
5440-
CPPFLAGS="-I/opt/homebrew/opt/libaec/include $CPPFLAGS"
5441-
fi
5434+
# Detect SZIP / libaec
5435+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SZIP / libaec library" >&5
5436+
printf %s "checking for SZIP / libaec library... " >&6; }
5437+
5438+
case "$host_os" in
5439+
darwin*)
5440+
# Homebrew paths
5441+
echo "---------------------"
5442+
echo "-- We are in macOS --"
5443+
echo "---------------------"
5444+
if test -d "/opt/homebrew/opt/libaec"; then
5445+
LDFLAGS="-L/opt/homebrew/opt/libaec/lib $LDFLAGS"
5446+
CPPFLAGS="-I/opt/homebrew/opt/libaec/include $CPPFLAGS"
5447+
elif test -d "/usr/local/opt/libaec"; then
5448+
LDFLAGS="-L/usr/local/opt/libaec/lib $LDFLAGS"
5449+
CPPFLAGS="-I/usr/local/opt/libaec/include $CPPFLAGS"
5450+
fi
5451+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SZ_BufftoBuffCompress in -laec" >&5
5452+
printf %s "checking for SZ_BufftoBuffCompress in -laec... " >&6; }
5453+
if test ${ac_cv_lib_aec_SZ_BufftoBuffCompress+y}
5454+
then :
5455+
printf %s "(cached) " >&6
5456+
else case e in #(
5457+
e) ac_check_lib_save_LIBS=$LIBS
5458+
LIBS="-laec $LIBS"
5459+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5460+
/* end confdefs.h. */
5461+
5462+
/* Override any GCC internal prototype to avoid an error.
5463+
Use char because int might match the return type of a GCC
5464+
builtin and then its argument prototype would still apply.
5465+
The 'extern "C"' is for builds by C++ compilers;
5466+
although this is not generally supported in C code supporting it here
5467+
has little cost and some practical benefit (sr 110532). */
5468+
#ifdef __cplusplus
5469+
extern "C"
5470+
#endif
5471+
char SZ_BufftoBuffCompress (void);
5472+
int
5473+
main (void)
5474+
{
5475+
return SZ_BufftoBuffCompress ();
5476+
;
5477+
return 0;
5478+
}
5479+
_ACEOF
5480+
if ac_fn_c_try_link "$LINENO"
5481+
then :
5482+
ac_cv_lib_aec_SZ_BufftoBuffCompress=yes
5483+
else case e in #(
5484+
e) ac_cv_lib_aec_SZ_BufftoBuffCompress=no ;;
5485+
esac
54425486
fi
5487+
rm -f core conftest.err conftest.$ac_objext conftest.beam \
5488+
conftest$ac_exeext conftest.$ac_ext
5489+
LIBS=$ac_check_lib_save_LIBS ;;
5490+
esac
5491+
fi
5492+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_aec_SZ_BufftoBuffCompress" >&5
5493+
printf "%s\n" "$ac_cv_lib_aec_SZ_BufftoBuffCompress" >&6; }
5494+
if test "x$ac_cv_lib_aec_SZ_BufftoBuffCompress" = xyes
5495+
then :
5496+
HAVE_LIBSZ="yes"
54435497

5444-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SZ_BufftoBuffCompress in -lsz" >&5
5498+
printf "%s\n" "#define HAVE_LIBSZ 1" >>confdefs.h
5499+
5500+
else case e in #(
5501+
e) as_fn_error $? "could not find SZIP (libaec) in Homebrew" "$LINENO" 5 ;;
5502+
esac
5503+
fi
5504+
5505+
;;
5506+
*)
5507+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SZ_BufftoBuffCompress in -lsz" >&5
54455508
printf %s "checking for SZ_BufftoBuffCompress in -lsz... " >&6; }
54465509
if test ${ac_cv_lib_sz_SZ_BufftoBuffCompress+y}
54475510
then :
@@ -5492,12 +5555,16 @@ printf "%s\n" "#define HAVE_LIBSZ 1" >>confdefs.h
54925555

54935556
else case e in #(
54945557
e) as_fn_error $? "could not find SZIP (libaec):
5495-
Debian/Ubuntu: sudo apt install libaec-dev
5496-
RPM-based: sudo dnf install libaec-devel
5497-
macOS: brew install libaec" "$LINENO" 5 ;;
5558+
Debian/Ubuntu: sudo apt install libaec-dev
5559+
RPM-based: sudo dnf install libaec-devel
5560+
macOS: brew install libaec" "$LINENO" 5 ;;
54985561
esac
54995562
fi
55005563

5564+
;;
5565+
esac
5566+
5567+
55015568

55025569
##################
55035570
## LIBZ

src/Makevars.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
HANCOCKTOOLS_ROOT = tools
33
GEDIRAT_ROOT = gedisimulator
44
LIBCLIDAR_ROOT = libclidar
5-
CMPFIT_ROOT = cmpfit-1.2
5+
CMPFIT_ROOT = cmpfit-1.5
66

77

88
PKG_CFLAGS=@HDF5_CPPFLAGS@ \
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Tranlation to C Language by S. Moshier (moshier.net)
99
Enhancements, documentation and packaging by C. Markwardt
1010
(comparable to IDL fitting routine MPFIT
1111
see http://cow.physics.wisc.edu/~craigm/idl/idl.html)
12-
Copyright (C) 2003, 2004, 2006, 2007, 2009, 2010 Craig B. Markwardt
12+
Copyright (C) 2003, 2004, 2006, 2007, 2009, 2010, 2013 Craig B. Markwardt
1313

1414

1515
SUMMARY of CHANGES
@@ -21,8 +21,14 @@ SUMMARY of CHANGES
2121
04 Oct 2010 - - add static declarations, remove some compiler warnings
2222
(reported by Lars Kr. Lundin)
2323
13 Nov 2010 - version 1.2 - additional documentation, cleanup of mpfit.h
24+
23 Apr 2013 - version 1.3 - add MP_NO_ITER; bug fix mpside=2 when debugging
25+
(thanks to M. Wojdyr)
26+
24 Jan 2020 - version 1.4 - bug fixes for 2-sided derivative calculation and
27+
potential buffer overflow (thanks T. Larsen @ Oliasoft AS)
28+
09 Dec 2022 - version 1.5 - bug fix for mix of analytical + numerical derivatives
29+
(thanks to T. Greeniaus @ Phasesensors)
2430

25-
$Id: README.html,v 1.3 2010/11/13 08:17:15 craigm Exp $
31+
$Id$
2632

2733
INTRODUCTION
2834

@@ -443,12 +449,12 @@ turn is defined as a pointer to the following structure:
443449
double epsfcn; /* Finite derivative step size Default: MP_MACHEP0 */
444450
double stepfactor; /* Initial step bound Default: 100.0 */
445451
double covtol; /* Range tolerance for covariance calculation Default: 1e-14 */
446-
int maxiter; /* Maximum number of iterations. If maxiter == 0,
452+
int maxiter; /* Maximum number of iterations. If maxiter == MP_NO_ITER,
447453
then basic error checking is done, and parameter
448454
errors/covariances are estimated based on input
449455
parameter values, but no fitting iterations are done.
450-
Default: 200
451-
*/
456+
Default: 200
457+
*/
452458
int maxfev; /* Maximum number of function evaluations, or 0 for no limit
453459
Default: 0 (no limit) */
454460
int nprint; /* Default: 1 */
@@ -610,7 +616,7 @@ EXAMPLE 8 - Complete example
610616

611617

612618
This example shows how to fit sample data to a linear function
613-
y = f(x) = a - b*x, where a and b are fitted parameters. There is sample
619+
y = f(x) = a + b*x, where a and b are fitted parameters. There is sample
614620
data included within the program. The parameters are initialized to
615621
a = 1.0, b = 1.0, and then the fitting occurs. The function
616622
residuals; within linfunc(), the value of f(x) is computed. The main
@@ -652,7 +658,7 @@ int linfunc(int m, int n, double *p, double *dy, double **dvec, void *vars)
652658
ey = v->ey;
653659

654660
for (i=0; i<m; i++) {
655-
f = p[0] - p[1]*x[i]; /* Linear fit function; note f = a - b*x */
661+
f = p[0] + p[1]*x[i]; /* Linear fit function; note f = a + b*x */
656662
dy[i] = (y[i] - f)/ey[i];
657663
}
658664

0 commit comments

Comments
 (0)