Skip to content

Commit c4f30f6

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/issue-2881-dense-metric-decomposition
2 parents a8e7500 + 2624416 commit c4f30f6

File tree

223 files changed

+77237
-73689
lines changed

Some content is hidden

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

223 files changed

+77237
-73689
lines changed

Jenkinsfile

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pipeline {
6060
options {
6161
skipDefaultCheckout()
6262
preserveStashes(buildCount: 7)
63+
parallelsAlwaysFailFast()
6364
}
6465
stages {
6566
stage('Kill previous builds') {
@@ -74,45 +75,6 @@ pipeline {
7475
}
7576
}
7677
}
77-
stage('Linting & Doc checks') {
78-
agent any
79-
steps {
80-
script {
81-
sh "printenv"
82-
retry(3) { checkout scm }
83-
sh """
84-
make math-revert
85-
make clean-all
86-
git clean -xffd
87-
"""
88-
utils.checkout_pr("math", "lib/stan_math", params.math_pr)
89-
stash 'StanSetup'
90-
setupCXX(true, env.GCC)
91-
parallel(
92-
CppLint: { sh "make cpplint" },
93-
API_docs: { sh 'make doxygen' },
94-
)
95-
}
96-
}
97-
post {
98-
always {
99-
100-
recordIssues id: "lint_doc_checks",
101-
name: "Linting & Doc checks",
102-
enabledForFailure: true,
103-
aggregatingResults : true,
104-
tools: [
105-
cppLint(id: "cpplint", name: "Linting & Doc checks@CPPLINT")
106-
],
107-
blameDisabled: false,
108-
qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]],
109-
healthy: 10, unhealthy: 100, minimumSeverity: 'HIGH',
110-
referenceJobName: env.BRANCH_NAME
111-
112-
deleteDir()
113-
}
114-
}
115-
}
11678
stage("Clang-format") {
11779
agent any
11880
steps {
@@ -161,6 +123,45 @@ pipeline {
161123
}
162124
}
163125
}
126+
stage('Linting & Doc checks') {
127+
agent any
128+
steps {
129+
script {
130+
sh "printenv"
131+
retry(3) { checkout scm }
132+
sh """
133+
make math-revert
134+
make clean-all
135+
git clean -xffd
136+
"""
137+
utils.checkout_pr("math", "lib/stan_math", params.math_pr)
138+
stash 'StanSetup'
139+
setupCXX(true, env.GCC)
140+
parallel(
141+
CppLint: { sh "make cpplint" },
142+
API_docs: { sh 'make doxygen' },
143+
)
144+
}
145+
}
146+
post {
147+
always {
148+
149+
recordIssues id: "lint_doc_checks",
150+
name: "Linting & Doc checks",
151+
enabledForFailure: true,
152+
aggregatingResults : true,
153+
tools: [
154+
cppLint(id: "cpplint", name: "Linting & Doc checks@CPPLINT")
155+
],
156+
blameDisabled: false,
157+
qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]],
158+
healthy: 10, unhealthy: 100, minimumSeverity: 'HIGH',
159+
referenceJobName: env.BRANCH_NAME
160+
161+
deleteDir()
162+
}
163+
}
164+
}
164165
stage('Verify changes') {
165166
agent { label 'linux' }
166167
steps {
@@ -240,6 +241,13 @@ pipeline {
240241
}
241242
stage('Integration Mac') {
242243
agent { label 'osx' }
244+
when {
245+
expression {
246+
( env.BRANCH_NAME == "develop" ||
247+
env.BRANCH_NAME == "master" ) &&
248+
!skipRemainingStages
249+
}
250+
}
243251
steps {
244252
unstash 'StanSetup'
245253
setupCXX()
@@ -273,6 +281,7 @@ pipeline {
273281
setupCXX()
274282
script {
275283
dir("lib/stan_math/") {
284+
sh "echo O=0 > make/local"
276285
withEnv(['PATH+TBB=./lib/tbb']) {
277286
try { sh "./runTests.py -j${env.PARALLEL} test/expressions" }
278287
finally { junit 'test/**/*.xml' }

lib/stan_math

Submodule stan_math updated 286 files

src/stan/io/reader.hpp

Lines changed: 115 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef STAN_IO_READER_HPP
22
#define STAN_IO_READER_HPP
33

4-
#include <stan/math/prim.hpp>
4+
#include <stan/math/rev.hpp>
55
#include <stdexcept>
66
#include <string>
77
#include <vector>
@@ -54,13 +54,20 @@ class reader {
5454
}
5555

5656
public:
57-
typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> matrix_t;
58-
typedef Eigen::Matrix<T, Eigen::Dynamic, 1> vector_t;
59-
typedef Eigen::Matrix<T, 1, Eigen::Dynamic> row_vector_t;
57+
using matrix_t = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
58+
using vector_t = Eigen::Matrix<T, Eigen::Dynamic, 1>;
59+
using row_vector_t = Eigen::Matrix<T, 1, Eigen::Dynamic>;
6060

61-
typedef Eigen::Map<matrix_t> map_matrix_t;
62-
typedef Eigen::Map<vector_t> map_vector_t;
63-
typedef Eigen::Map<row_vector_t> map_row_vector_t;
61+
using map_matrix_t = Eigen::Map<matrix_t>;
62+
using map_vector_t = Eigen::Map<vector_t>;
63+
using map_row_vector_t = Eigen::Map<row_vector_t>;
64+
65+
using var_matrix_t = stan::math::var_value<
66+
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>;
67+
using var_vector_t
68+
= stan::math::var_value<Eigen::Matrix<double, Eigen::Dynamic, 1>>;
69+
using var_row_vector_t
70+
= stan::math::var_value<Eigen::Matrix<double, 1, Eigen::Dynamic>>;
6471

6572
/**
6673
* Construct a variable reader using the specified vectors
@@ -186,6 +193,33 @@ class reader {
186193
return vector_t();
187194
return map_vector_t(&scalar_ptr_increment(m), m);
188195
}
196+
197+
/**
198+
* Return a `var_value` with inner type column vector with specified
199+
* dimensionality made up of the next scalars.
200+
*
201+
* @param m Number of rows in the vector to read.
202+
* @return Column vector made up of the next scalars.
203+
*/
204+
template <typename T_ = T, require_st_var<T_> * = nullptr>
205+
inline var_vector_t var_vector(size_t m) {
206+
if (m == 0)
207+
return var_vector_t(Eigen::VectorXd(0));
208+
return stan::math::to_var_value(map_vector_t(&scalar_ptr_increment(m), m));
209+
}
210+
211+
/**
212+
* Return a column vector of specified dimensionality made up of
213+
* the next scalars.
214+
*
215+
* @param m Number of rows in the vector to read.
216+
* @return Column vector made up of the next scalars.
217+
*/
218+
template <typename T_ = T, require_st_arithmetic<T_> * = nullptr>
219+
inline vector_t var_vector(size_t m) {
220+
return this->vector(m);
221+
}
222+
189223
/**
190224
* Return a column vector of specified dimensionality made up of
191225
* the next scalars. The constraint is a no-op.
@@ -225,6 +259,33 @@ class reader {
225259
return map_row_vector_t(&scalar_ptr_increment(m), m);
226260
}
227261

262+
/**
263+
* Return a `var_value` with inner type as a row vector with specified
264+
* dimensionality made up of the next scalars.
265+
*
266+
* @param m Number of rows in the vector to read.
267+
* @return Column vector made up of the next scalars.
268+
*/
269+
template <typename T_ = T, require_st_var<T_> * = nullptr>
270+
inline var_row_vector_t var_row_vector(size_t m) {
271+
if (m == 0)
272+
return var_row_vector_t(Eigen::RowVectorXd(0));
273+
return stan::math::to_var_value(
274+
map_row_vector_t(&scalar_ptr_increment(m), m));
275+
}
276+
277+
/**
278+
* Return a row vector of specified dimensionality made up of
279+
* the next scalars.
280+
*
281+
* @param m Number of rows in the vector to read.
282+
* @return Column vector made up of the next scalars.
283+
*/
284+
template <typename T_ = T, require_st_arithmetic<T_> * = nullptr>
285+
inline row_vector_t var_row_vector(size_t m) {
286+
return this->row_vector(m);
287+
}
288+
228289
/**
229290
* Return a row vector of specified dimensionality made up of
230291
* the next scalars. The constraint is a no-op.
@@ -276,6 +337,53 @@ class reader {
276337
return map_matrix_t(&scalar_ptr_increment(m * n), m, n);
277338
}
278339

340+
/**
341+
* Return a `var_value` with inner type matrix with the specified
342+
* dimensionality made up of the next scalars arranged in column-major order.
343+
*
344+
* Row-major reading means that if a matrix of <code>m=2</code>
345+
* rows and <code>n=3</code> columns is read and the next
346+
* scalar values are <code>1,2,3,4,5,6</code>, the result is
347+
*
348+
* <pre>
349+
* a = 1 4
350+
* 2 5
351+
* 3 6</pre>
352+
*
353+
* @param m Number of rows.
354+
* @param n Number of columns.
355+
* @return Eigen::Matrix made up of the next scalars.
356+
*/
357+
template <typename T_ = T, require_st_var<T_> * = nullptr>
358+
inline var_matrix_t var_matrix(size_t m, size_t n) {
359+
if (m == 0 || n == 0)
360+
return var_matrix_t(Eigen::MatrixXd(0, 0));
361+
return stan::math::to_var_value(
362+
map_matrix_t(&scalar_ptr_increment(m * n), m, n));
363+
}
364+
365+
/**
366+
* Return a matrix of the specified dimensionality made up of
367+
* the next scalars arranged in column-major order.
368+
*
369+
* Row-major reading means that if a matrix of <code>m=2</code>
370+
* rows and <code>n=3</code> columns is read and the next
371+
* scalar values are <code>1,2,3,4,5,6</code>, the result is
372+
*
373+
* <pre>
374+
* a = 1 4
375+
* 2 5
376+
* 3 6</pre>
377+
*
378+
* @param m Number of rows.
379+
* @param n Number of columns.
380+
* @return Eigen::Matrix made up of the next scalars.
381+
*/
382+
template <typename T_ = T, require_st_arithmetic<T_> * = nullptr>
383+
inline matrix_t var_matrix(size_t m, size_t n) {
384+
return this->matrix(m, n);
385+
}
386+
279387
/**
280388
* Return a matrix of the specified dimensionality made up of
281389
* the next scalars arranged in column-major order. The

src/stan/io/stan_csv_reader.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <boost/algorithm/string.hpp>
55
#include <stan/math/prim.hpp>
6+
#include <cctype>
67
#include <istream>
78
#include <iostream>
89
#include <sstream>
@@ -178,7 +179,7 @@ class stan_csv_reader {
178179
std::ostream* out, bool prettify_name = true) {
179180
std::string line;
180181

181-
if (in.peek() != 'l')
182+
if (!std::isalpha(in.peek()))
182183
return false;
183184

184185
std::getline(in, line);

src/stan/lang/generator.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include <stan/lang/generator/generate_member_var_decls.hpp>
7171
#include <stan/lang/generator/generate_member_var_decls_all.hpp>
7272
#include <stan/lang/generator/generate_model_name_method.hpp>
73+
#include <stan/lang/generator/generate_model_compile_info_method.hpp>
7374
#include <stan/lang/generator/generate_model_typedef.hpp>
7475
#include <stan/lang/generator/generate_namespace_end.hpp>
7576
#include <stan/lang/generator/generate_namespace_start.hpp>

src/stan/lang/generator/generate_cpp.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <stan/lang/generator/generate_log_prob.hpp>
1717
#include <stan/lang/generator/generate_member_var_decls_all.hpp>
1818
#include <stan/lang/generator/generate_model_name_method.hpp>
19+
#include <stan/lang/generator/generate_model_compile_info_method.hpp>
1920
#include <stan/lang/generator/generate_model_typedef.hpp>
2021
#include <stan/lang/generator/generate_namespace_end.hpp>
2122
#include <stan/lang/generator/generate_namespace_start.hpp>
@@ -70,6 +71,7 @@ void generate_cpp(const program& prog, const std::string& model_name,
7071
generate_dims_method(prog, o);
7172
generate_write_array_method(prog, model_name, o);
7273
generate_model_name_method(model_name, o);
74+
generate_model_compile_info_method(o);
7375
generate_constrained_param_names_method(prog, o);
7476
generate_unconstrained_param_names_method(prog, o);
7577
generate_class_decl_end(o);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef STAN_LANG_GENERATOR_GENERATE_MODEL_COMPILE_INFO_METHOD_HPP
2+
#define STAN_LANG_GENERATOR_GENERATE_MODEL_COMPILE_INFO_METHOD_HPP
3+
4+
#include <stan/lang/ast.hpp>
5+
#include <stan/lang/generator/constants.hpp>
6+
#include <ostream>
7+
#include <string>
8+
9+
namespace stan {
10+
namespace lang {
11+
12+
/**
13+
* Generate the <code>model_compile_info</code> method on the specified stream.
14+
*
15+
* @param[in,out] o stream for generating
16+
*/
17+
void generate_model_compile_info_method(std::ostream& o) {
18+
o << INDENT << "std::vector<std::string> model_compile_info() const {" << EOL
19+
<< INDENT2 << "std::vector<std::string> stanc_info;" << EOL << INDENT2
20+
<< "stanc_info.push_back(\"stanc_version = stanc2\");" << EOL << INDENT2
21+
<< "return stanc_info;" << EOL << INDENT << "}" << EOL2;
22+
}
23+
24+
} // namespace lang
25+
} // namespace stan
26+
#endif

0 commit comments

Comments
 (0)