Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions TMB/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: TMB
Type: Package
Title: Template Model Builder: A General Random Effect Tool Inspired by 'ADMB'
Version: 1.7.22
Date: 2021-09-28
Version: 1.7.22-2
Date: 2022-02-12
Authors@R: c(person("Kasper","Kristensen",role=c("aut","cre","cph"),email="kaskr@dtu.dk"),
person("Brad","Bell",role="cph"),
person("Hans","Skaug",role="ctb"),
Expand Down
27 changes: 27 additions & 0 deletions TMB/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
------------------------------------------------------------------------
TMB 1.7.22-2 (2022-02-13)
*** FORKED PATCH VERSION ***
------------------------------------------------------------------------

o Explicitly reference tmbutils::array in tmbutils/density.hpp and
tmbutils/R_inla.hpp. This avoids a namespace clash between
Eigen:: and tmbutils:: when Eigen/Tensor headers are included:

> TMB/include/tmbutils/density.hpp:106:3: error:
> reference to 'array' is ambiguous

o Add `#define R_NO_REMAP` before `#include <Rinternals.h>` in TMB.hpp. This
avoids a compiler error when including <TMB.hpp> is included before <Tensor>
(compiler Apple clang version 13.0.0):

> unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h:122:8: error:
> explicit specialization of non-template struct 'Rf_eval'

o Specify Rf_ prefix in a few locations in tmb_core.hpp and dynamic_data.hpp
where it was omitted (Rf_findVar, Rf_install, Rf_setAttrib, Rf_mkString,
Rf_ScalarLogical).

o Update `inst/include/unsupported/` headers to Eigen 3.4.0 for consistency
with updated headers in `inst/include/Eigen`.


------------------------------------------------------------------------
TMB 1.7.22 (2021-09-28)
------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions TMB/inst/include/TMB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ namespace TMBad {
macros can cause conflicts (as they do not respect the Eigen and
CppAD namespace limits). E.g., the 'length' macro conflicts with
CppAD when compiling with '-std=c++11'. */

#define R_NO_REMAP // avoid Eigen clashes with eval(), length(),
#include <R.h>
#include <Rinternals.h>
#include "toggle_thread_safe_R.hpp"
Expand Down
2 changes: 1 addition & 1 deletion TMB/inst/include/dynamic_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace dynamic_data {
// forward double
SEXP envir = double_to_sexp( tx[0] );
const char* nam = double_to_charptr( tx[1] );
SEXP res = findVar(install(nam), envir);
SEXP res = Rf_findVar(Rf_install(nam), envir);
ty[0] = sexp_to_double( res );
,
// reverse
Expand Down
24 changes: 12 additions & 12 deletions TMB/inst/include/tmb_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ class objective_function
/** \brief Syncronize user's data object. It could be changed between calls to e.g. EvalDoubleFunObject */
void sync_data() {
SEXP env = ENCLOS(this->report);
this->data = findVar(install("data"), env);
this->data = Rf_findVar(Rf_install("data"), env);
}

/** \brief Extract theta vector from objetive function object */
Expand Down Expand Up @@ -1452,7 +1452,7 @@ extern "C"

#ifdef TMBAD_FRAMEWORK
inline int get_num_tapes(SEXP f) {
if (isNull(f))
if (Rf_isNull(f))
return 0;
SEXP tag = R_ExternalPtrTag(f);
if (tag != Rf_install("parallelADFun"))
Expand Down Expand Up @@ -1488,7 +1488,7 @@ SEXP TMBAD_TransformADFunObjectTemplate(TMBad::ADFun<TMBad::ad_aug>* pf, SEXP co
return R_NilValue;
}
SEXP random_order = getListElement(control, "random_order");
int nr = (isNull(random_order) ? 0 : LENGTH(random_order));
int nr = (Rf_isNull(random_order) ? 0 : LENGTH(random_order));
std::vector<TMBad::Index> random;
if (nr != 0) {
random = std::vector<TMBad::Index>(INTEGER(random_order),
Expand Down Expand Up @@ -1823,7 +1823,7 @@ SEXP CPPAD_TransformADFunObject(SEXP f, SEXP control)
std::string method =
CHAR(STRING_ELT(getListElement(control, "method"), 0));
if (method == "num_tapes") { // Get number of tapes
return ScalarInteger(num_tapes);
return Rf_ScalarInteger(num_tapes);
}
else if (method == "tape") { // Print tape
int depth = getListInteger(control, "depth", 1);
Expand Down Expand Up @@ -1862,15 +1862,15 @@ SEXP CPPAD_TransformADFunObject(SEXP f, SEXP control)
int input_size = getListInteger(control, "input_size", 0);
int output_size = getListInteger(control, "output_size", 0);
size_t n = pf->glob.opstack.size();
SEXP ans = PROTECT(allocVector(STRSXP, n));
SEXP ans = PROTECT(Rf_allocVector(STRSXP, n));
for (size_t i=0; i<n; i++) {
std::stringstream strm;
if (address) strm << (void*) pf->glob.opstack[i] << " ";
if (name) strm << pf->glob.opstack[i]->op_name() << " ";
if (input_size) strm << pf->glob.opstack[i]->input_size();
if (output_size) strm << pf->glob.opstack[i]->output_size();
const std::string& tmp = strm.str();
SET_STRING_ELT(ans, i, mkChar(tmp.c_str()));
SET_STRING_ELT(ans, i, Rf_mkChar(tmp.c_str()));
}
UNPROTECT(1);
return ans;
Expand Down Expand Up @@ -1952,7 +1952,7 @@ extern "C"
if(get_reportdims) {
SEXP reportdims;
PROTECT( reportdims = pf -> reportvector.reportdims() );
setAttrib( res, install("reportdims"), reportdims);
Rf_setAttrib( res, Rf_install("reportdims"), reportdims);
UNPROTECT(1);
}
UNPROTECT(2);
Expand Down Expand Up @@ -2516,20 +2516,20 @@ extern "C"
SEXP ans;
PROTECT(ans = R_NilValue);
#ifdef TMBAD_FRAMEWORK
ans = mkString("TMBad");
ans = Rf_mkString("TMBad");
#elif CPPAD_FRAMEWORK
ans = mkString("CppAD");
ans = Rf_mkString("CppAD");
#else
ans = mkString("Unknown");
ans = Rf_mkString("Unknown");
#endif
SEXP openmp_sym, openmp_res;
PROTECT(openmp_sym = R_NilValue);
PROTECT(openmp_res = R_NilValue);
openmp_sym = Rf_install("openmp");
#ifdef _OPENMP
openmp_res = ScalarLogical(1);
openmp_res = Rf_ScalarLogical(1);
#else
openmp_res = ScalarLogical(0);
openmp_res = Rf_ScalarLogical(0);
#endif
Rf_setAttrib(ans, openmp_sym, openmp_res);
UNPROTECT(3);
Expand Down
2 changes: 1 addition & 1 deletion TMB/inst/include/tmbutils/R_inla.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ template<class Type>
// Calculate new SPDE matrices

// Calculate G1 - pt. 1
array<Type> Gtmp(n_tri,3,3);
tmbutils::array<Type> Gtmp(n_tri,3,3);
for(i=0; i<n_tri; i++){
// 1st line: E0(i,) %*% adjH %*% t(E0(i,)), etc.
Gtmp(i,0,0) = (E0(i,0)*(E0(i,0)*adj_H(0,0)+E0(i,1)*adj_H(1,0)) + E0(i,1)*(E0(i,0)*adj_H(0,1)+E0(i,1)*adj_H(1,1))) / (4*Tri_Area(i));
Expand Down
4 changes: 2 additions & 2 deletions TMB/inst/include/tmbutils/density.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public: \
typedef scalartype_ scalartype; \
typedef vector<scalartype> vectortype; \
typedef matrix<scalartype> matrixtype; \
typedef array<scalartype> arraytype
typedef tmbutils::array<scalartype> arraytype

#define VARIANCE_NOT_YET_IMPLEMENTED \
private: \
Expand Down Expand Up @@ -730,7 +730,7 @@ class contAR2_t{
scalartype operator()(vectortype x){ /* x.dim=[2,n] */
vector<int> dim(2);
dim << 2 , x.size()/2 ;
array<scalartype> y(x,dim);
tmbutils::array<scalartype> y(x,dim);
y=y.transpose();
return this->operator()(y.col(0),y.col(1));
}
Expand Down
14 changes: 9 additions & 5 deletions TMB/inst/include/unsupported/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
add_subdirectory(Eigen)
add_subdirectory(doc EXCLUDE_FROM_ALL)
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
add_subdirectory(test) # can't do EXCLUDE_FROM_ALL here, breaks CTest
else()
add_subdirectory(test EXCLUDE_FROM_ALL)
if(EIGEN_BUILD_DOC)
add_subdirectory(doc EXCLUDE_FROM_ALL)
endif()
if(BUILD_TESTING)
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
add_subdirectory(test) # can't do EXCLUDE_FROM_ALL here, breaks CTest
else()
add_subdirectory(test EXCLUDE_FROM_ALL)
endif()
endif()
5 changes: 4 additions & 1 deletion TMB/inst/include/unsupported/Eigen/AdolcForward
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# undef realloc
#endif

#include <Eigen/Core>
#include "../../Eigen/Core"

namespace Eigen {

Expand Down Expand Up @@ -74,6 +74,9 @@ inline adouble imag(const adouble&) { return 0.; }
inline adouble abs(const adouble& x) { return fabs(x); }
inline adouble abs2(const adouble& x) { return x*x; }

inline bool (isinf)(const adouble& x) { return (Eigen::numext::isinf)(x.getValue()); }
inline bool (isnan)(const adouble& x) { return (Eigen::numext::isnan)(x.getValue()); }

}

namespace Eigen {
Expand Down
12 changes: 11 additions & 1 deletion TMB/inst/include/unsupported/Eigen/AlignedVector3
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#ifndef EIGEN_ALIGNED_VECTOR3
#define EIGEN_ALIGNED_VECTOR3

#include <Eigen/Geometry>
#include "../../Eigen/Geometry"

#include "../../Eigen/src/Core/util/DisableStupidWarnings.h"

namespace Eigen {

Expand Down Expand Up @@ -76,6 +78,9 @@ template<typename _Scalar> class AlignedVector3
{ return m_coeffs.coeffRef(index);}


inline AlignedVector3()
{}

inline AlignedVector3(const Scalar& x, const Scalar& y, const Scalar& z)
: m_coeffs(x, y, z, Scalar(0))
{}
Expand Down Expand Up @@ -129,6 +134,9 @@ template<typename _Scalar> class AlignedVector3
inline AlignedVector3 operator-(const AlignedVector3& other) const
{ return AlignedVector3(m_coeffs - other.m_coeffs); }

inline AlignedVector3 operator-() const
{ return AlignedVector3(-m_coeffs); }

inline AlignedVector3 operator-=(const AlignedVector3& other)
{ m_coeffs -= other.m_coeffs; return *this; }

Expand Down Expand Up @@ -221,4 +229,6 @@ struct evaluator<AlignedVector3<Scalar> >

}

#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h"

#endif // EIGEN_ALIGNED_VECTOR3
11 changes: 5 additions & 6 deletions TMB/inst/include/unsupported/Eigen/ArpackSupport
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#ifndef EIGEN_ARPACKSUPPORT_MODULE_H
#define EIGEN_ARPACKSUPPORT_MODULE_H

#include <Eigen/Core>

#include <Eigen/src/Core/util/DisableStupidWarnings.h>
#include "../../Eigen/Core"

/** \defgroup ArpackSupport_Module Arpack support module
*
Expand All @@ -22,10 +20,11 @@
* \endcode
*/

#include <Eigen/SparseCholesky>
#include "../../Eigen/SparseCholesky"

#include "../../Eigen/src/Core/util/DisableStupidWarnings.h"
#include "src/Eigenvalues/ArpackSelfAdjointEigenSolver.h"

#include <Eigen/src/Core/util/ReenableStupidWarnings.h>
#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h"

#endif // EIGEN_ARPACKSUPPORT_MODULE_H
/* vim: set filetype=cpp et sw=2 ts=2 ai: */
6 changes: 6 additions & 0 deletions TMB/inst/include/unsupported/Eigen/AutoDiff
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ namespace Eigen {
//@{

}
#include "../../Eigen/src/Core/util/DisableStupidWarnings.h"


#include "src/AutoDiff/AutoDiffScalar.h"
// #include "src/AutoDiff/AutoDiffVector.h"
#include "src/AutoDiff/AutoDiffJacobian.h"

#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h"



namespace Eigen {
//@}
}
Expand Down
6 changes: 3 additions & 3 deletions TMB/inst/include/unsupported/Eigen/BVH
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#ifndef EIGEN_BVH_MODULE_H
#define EIGEN_BVH_MODULE_H

#include <Eigen/Core>
#include <Eigen/Geometry>
#include <Eigen/StdVector>
#include "../../Eigen/Core"
#include "../../Eigen/Geometry"
#include "../../Eigen/StdVector"
#include <algorithm>
#include <queue>

Expand Down
Loading