Skip to content

Commit 59335f6

Browse files
committed
Merge branch 'develop' into generalize_view_and_size
# Conflicts: # stan/math/prim/fun/cols.hpp # stan/math/prim/fun/transpose.hpp
2 parents 458b8dc + f11c9e0 commit 59335f6

File tree

807 files changed

+8153
-3984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

807 files changed

+8153
-3984
lines changed

Jenkinsfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ def runTests(String testPath) {
88
finally { junit 'test/**/*.xml' }
99
}
1010

11-
def runTestsWin(String testPath) {
11+
def runTestsWin(String testPath, boolean buildLibs = true) {
1212
withEnv(['PATH+TBB=./lib/tbb']) {
1313
bat "echo $PATH"
14-
bat "mingw32-make.exe -f make/standalone math-libs"
14+
if (buildLibs){
15+
bat "mingw32-make.exe -f make/standalone math-libs"
16+
}
1517
bat "runTests.py -j${env.PARALLEL} ${testPath} --make-only"
1618
try { bat "runTests.py -j${env.PARALLEL} ${testPath}" }
1719
finally { junit 'test/**/*.xml' }
@@ -246,8 +248,9 @@ pipeline {
246248
steps {
247249
deleteDirWin()
248250
unstash 'MathSetup'
251+
bat "mingw32-make.exe -f make/standalone math-libs"
249252
bat "mingw32-make -j${env.PARALLEL} test-headers"
250-
runTestsWin("test/unit")
253+
runTestsWin("test/unit", false)
251254
}
252255
}
253256
stage('Windows Threading') {

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ Bug Fixes
434434
--------------------------------------------------
435435
* beta_rng no longer returns NaN
436436
* fixed memory issue with cholesky_decompose in reverse-mode (#415)
437-
* no more mulitple definitions when including Stan headers in
437+
* no more multiple definitions when including Stan headers in
438438
multiple source files (#394)
439439
* fixed broken _MSC_VER conditionals and remove math.h includes (#370)
440440

doxygen/contributor_help_pages/distribution_tests.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Before diving into details, the overall structure of the test file is:
101101
```
102102
template <class T_n, class T_prob, typename T2,
103103
typename T3, typename T4, typename T5>
104-
typename stan::return_type<T_n, T_prob>::type
104+
stan::return_type_t<T_n, T_prob>
105105
log_prob(const T_n& n, const T_prob& theta, const T2&,
106106
const T3&, const T4&, const T5&)
107107
```
@@ -110,15 +110,15 @@ Before diving into details, the overall structure of the test file is:
110110
template <bool propto,
111111
class T_n, class T_prob, typename T2,
112112
typename T3, typename T4, typename T5>
113-
typename stan::return_type<T_n, T_prob>::type
113+
stan::return_type_t<T_n, T_prob>
114114
log_prob(const T_n& n, const T_prob& theta, const T2&,
115115
const T3&, const T4&, const T5&)
116116
```
117117
-
118118
```
119119
template <class T_n, class T_prob, typename T2,
120120
typename T3, typename T4, typename T5>
121-
typename stan::return_type<T_n, T_prob>::type
121+
stan::return_type_t<T_n, T_prob>
122122
log_prob_function(const T_n& n, const T_prob& theta, const T2&,
123123
const T3&, const T4&, const T5&)
124124
```

make/compiler_flags

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Find files subroutine for different operating system
2+
# This is recursive version of the makefiles wildcard function
3+
findfiles = $(foreach d,$(wildcard $(addsuffix *,$(1))),$(call findfiles,$(d)/,$(2)) $(wildcard $(d)/$(2)))
4+
5+
ifneq ($(OS),Windows_NT)
6+
GENERATE_DISTRIBUTION_TESTS=true
7+
endif
8+
19
# Detect operating system, set default compiler, and detect compiler type
210
# The defaults are configured for the compilers we test:
311
# https://github.com/stan-dev/stan/wiki/Supported-C---Compilers-and-Language-Features

make/libraries

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ $(SUNDIALS)/lib/libsundials_nvecserial.a: $(SUNDIALS_NVECSERIAL)
7474

7575
LIBSUNDIALS := $(SUNDIALS)/lib/libsundials_nvecserial.a $(SUNDIALS)/lib/libsundials_cvodes.a $(SUNDIALS)/lib/libsundials_idas.a $(SUNDIALS)/lib/libsundials_kinsol.a
7676

77-
STAN_SUNDIALS_HEADERS := $(shell find $(MATH)stan -name *cvodes*.hpp) $(shell find $(MATH)stan -name *idas*.hpp) $(shell find $(MATH)stan -name *kinsol*.hpp)
77+
STAN_SUNDIALS_HEADERS := $(call findfiles,$(MATH)stan,*cvodes*.hpp) $(call findfiles,$(MATH)stan,*idas*.hpp) $(call findfiles,$(MATH)stan,*kinsol*.hpp)
7878
$(STAN_SUNDIALS_HEADERS) : $(LIBSUNDIALS)
7979

8080
clean-sundials:
@@ -196,7 +196,7 @@ $(BOOST)/stage/lib/libboost_mpi.dylib: $(BOOST)/stage/lib/mpi.so $(BOOST)/stage/
196196
install_name_tool -change libboost_serialization.dylib @rpath/libboost_serialization.dylib "$(BOOST)/stage/lib/libboost_mpi.dylib"
197197
install_name_tool -id @rpath/libboost_mpi.dylib "$(BOOST)/stage/lib/libboost_mpi.dylib"
198198

199-
MPI_TEMPLATE_INSTANTIATION_CPP := $(shell find $(MATH)stan -type f -name 'mpi_*_inst.cpp') $(shell find $(MATH)stan -type f -name 'mpi_*_def.cpp')
199+
MPI_TEMPLATE_INSTANTIATION_CPP := $(call findfiles,$(MATH)stan,mpi_*_inst.cpp) $(call findfiles,$(MATH)stan,mpi_*_def.cpp)
200200
MPI_TEMPLATE_INSTANTIATION := $(MPI_TEMPLATE_INSTANTIATION_CPP:%.cpp=%.o)
201201

202202
$(MPI_TEMPLATE_INSTANTIATION) : CXXFLAGS += -fPIC

make/tests

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test/unit/multiple_translation_units_test$(EXE): test/unit/libmultiple.so
4040
# CVODES tests
4141
##
4242

43-
CVODES_TESTS := $(subst .cpp,$(EXE),$(shell find test -name *cvodes*_test.cpp) $(shell find test -name *_bdf_*_test.cpp) $(shell find test -name *_adams_*_test.cpp))
43+
CVODES_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*cvodes*_test.cpp) $(call findfiles,test,*_bdf_*_test.cpp) $(call findfiles,test,*_adams_*_test.cpp))
4444
$(CVODES_TESTS) : $(LIBSUNDIALS)
4545

4646

@@ -49,7 +49,7 @@ $(CVODES_TESTS) : $(LIBSUNDIALS)
4949
# IDAS tests
5050
##
5151

52-
IDAS_TESTS := $(subst .cpp,$(EXE),$(shell find test -name *idas*_test.cpp) $(shell find test -name *_dae*_test.cpp))
52+
IDAS_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*idas*_test.cpp) $(call findfiles,test,*_dae*_test.cpp))
5353
$(IDAS_TESTS) : $(LIBSUNDIALS)
5454

5555

@@ -58,7 +58,7 @@ $(IDAS_TESTS) : $(LIBSUNDIALS)
5858
# KINSOL tests
5959
##
6060

61-
ALGEBRA_SOLVER_TESTS := $(subst .cpp,$(EXE),$(shell find test -name *algebra_solver*_test.cpp))
61+
ALGEBRA_SOLVER_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*algebra_solver*_test.cpp))
6262
$(ALGEBRA_SOLVER_TESTS) : $(LIBSUNDIALS)
6363

6464

@@ -67,7 +67,7 @@ $(ALGEBRA_SOLVER_TESTS) : $(LIBSUNDIALS)
6767
# Target to verify header files within Stan has
6868
# enough include calls
6969
##
70-
HEADER_TESTS := $(addsuffix -test,$(shell find stan -name '*.hpp' -type f))
70+
HEADER_TESTS := $(addsuffix -test,$(call findfiles,stan,*.hpp))
7171

7272
ifeq ($(OS),Windows_NT)
7373
DEV_NULL = nul
@@ -86,6 +86,7 @@ test/dummy.cpp:
8686
.PHONY: test-headers
8787
test-headers: $(HEADER_TESTS)
8888

89+
ifdef GENERATE_DISTRIBUTION_TESTS
8990
############################################################
9091
##
9192
# Test generator for distribution tests
@@ -108,3 +109,4 @@ LIST_OF_GENERATED_TESTS := $(shell find test/prob -type f -name '*_test.hpp' | s
108109

109110
.PHONY: generate-tests
110111
generate-tests: $(LIST_OF_GENERATED_TESTS)
112+
endif

makefile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,29 @@ doxygen:
9898
.PHONY: clean clean-doxygen clean-deps clean-all
9999
clean:
100100
@echo ' removing test executables'
101-
$(shell find test -type f -name "*_test$(EXE)" -exec rm {} +)
102-
$(shell find test -type f -name "*_test.d" -exec rm {} +)
103-
$(shell find test -type f -name "*_test.d.*" -exec rm {} +)
104-
$(shell find test -type f -name "*_test.xml" -exec rm {} +)
105-
$(shell find test -type f -name "*.o" -exec rm {} +)
106-
$(RM) $(wildcard $(GTEST)/src/gtest-all.o)
101+
@$(RM) $(call findfiles,test,*_test$(EXE))
102+
@$(RM) $(call findfiles,test,*_test.d)
103+
@$(RM) $(call findfiles,test,*_test.d.*)
104+
@$(RM) $(call findfiles,test,*_test.xml)
105+
@$(RM) $(call findfiles,test,*.o)
106+
@$(RM) $(wildcard $(GTEST)/src/gtest-all.o)
107107
@echo ' removing generated test files'
108-
$(RM) $(wildcard test/prob/generate_tests$(EXE))
109-
$(shell find test/prob -name '*_generated_*_test.cpp' -type f -exec rm {} +)
108+
@$(RM) $(wildcard test/prob/generate_tests$(EXE))
109+
@$(RM) $(call findfiles,test/prob,*_generated_*_test.cpp)
110110

111111
clean-doxygen:
112112
@echo ' removing doxygen'
113113
$(RM) -r doc/api
114114

115115
clean-deps:
116116
@echo ' removing dependency files'
117-
$(shell find stan test lib -type f -name '*.d' -exec rm {} +)
118-
$(shell find stan test lib -type f -name '*.d.*' -exec rm {} +)
119-
$(shell find stan -type f -name '*.dSYM' -exec rm {} +)
117+
@$(RM) $(call findfiles,stan,*.d)
118+
@$(RM) $(call findfiles,test,*.d)
119+
@$(RM) $(call findfiles,lib,*.d)
120+
@$(RM) $(call findfiles,stan,*.d.*)
121+
@$(RM) $(call findfiles,test,*.d.*)
122+
@$(RM) $(call findfiles,lib,*.d.*)
123+
@$(RM) $(call findfiles,stan,*.dSYM)
120124

121125
clean-all: clean clean-doxygen clean-deps clean-libraries
122126

runChecks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def check_non_unique_test_names():
5757
for y in duplicates[x]:
5858
duplicates_error_msg += "\t" + y + "\n"
5959
errors.append(
60-
"Tests or test fixtures with non-unqiue names found in test/unit:\n\n" +
60+
"Tests or test fixtures with non-unique names found in test/unit:\n\n" +
6161
duplicates_error_msg
6262
)
6363
return errors

stan/math.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@
109109
*
110110
* In general, these methods allow Stan to have more generic types so that the
111111
* library can forward along Eigen expression and have better move semantics.
112-
* For instance, the below code will accept any arbitrary eigen expression
112+
* For instance, the code below will accept any arbitrary Eigen expression
113113
* that, if it's an rvalue, can be forwarded to another function.
114114
*
115115
*~~~~~{.cpp}
116-
* template <typename Mat1, typename Mat2,
116+
* template <typename Mat1, typename Mat2,
117117
* require_all_eigen_vt<is_arithmetic, Mat1, Mat2>...>
118118
* inline auto a_func(Mat1&& m1, Mat2&& m2) {
119119
* check_nan(m1);
120120
* check_nan(m2);
121121
* // If m1 and/or m2 is an rvalue it will be moved over to this function
122-
* // instead of copied to an lvalue
122+
* // instead of copied to an lvalue
123123
* auto B = another_func(std::forward<Mat1>(m1), std::forward<Mat2>(m2)); //
124124
*(3) return B;
125125
*~~~~~
@@ -141,7 +141,7 @@
141141
* certain conditions while @c _st methods check that the objects @c scalar_type
142142
* fulfills certain conditions. @c value_type and @c scalar_type differ in that
143143
* @c value_type is the first level of a container while @c scalar_type
144-
* recursivly goes through containers of containers till it comes to a simple
144+
* recursively goes through containers of containers till it comes to a simple
145145
* type.
146146
*/
147147

stan/math/fwd.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include <stan/math/fwd/core.hpp>
77
#include <stan/math/fwd/meta.hpp>
8-
#include <stan/math/fwd/vectorize.hpp>
98
#include <stan/math/prim.hpp>
109

1110
#include <stan/math/fwd/fun.hpp>

stan/math/fwd/core.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
#include <stan/math/fwd/core/operator_unary_not.hpp>
1919
#include <stan/math/fwd/core/operator_unary_plus.hpp>
2020
#include <stan/math/fwd/core/std_numeric_limits.hpp>
21+
#include <stan/math/fwd/core/std_iterator_traits.hpp>
2122

2223
#endif
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#ifndef STAN_MATH_FWD_CORE_STD_ITERATOR_TRAITS_HPP
2+
#define STAN_MATH_FWD_CORE_STD_ITERATOR_TRAITS_HPP
3+
4+
#include <stan/math/fwd/core/fvar.hpp>
5+
#include <stan/math/prim/meta.hpp>
6+
#include <iterator>
7+
8+
namespace std {
9+
/**
10+
* Specialization of iterator traits for Stan math. These all take
11+
* the form of typedefs.
12+
*/
13+
template <typename T>
14+
struct iterator_traits<stan::math::fvar<T>> {
15+
/**
16+
* Iterator category for traits.
17+
*/
18+
typedef random_access_iterator_tag iterator_category;
19+
20+
/**
21+
* Type for difference between pointers.
22+
*/
23+
typedef ptrdiff_t difference_type;
24+
25+
/**
26+
* Type for value of pointer to values.
27+
*/
28+
typedef stan::math::fvar<T> value_type;
29+
30+
/**
31+
* Type of pointer to variables.
32+
*/
33+
typedef stan::math::fvar<T>* pointer;
34+
35+
/**
36+
* Type of reference to variables.
37+
*/
38+
typedef stan::math::fvar<T>& reference;
39+
};
40+
} // namespace std
41+
42+
#endif

stan/math/fwd/fun.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <stan/math/fwd/fun/determinant.hpp>
2424
#include <stan/math/fwd/fun/digamma.hpp>
2525
#include <stan/math/fwd/fun/divide.hpp>
26-
#include <stan/math/fwd/fun/dot_product.hpp>
2726
#include <stan/math/fwd/fun/dot_self.hpp>
2827
#include <stan/math/fwd/fun/Eigen_NumTraits.hpp>
2928
#include <stan/math/fwd/fun/erf.hpp>
@@ -92,6 +91,7 @@
9291
#include <stan/math/fwd/fun/primitive_value.hpp>
9392
#include <stan/math/fwd/fun/qr_Q.hpp>
9493
#include <stan/math/fwd/fun/qr_R.hpp>
94+
#include <stan/math/fwd/fun/quad_form.hpp>
9595
#include <stan/math/fwd/fun/quad_form_sym.hpp>
9696
#include <stan/math/fwd/fun/rising_factorial.hpp>
9797
#include <stan/math/fwd/fun/round.hpp>

stan/math/fwd/fun/columns_dot_product.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ inline Eigen::Matrix<fvar<T>, 1, C1> columns_dot_product(
1616
check_matching_dims("columns_dot_product", "v1", v1, "v2", v2);
1717
Eigen::Matrix<fvar<T>, 1, C1> ret(1, v1.cols());
1818
for (size_type j = 0; j < v1.cols(); ++j) {
19-
Eigen::Matrix<fvar<T>, R1, C1> ccol1 = v1.col(j);
20-
Eigen::Matrix<fvar<T>, R2, C2> ccol2 = v2.col(j);
19+
Eigen::Matrix<fvar<T>, R1, 1> ccol1 = v1.col(j);
20+
Eigen::Matrix<fvar<T>, R2, 1> ccol2 = v2.col(j);
2121
ret(0, j) = dot_product(ccol1, ccol2);
2222
}
2323
return ret;
@@ -30,8 +30,8 @@ inline Eigen::Matrix<fvar<T>, 1, C1> columns_dot_product(
3030
check_matching_dims("columns_dot_product", "v1", v1, "v2", v2);
3131
Eigen::Matrix<fvar<T>, 1, C1> ret(1, v1.cols());
3232
for (size_type j = 0; j < v1.cols(); ++j) {
33-
Eigen::Matrix<fvar<T>, R1, C1> ccol1 = v1.col(j);
34-
Eigen::Matrix<double, R2, C2> ccol = v2.col(j);
33+
Eigen::Matrix<fvar<T>, R1, 1> ccol1 = v1.col(j);
34+
Eigen::Matrix<double, R2, 1> ccol = v2.col(j);
3535
ret(0, j) = dot_product(ccol1, ccol);
3636
}
3737
return ret;
@@ -44,8 +44,8 @@ inline Eigen::Matrix<fvar<T>, 1, C1> columns_dot_product(
4444
check_matching_dims("columns_dot_product", "v1", v1, "v2", v2);
4545
Eigen::Matrix<fvar<T>, 1, C1> ret(1, v1.cols());
4646
for (size_type j = 0; j < v1.cols(); ++j) {
47-
Eigen::Matrix<double, R1, C1> ccol = v1.col(j);
48-
Eigen::Matrix<fvar<T>, R2, C2> ccol2 = v2.col(j);
47+
Eigen::Matrix<double, R1, 1> ccol = v1.col(j);
48+
Eigen::Matrix<fvar<T>, R2, 1> ccol2 = v2.col(j);
4949
ret(0, j) = dot_product(ccol, ccol2);
5050
}
5151
return ret;

stan/math/fwd/fun/columns_dot_self.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <stan/math/prim/fun/Eigen.hpp>
55
#include <stan/math/fwd/core.hpp>
6+
#include <stan/math/fwd/fun/typedefs.hpp>
67
#include <stan/math/fwd/fun/dot_self.hpp>
78

89
namespace stan {

stan/math/fwd/fun/crossprod.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ template <typename T, int R, int C>
1212
inline Eigen::Matrix<fvar<T>, C, C> crossprod(
1313
const Eigen::Matrix<fvar<T>, R, C>& m) {
1414
if (m.rows() == 0) {
15-
return Eigen::Matrix<fvar<T>, C, C>(0, 0);
15+
return {};
1616
}
1717
return multiply(transpose(m), m);
1818
}

0 commit comments

Comments
 (0)