diff -Nru jags-4.1.0/configure jags-4.2.0/configure --- jags-4.1.0/configure 2016-01-14 14:09:02.000000000 +0000 +++ jags-4.2.0/configure 2016-02-09 13:15:23.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for JAGS 4.1.0. +# Generated by GNU Autoconf 2.69 for JAGS 4.2.0. # # Report bugs to . # @@ -592,8 +592,8 @@ # Identity of this package. PACKAGE_NAME='JAGS' PACKAGE_TARNAME='JAGS' -PACKAGE_VERSION='4.1.0' -PACKAGE_STRING='JAGS 4.1.0' +PACKAGE_VERSION='4.2.0' +PACKAGE_STRING='JAGS 4.2.0' PACKAGE_BUGREPORT='martyn_plummer@users.sourceforge.net' PACKAGE_URL='' @@ -1375,7 +1375,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures JAGS 4.1.0 to adapt to many kinds of systems. +\`configure' configures JAGS 4.2.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1445,7 +1445,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of JAGS 4.1.0:";; + short | recursive ) echo "Configuration of JAGS 4.2.0:";; esac cat <<\_ACEOF @@ -1569,7 +1569,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -JAGS configure 4.1.0 +JAGS configure 4.2.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2243,7 +2243,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by JAGS $as_me 4.1.0, which was +It was created by JAGS $as_me 4.2.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2593,7 +2593,7 @@ JAGS_MAJOR=4 -JAGS_MINOR=1 +JAGS_MINOR=2 JAGS_PATCH=0 @@ -2618,7 +2618,7 @@ -$as_echo "#define HG_VERSION \"r6db47652d6aa 2016-01-14\"" >>confdefs.h +$as_echo "#define HG_VERSION \"r689eccd0ad49 2016-02-09\"" >>confdefs.h @@ -2628,7 +2628,7 @@ -$as_echo "#define HG_MONTH_DAY \"0114\"" >>confdefs.h +$as_echo "#define HG_MONTH_DAY \"0209\"" >>confdefs.h ac_aux_dir= @@ -3221,7 +3221,7 @@ # Define the identity of the package. PACKAGE='JAGS' - VERSION='4.1.0' + VERSION='4.2.0' cat >>confdefs.h <<_ACEOF @@ -23819,7 +23819,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by JAGS $as_me 4.1.0, which was +This file was extended by JAGS $as_me 4.2.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -23885,7 +23885,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -JAGS config.status 4.1.0 +JAGS config.status 4.2.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru jags-4.1.0/configure.ac jags-4.2.0/configure.ac --- jags-4.1.0/configure.ac 2015-11-09 08:52:35.000000000 +0000 +++ jags-4.2.0/configure.ac 2016-02-09 13:14:58.000000000 +0000 @@ -2,10 +2,10 @@ AC_PREREQ(2.63) -AC_INIT([JAGS],[4.1.0],[martyn_plummer@users.sourceforge.net],[JAGS]) +AC_INIT([JAGS],[4.2.0],[martyn_plummer@users.sourceforge.net],[JAGS]) JAGS_MAJOR=4 -JAGS_MINOR=1 +JAGS_MINOR=2 JAGS_PATCH=0 AC_SUBST(JAGS_MAJOR) diff -Nru jags-4.1.0/debian/changelog jags-4.2.0/debian/changelog --- jags-4.1.0/debian/changelog 2016-02-22 12:35:17.000000000 +0000 +++ jags-4.2.0/debian/changelog 2016-02-22 12:35:17.000000000 +0000 @@ -1,10 +1,16 @@ -jags (4.1.0-1precise0) precise; urgency=low +jags (4.2.0-1precise0) precise; urgency=low * Compilation for Ubuntu 12.04.5 LTS * debian/control, revert to a version of gfortran that is available * debian/control, revert to a version of g++ that is available - -- Michael Rutter Mon, 18 Jan 2016 14:14:27 +0000 + -- Michael Rutter Mon, 22 Feb 2016 12:32:24 +0000 + +jags (4.2.0-1) unstable; urgency=medium + + * New upstream release + + -- Dirk Eddelbuettel Sun, 21 Feb 2016 22:09:31 -0600 jags (4.1.0-1) unstable; urgency=low diff -Nru jags-4.1.0/doc/manual/jags_installation_manual.tex jags-4.2.0/doc/manual/jags_installation_manual.tex --- jags-4.1.0/doc/manual/jags_installation_manual.tex 2015-11-05 12:54:24.000000000 +0000 +++ jags-4.2.0/doc/manual/jags_installation_manual.tex 2016-02-19 10:47:53.000000000 +0000 @@ -4,7 +4,7 @@ \usepackage{url} \usepackage{multirow} \usepackage{amsfonts} -\newcommand{\release}{4.0.0} +\newcommand{\release}{4.1.0} \newcommand{\JAGS}{\textsf{JAGS}} \newcommand{\BUGS}{\textsf{BUGS}} \newcommand{\WinBUGS}{\textsf{WinBUGS}} @@ -23,7 +23,7 @@ \title{JAGS Version \release\ installation manual} \author{Martyn Plummer \and Bill Northcott \and Matt Denwood} -\date{1 October 2015} +\date{19 January 2016} \maketitle \JAGS\ is distributed in binary format for Microsoft Windows, Mac OS @@ -52,6 +52,14 @@ \begin{verbatim} make check \end{verbatim} +WARNING. If you already have a copy of the jags library installed on +your system then the test program created by \code{make check} will +link against the {\bf installed} library and not the one in your build +directory. So if the test suite includes a regression test for a bug +that was fixed in the version you are building but a previous version +of JAGS is already installed then the unit tests will fail. Best +practice is to run the tests after \code{make install} so the build +and installed versions are the same. \subsection{Configure options} @@ -142,7 +150,7 @@ environment variable \code{LD\_LIBRARY\_PATH}, {\em e.g.} \begin{verbatim} LD_LIBRARY_PATH="/path/to/my/libs:${LD_LIBRARY_PATH}" -\end{verbatim} %$ +\end{verbatim} Alternatively, you may hard-code the paths to the blas and lapack libraries at compile time. This is compiler and platform-specific, but is typically achieved with @@ -150,6 +158,24 @@ LDFLAGS="-L/path/to/my/libs -R/path/to/my/libs \end{verbatim} +JAGS can also be linked to static BLAS and LAPACK if they have both +been compiled with the \texttt{-fPIC} flag. You will probably need to +do a custom build of BLAS and LAPACK if you require this. The +configure options for JAGS are then: +\begin{verbatim} +./configure --with-blas="-L/path/to/my/libs -lmyblas -lgfortran -lquadmath" \ + --with-lapack="-L/path/to/my/libs -lmylapack" +\end{verbatim} +Note that with static linking you must add the dependencies of the BLAS +library manually. The LAPACK library will pick up the same dependencies. +Note also that libtool does not like linking directly to archive files. +If you attempt a configuration of the form +\begin{verbatim} +--with-blas="/path/to/my/libs/myblas.a" +\end{verbatim} +then this will pass at configure time but ``make'' will not correctly +build the JAGS modules. + \subsubsection{Multithreaded BLAS and LAPACK} \label{section:blas:multithreaded} @@ -330,12 +356,13 @@ \subsection{Solaris} \JAGS\ has been successfully built and tested on the Intel x86 -platform under Solaris 11 using the Sun Studio 12.3 compilers. +platform under Solaris 11.3 using the Sun Studio 12.3 and 12.4 +compilers. \begin{verbatim} ./configure CC=cc CXX=CC F77=f95 \ CFLAGS="-xO3 -xarch=sse2" \ FFLAGS="-xO3 -xarch=sse2" \ -CXXFLAGS="-xO3 -xarch=sse2" +CXXFLAGS="-xO3 -xarch=sse2 -library=stlport4" \end{verbatim} The Sun Studio compiler is not optimized by default. Use the option \option{-xO3} for optimization (NB This is the letter ``O'' not the @@ -344,14 +371,20 @@ above are for an Intel processor with SSE2 instructions. This must be adapted to your own platform. -To compile a 64-bit version of JAGS, add the option \option{-m64} to -all the compiler flags. +Starting with release 4.1.0, the default C++ library \file{libCstd} is +no longer supported. You must therefore add the option +\option{-library=stlport4} to \option{CXXFLAGS} to use the alternative +STLPort4 library. + +%C++11? -Solaris provides two versions of the C++ standard library: -\texttt{libCstd}, which is the default, and \texttt{libstlport4}, -which conforms more closely to the C++ standard. \JAGS\ may be linked -to the stlport4 library by adding the option -\option{-library=stlport4} to \code{CXXFLAGS}. +To compile a 64-bit version of JAGS, add the option \option{-m64} to +all the compiler flags. On Solaris, 64-bit files are generally +installed in an architecture-specific sub-directory (e.g. +\file{amd64} on the x86 platform). If you wish to conform to this +convention for 64-bit JAGS then you should set the configure options +\option{--libdir}, \option{--libexecdir}, and \option{--bindir} +appropriately. The configure script automatically detects the Sun Performance library, which implements the BLAS/LAPACK functions. @@ -360,35 +393,31 @@ \section{Mac OS X} There have been big changes in Apple's developer tools over the last few -years. Two major transitions in compiler tools have been made between -OS 10.6 and 10.9: firstly a change from gcc to clang compilers, and -secondly a move from the libstdc++ to libc++ standard library. As of -Mac OS 10.7, Apple has provided a free Xcode application from the Mac -App Store, which is a fairly large download but contains all of the libraries -necessary to install \JAGS. The instructions that follow assume you are -running OS 10.9 or later, and have the free Xcode application from the -Mac App Store. +years, but as of OS 10.9 things should hopefully be more stable. These +instructions are for users that wish to build JAGS using clang and the +libc++ standard library, which have been the default since OS 10.9. Users +needing to build against the libstdc++ library should see section \ref{section:otherosxoptions}, +and users with an older version of OS X should refer to the installation +instructions given in older versions of the \JAGS~manual. \subsection{Required tools} If you wish to build from a released source package i.e. -\file{JAGS-\release.tar.gz}, you will need Xcode from the Mac App Store -as described above. You will also need to install command line compilers -and agree to the Xcode agreement before using them (if you have not -done so already). The easiest way to do this is using the Terminal -application from \file{/Applications/Utilities} - opening the -application gives you a terminal with a UNIX shell known as bash. Run -the command \code{xcode-select --install} on the terminal and follow the +\file{JAGS-\release.tar.gz}, you will need to install command line compilers +and agree to the license agreement before using them. The easiest way +to do this is using the Terminal application from \file{/Applications/Utilities} +- opening the application gives you a terminal with a UNIX shell known as bash. +Run the command \code{xcode-select --install} on the terminal and follow the instructions. Then run the command \code{sudo xcodebuild -license} on the terminal, and follow the instructions to agree to the Apple license terms (an administrators password is required). You will then -need to install the gfortran package which you can find by following the -``tools directory'' link on the ``R for Mac OS X'' page on -\url{http://cran.r-project.org} +need to install the gfortran package which you can download from: + +\url{https://gcc.gnu.org/wiki/GFortranBinaries#MacOS} This setup should be able to build the \JAGS\ sources and also source packages in R. All the necessary libraries such as BLAS and LAPACK are -included within Xcode. Additional tools are required to run the optional +included within OS X. Additional tools are required to run the optional test suite (see section \ref{section:otherosxoptions}). @@ -425,7 +454,7 @@ \end{verbatim} The \texttt{-framework Accelerate} finds the BLAS and LAPACK -contained within the Xcode application. The clang warning +contained within the OS X installation. The clang warning \texttt{-framework Accelerate: `linker' input unused} can be safely ignored. @@ -477,11 +506,9 @@ As of \JAGS\ version 4, a test suite is included with the source code that can be run to ensure that the compiled code produces the expected results. To run this code on your installation, you will need to install the CppUnit framework - this can -be downloaded from \url{https://sourceforge.net/projects/cppunit/} or installed using -MacPorts or similar (see section \ref{section:osxtools}). - -You should then be able to run the test suite from the Terminal -(in the \file{JAGS-\release} folder directory) by typing: +be downloaded from \url{http://freedesktop.org/wiki/Software/cppunit/} or installed using +MacPorts or similar (see section \ref{section:osxtools}). You should then be able to +run the test suite from the Terminal (in the \file{JAGS-\release} folder directory) by typing: \begin{verbatim} make check @@ -504,6 +531,10 @@ 32-bit i386 and 64-bit x86\_64 code) using libstdc++ which will run on OS 10.6 - 10.9. This is compatible with the ``Snow Leopard build'' of \R\ on CRAN and the corresponding \texttt{rjags} and \texttt{runjags} modules. +In addition to the previously stated build requirements, installation of +the (free) Xcode application from the Mac App store is required to be +able to follow these instructions. + In your Terminal window copy/paste the following code (note that there is no space after 'platform' and the '$\backslash$' must not be followed by any spaces): @@ -545,11 +576,12 @@ \subsubsection{Additional tools} \label{section:osxtools} -Apple supplies a compiler suite, BLAS and LAPACK along with Xcode, but some +Apple supplies a compiler suite, BLAS and LAPACK along with OS X developer tools, but some additional tools are required to work with code from the \JAGS\ repository. Probably the easiest way of obtaining the necessary utilities is using -\url{https://www.macports.org} or \url{http://brew.sh} The following sections assume -that MacPorts is installed. +\url{https://www.macports.org} or \url{http://brew.sh} + +The following sections assume that MacPorts is installed. \subsubsection{Working with the development code} @@ -595,7 +627,7 @@ \subsubsection{Using ATLAS} -Rather than using the versions of BLAS and LAPACK provided within Xcode, it +Rather than using the versions of BLAS and LAPACK provided within OS X, it is possible to use ATLAS which can be installed via MacPorts using: \begin{verbatim} @@ -606,13 +638,6 @@ then be omitted from the instructions given in section \ref{section:osxenvironment}. -\subsubsection{A note on Apple compilers} - -Older versions of Xcode used the gcc compiler suite, but Apple abandoned -the gcc project when GPL3 was introduced. Current Apple compilers are -based on LLVM, and are invoked as clang and clang++. The same compilers -are also invoked as gcc and gxx. - \clearpage \section{Windows} diff -Nru jags-4.1.0/NEWS jags-4.2.0/NEWS --- jags-4.1.0/NEWS 2016-01-08 16:14:49.000000000 +0000 +++ jags-4.2.0/NEWS 2016-02-09 13:10:21.000000000 +0000 @@ -1,3 +1,16 @@ +Change in JAGS 4.2.0 + +Bug fixes +========= +* JAGS 4.1.0 did not compile under Solaris Studio 12.3 as it referenced + some C99 functions that are not part of the C++98 standard (It did + compile under Solaris Studio 12.4). +* The non-central t distribution (dnt) was not inserted into the bugs + module. +* The likelihood for left-truncated nodes was not calculated correctly + (This did not affect truncated nodes with no parents, only truncated + outcome variables). + Changes in JAGS 4.1.0 Bug fixes diff -Nru jags-4.1.0/src/lib/distribution/c99_math.c jags-4.2.0/src/lib/distribution/c99_math.c --- jags-4.1.0/src/lib/distribution/c99_math.c 1970-01-01 00:00:00.000000000 +0000 +++ jags-4.2.0/src/lib/distribution/c99_math.c 2016-01-18 17:30:56.000000000 +0000 @@ -0,0 +1,11 @@ +/* Remap some C99 functions for conformance with C++98 */ + +#include + +double jags_expm1(double x) { + return expm1(x); +} + +double jags_log1p(double x) { + return log1p(x); +} diff -Nru jags-4.1.0/src/lib/distribution/c99_math.h jags-4.2.0/src/lib/distribution/c99_math.h --- jags-4.1.0/src/lib/distribution/c99_math.h 1970-01-01 00:00:00.000000000 +0000 +++ jags-4.2.0/src/lib/distribution/c99_math.h 2016-01-18 17:30:56.000000000 +0000 @@ -0,0 +1,11 @@ +#ifndef C99_MATH_H_ +#define C99_MATH_H_ + +extern "C" { + +double jags_expm1(double); +double jags_log1p(double); + +} + +#endif diff -Nru jags-4.1.0/src/lib/distribution/Makefile.am jags-4.2.0/src/lib/distribution/Makefile.am --- jags-4.1.0/src/lib/distribution/Makefile.am 2015-10-01 07:58:10.000000000 +0000 +++ jags-4.2.0/src/lib/distribution/Makefile.am 2016-01-18 17:30:56.000000000 +0000 @@ -3,4 +3,7 @@ libdist_la_CPPFLAGS = -I$(top_srcdir)/src/include libdist_la_SOURCES = Distribution.cc ScalarDist.cc VectorDist.cc \ -ArrayDist.cc DistPtr.cc DistTab.cc DistError.cc RScalarDist.cc +ArrayDist.cc DistPtr.cc DistTab.cc DistError.cc RScalarDist.cc \ +c99_math.c + +noinst_HEADERS = c99_math.h diff -Nru jags-4.1.0/src/lib/distribution/Makefile.in jags-4.2.0/src/lib/distribution/Makefile.in --- jags-4.1.0/src/lib/distribution/Makefile.in 2016-01-14 14:09:05.000000000 +0000 +++ jags-4.2.0/src/lib/distribution/Makefile.in 2016-02-09 13:15:25.000000000 +0000 @@ -14,6 +14,7 @@ @SET_MAKE@ + VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ @@ -80,7 +81,7 @@ host_triplet = @host@ subdir = src/lib/distribution DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp + $(top_srcdir)/depcomp $(noinst_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/R.m4 $(top_srcdir)/m4/argz.m4 \ $(top_srcdir)/m4/ax_lapack.m4 $(top_srcdir)/m4/axx_blas.m4 \ @@ -100,7 +101,7 @@ libdist_la-ScalarDist.lo libdist_la-VectorDist.lo \ libdist_la-ArrayDist.lo libdist_la-DistPtr.lo \ libdist_la-DistTab.lo libdist_la-DistError.lo \ - libdist_la-RScalarDist.lo + libdist_la-RScalarDist.lo libdist_la-c99_math.lo libdist_la_OBJECTS = $(am_libdist_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -122,6 +123,24 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ @@ -147,6 +166,7 @@ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +HEADERS = $(noinst_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -323,12 +343,14 @@ noinst_LTLIBRARIES = libdist.la libdist_la_CPPFLAGS = -I$(top_srcdir)/src/include libdist_la_SOURCES = Distribution.cc ScalarDist.cc VectorDist.cc \ -ArrayDist.cc DistPtr.cc DistTab.cc DistError.cc RScalarDist.cc +ArrayDist.cc DistPtr.cc DistTab.cc DistError.cc RScalarDist.cc \ +c99_math.c +noinst_HEADERS = c99_math.h all: all-am .SUFFIXES: -.SUFFIXES: .cc .lo .o .obj +.SUFFIXES: .c .cc .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -388,6 +410,38 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdist_la-RScalarDist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdist_la-ScalarDist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdist_la-VectorDist.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdist_la-c99_math.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libdist_la-c99_math.lo: c99_math.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdist_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdist_la-c99_math.lo -MD -MP -MF $(DEPDIR)/libdist_la-c99_math.Tpo -c -o libdist_la-c99_math.lo `test -f 'c99_math.c' || echo '$(srcdir)/'`c99_math.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdist_la-c99_math.Tpo $(DEPDIR)/libdist_la-c99_math.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='c99_math.c' object='libdist_la-c99_math.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdist_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdist_la-c99_math.lo `test -f 'c99_math.c' || echo '$(srcdir)/'`c99_math.c .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -559,7 +613,7 @@ done check-am: all-am check: check-am -all-am: Makefile $(LTLIBRARIES) +all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: install: install-am install-exec: install-exec-am diff -Nru jags-4.1.0/src/lib/distribution/RScalarDist.cc jags-4.2.0/src/lib/distribution/RScalarDist.cc --- jags-4.1.0/src/lib/distribution/RScalarDist.cc 2016-01-05 10:58:21.000000000 +0000 +++ jags-4.2.0/src/lib/distribution/RScalarDist.cc 2016-02-19 11:23:23.000000000 +0000 @@ -4,6 +4,8 @@ #include #include +#include "c99_math.h" + #include #include @@ -13,6 +15,10 @@ using std::min; using std::max; +//debuggin +#include +using std::logic_error; + namespace jags { double RScalarDist::calPlower(double lower, @@ -91,10 +97,11 @@ double loglik = d(x, type, parameters, true); if (type != PDF_PRIOR && (lower || upper)) { + //Normalize truncated distributions double ll = l(parameters); - if (lower && *lower < ll) ll = *lower; + if (lower) ll = max(*lower, ll); if (_discrete) ll -= 1; //Adjustment for discrete valued distributions /* In theory, we just have to subtract log[P(lower <= X <= @@ -106,20 +113,22 @@ if (have_lower && have_upper) { if (p(ll, parameters, false, false) < 0.5) { - //Use upper tail + //Use upper tail: log (P(lower <= X) - P(upper < X)) loglik -= log(p(ll, parameters, false, false) - p(*upper, parameters, false, false)); } else { - //Use lower tail + //Use lower tail: log (P(X <= upper) - P(X < lower)) loglik -= log(p(*upper, parameters, true, false) - p(ll, parameters, true, false)); } } else if (have_lower) { + // log P(lower <= X) loglik -= p(ll, parameters, false, true); } else if (have_upper) { + // log P(X <= upper) loglik -= p(*upper, parameters, true, true); } } @@ -164,7 +173,7 @@ else { double logpu = p(*upper, parameters, false, true); double delta = logpu - logpl; - logp += log1p(rng->uniform() * expm1(delta)); + logp += jags_log1p(rng->uniform() * jags_expm1(delta)); } return q(logp, parameters, false, true); } @@ -180,7 +189,7 @@ if (_discrete) ll -= 1; double logpl = p(ll, parameters, true, true); double delta = logpl - logpu; - logp += log1p(rng->uniform() * expm1(delta)); + logp += jags_log1p(rng->uniform() * jags_expm1(delta)); } return q(logp, parameters, true, true); } diff -Nru jags-4.1.0/src/lib/version.cc jags-4.2.0/src/lib/version.cc --- jags-4.1.0/src/lib/version.cc 2016-01-14 14:11:01.000000000 +0000 +++ jags-4.2.0/src/lib/version.cc 2016-02-09 13:16:23.000000000 +0000 @@ -4,7 +4,7 @@ const char * jags_version() { - const char * version = "4.1.0"; + const char * version = "4.2.0"; return version; } diff -Nru jags-4.1.0/src/modules/bugs/bugs.cc jags-4.2.0/src/modules/bugs/bugs.cc --- jags-4.1.0/src/modules/bugs/bugs.cc 2015-11-03 12:49:44.000000000 +0000 +++ jags-4.2.0/src/modules/bugs/bugs.cc 2016-02-03 09:20:02.000000000 +0000 @@ -130,6 +130,7 @@ insert(new DNChisqr); insert(new DNegBin); insert(new DNorm); + insert(new DNT); insert(new DPar); insert(new DPois); insert(new DSample); diff -Nru jags-4.1.0/src/modules/bugs/distributions/testbugsdist.cc jags-4.2.0/src/modules/bugs/distributions/testbugsdist.cc --- jags-4.1.0/src/modules/bugs/distributions/testbugsdist.cc 2016-01-05 10:58:21.000000000 +0000 +++ jags-4.2.0/src/modules/bugs/distributions/testbugsdist.cc 2016-02-19 10:52:16.000000000 +0000 @@ -39,6 +39,7 @@ #include #include #include +#include using std::string; using std::vector; @@ -48,6 +49,7 @@ using std::multiset; using std::abs; using std::ostringstream; +using std::sort; using jags::ScalarDist; using jags::RScalarDist; @@ -245,6 +247,7 @@ inheriting from RScalarDist. */ unsigned int nsim = 100; + unsigned int nsim2 = 10; unsigned int nquant = 10; CPPUNIT_ASSERT_MESSAGE(dist->name(), checkNPar(dist, par.size())); @@ -257,26 +260,25 @@ double p = dist->p(y, par, true, false); CPPUNIT_ASSERT_MESSAGE(dist->name(), p >= 0 && p <= 1); double z = dist->q(p, par, true, false); - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), y, z, tol); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), y, z, tol*abs(y)); //Now do the same on a log scale double logp = dist->p(y, par, true, true); CPPUNIT_ASSERT_MESSAGE(dist->name(), logp <= 0); z = dist->q(logp, par, true, true); - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), y, z, tol); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), y, z, tol*abs(y)); //Using upper tail p = dist->p(y, par, false, false); CPPUNIT_ASSERT_MESSAGE(dist->name(), p >= 0 && p <= 1); z = dist->q(p, par, false, false); - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), y, z, tol); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), y, z, tol*abs(y)); //Upper tail on log scale logp = dist->p(y, par, false, true); CPPUNIT_ASSERT_MESSAGE(dist->name(), logp <= 0); z = dist->q(logp, par, false, true); - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), y, z, tol); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), y, z, tol*abs(y)); } - //FIXME: This may be slow? - for (unsigned int s = 0; s < nsim; ++s) { + for (unsigned int s = 0; s < nsim2; ++s) { // Test truncated sampling for (unsigned int i = 0; i <= nquant; ++i) { @@ -315,8 +317,124 @@ } } } + + rscalar_trunclik(dist, par); +} + +static void scalar_trunclik_discrete(RScalarDist const *dist, + vector const &par, + double bound, bool lower) +{ + // Test normalization of truncated likelihood for discrete variables + // by enumeration + + CPPUNIT_ASSERT(dist->discrete()); + + double delta = lower ? -1 : 1; + double const *ll = 0; + double const *uu = 0; + if (lower) { + uu = &bound; + } + else { + ll = &bound; + } + double lik = 0; + double likmax = dist->logDensity(bound, jags::PDF_FULL, par, ll, uu); + + double x = bound; + for (unsigned int i = 0; i < 1000; ++i) { + double y = dist->logDensity(x, jags::PDF_FULL, par, ll, uu); + lik += exp(y); + if (y > likmax) { + likmax = y; + } + else if (y < likmax - 10) { + break; + } + x += delta; + } + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), 1.0, lik, 1e-2); } +static void scalar_trunclik_cont(RScalarDist const *dist, + vector const &par, + double bound, bool lower) +{ + // Test normalization of truncated likelihood for continuous + // variables by approximate integration using the trapezoid method + + CPPUNIT_ASSERT(!dist->discrete()); + CPPUNIT_ASSERT(jags_finite(bound)); + + //Ensure that the density is finite at the other boundary (ob) + //If not then just return as this method will not work + double ob = lower ? dist->l(par) : dist->u(par); + if (jags_finite(ob)) { + if (!jags_finite(dist->d(ob, jags::PDF_FULL, par, false))) { + return; + } + } + + //Create grid of points for evaluating the likelihood + //If lower==false then the grid is in reverse order + vector x; + unsigned int N = 1000; + if (jags_finite(ob)) { + x.push_back(ob); + } + double pmax = dist->p(bound, par, lower, false); + for (unsigned int i = 1; i < N; ++i) { + x.push_back(dist->q(i*pmax/N, par, lower, false)); + } + x.push_back(bound); + + // Calculate likelihood by trapezoid method + // FIXME: WE could probably do better + double lik = 0; + double const *ll = lower ? 0 : &bound; + double const *uu = lower ? &bound : 0; + double y0 = exp(dist->logDensity(x[0], jags::PDF_FULL, par, ll, uu)); + for (unsigned int i = 1; i < x.size(); ++i) { + double y = exp(dist->logDensity(x[i], jags::PDF_FULL, par, ll, uu)); + lik += (x[i] - x[i-1]) * (y + y0) / 2; + y0 = y; + } + if (!lower) { + lik = -lik; //adjust for reverse grid + } + + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(dist->name(), 1.0, lik, 1.1e-2); +} + + +void BugsDistTest::rscalar_trunclik(RScalarDist const *dist, + vector const &par) +{ + /* + Test likelihood calculations for truncated distributions + */ + CPPUNIT_ASSERT_MESSAGE(dist->name(), checkNPar(dist, par.size())); + CPPUNIT_ASSERT_MESSAGE(dist->name(), dist->checkParameterValue(par)); + + double ll = dist->q(0.1, par, true, false); + double uu = dist->q(0.9, par, true, false); + + if (dist->discrete()) { + scalar_trunclik_discrete(dist, par, ll, true); + scalar_trunclik_discrete(dist, par, ll, false); + scalar_trunclik_discrete(dist, par, uu, true); + scalar_trunclik_discrete(dist, par, uu, false); + } + else { + scalar_trunclik_cont(dist, par, ll, true); + scalar_trunclik_cont(dist, par, ll, false); + scalar_trunclik_cont(dist, par, uu, true); + scalar_trunclik_cont(dist, par, uu, false); + } +} + + static vector mkPar(double const &v1) { vector par; @@ -360,7 +478,7 @@ rscalar_rpq(_dbin, mkPar(0.1, 10)); rscalar_rpq(_dbin, mkPar(0.9, 1)); - + rscalar_rpq(_dchisqr, mkPar(1)); rscalar_rpq(_dchisqr, mkPar(2)); rscalar_rpq(_dchisqr, mkPar(3)); @@ -368,6 +486,7 @@ rscalar_rpq(_ddexp, mkPar(2, 0.1)); rscalar_rpq(_ddexp, mkPar(-5, 2.8)); + rscalar_rpq(_dexp, mkPar(0.1)); rscalar_rpq(_dexp, mkPar(7)); diff -Nru jags-4.1.0/src/modules/bugs/distributions/testbugsdist.h jags-4.2.0/src/modules/bugs/distributions/testbugsdist.h --- jags-4.1.0/src/modules/bugs/distributions/testbugsdist.h 2015-10-30 08:39:05.000000000 +0000 +++ jags-4.2.0/src/modules/bugs/distributions/testbugsdist.h 2016-02-16 08:25:16.000000000 +0000 @@ -61,6 +61,9 @@ void rscalar_rpq(jags::RScalarDist const *dist, std::vector const &par); + void rscalar_trunclik(jags::RScalarDist const *dist, + std::vector const &par); + void kl_scalar(jags::ScalarDist const *dist, std::vector const &par0, std::vector const &par1); diff -Nru jags-4.1.0/src/modules/bugs/functions/testbugsfun.cc jags-4.2.0/src/modules/bugs/functions/testbugsfun.cc --- jags-4.1.0/src/modules/bugs/functions/testbugsfun.cc 2015-10-01 07:58:10.000000000 +0000 +++ jags-4.2.0/src/modules/bugs/functions/testbugsfun.cc 2016-01-18 17:30:56.000000000 +0000 @@ -672,26 +672,29 @@ CPPUNIT_ASSERT_ASSERTION_FAIL(eval(_prod, x0)); //Standard deviation requires at least two elements CPPUNIT_ASSERT_ASSERTION_FAIL(eval(_sd, v0)); - - summary(v0); - summary(v1); - summary(v2); - summary(v3); - summary(v4); - - summary(v1, v1); - summary(v1, v2); - summary(v1, v3); - summary(v1, v4); - - summary(v2, v2); - summary(v2, v3); - summary(v2, v4); - summary(v3, v3); - summary(v3, v4); + //Solaris Studio 12.3 requires some additional hinting for templates + //otherwise could have summary(v0) etc. - summary(v4, v4); + summary<1>(v0); + summary<9>(v1); + summary<5>(v2); + summary<2>(v3); + summary<6>(v4); + + summary<9,9>(v1, v1); + summary<9,5>(v1, v2); + summary<9,2>(v1, v3); + summary<9,6>(v1, v4); + + summary<5,5>(v2, v2); + summary<5,2>(v2, v3); + summary<5,6>(v2, v4); + + summary<2,2>(v3, v3); + summary<2,6>(v3, v4); + + summary<6,6>(v4, v4); } void BugsFunTest::math()