Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/issue-2814…
Browse files Browse the repository at this point in the history
…-warmup-auto
  • Loading branch information
bbbales2 committed Nov 28, 2020
2 parents 473a28c + 2624416 commit da00166
Show file tree
Hide file tree
Showing 223 changed files with 77,198 additions and 73,650 deletions.
9 changes: 9 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pipeline {
options {
skipDefaultCheckout()
preserveStashes(buildCount: 7)
parallelsAlwaysFailFast()
}
stages {
stage('Kill previous builds') {
Expand Down Expand Up @@ -240,6 +241,13 @@ pipeline {
}
stage('Integration Mac') {
agent { label 'osx' }
when {
expression {
( env.BRANCH_NAME == "develop" ||
env.BRANCH_NAME == "master" ) &&
!skipRemainingStages
}
}
steps {
unstash 'StanSetup'
setupCXX()
Expand Down Expand Up @@ -273,6 +281,7 @@ pipeline {
setupCXX()
script {
dir("lib/stan_math/") {
sh "echo O=0 > make/local"
withEnv(['PATH+TBB=./lib/tbb']) {
try { sh "./runTests.py -j${env.PARALLEL} test/expressions" }
finally { junit 'test/**/*.xml' }
Expand Down
2 changes: 1 addition & 1 deletion lib/stan_math
Submodule stan_math updated 286 files
122 changes: 115 additions & 7 deletions src/stan/io/reader.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef STAN_IO_READER_HPP
#define STAN_IO_READER_HPP

#include <stan/math/prim.hpp>
#include <stan/math/rev.hpp>
#include <stdexcept>
#include <string>
#include <vector>
Expand Down Expand Up @@ -54,13 +54,20 @@ class reader {
}

public:
typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> matrix_t;
typedef Eigen::Matrix<T, Eigen::Dynamic, 1> vector_t;
typedef Eigen::Matrix<T, 1, Eigen::Dynamic> row_vector_t;
using matrix_t = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
using vector_t = Eigen::Matrix<T, Eigen::Dynamic, 1>;
using row_vector_t = Eigen::Matrix<T, 1, Eigen::Dynamic>;

typedef Eigen::Map<matrix_t> map_matrix_t;
typedef Eigen::Map<vector_t> map_vector_t;
typedef Eigen::Map<row_vector_t> map_row_vector_t;
using map_matrix_t = Eigen::Map<matrix_t>;
using map_vector_t = Eigen::Map<vector_t>;
using map_row_vector_t = Eigen::Map<row_vector_t>;

using var_matrix_t = stan::math::var_value<
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>;
using var_vector_t
= stan::math::var_value<Eigen::Matrix<double, Eigen::Dynamic, 1>>;
using var_row_vector_t
= stan::math::var_value<Eigen::Matrix<double, 1, Eigen::Dynamic>>;

/**
* Construct a variable reader using the specified vectors
Expand Down Expand Up @@ -186,6 +193,33 @@ class reader {
return vector_t();
return map_vector_t(&scalar_ptr_increment(m), m);
}

/**
* Return a `var_value` with inner type column vector with specified
* dimensionality made up of the next scalars.
*
* @param m Number of rows in the vector to read.
* @return Column vector made up of the next scalars.
*/
template <typename T_ = T, require_st_var<T_> * = nullptr>
inline var_vector_t var_vector(size_t m) {
if (m == 0)
return var_vector_t(Eigen::VectorXd(0));
return stan::math::to_var_value(map_vector_t(&scalar_ptr_increment(m), m));
}

/**
* Return a column vector of specified dimensionality made up of
* the next scalars.
*
* @param m Number of rows in the vector to read.
* @return Column vector made up of the next scalars.
*/
template <typename T_ = T, require_st_arithmetic<T_> * = nullptr>
inline vector_t var_vector(size_t m) {
return this->vector(m);
}

/**
* Return a column vector of specified dimensionality made up of
* the next scalars. The constraint is a no-op.
Expand Down Expand Up @@ -225,6 +259,33 @@ class reader {
return map_row_vector_t(&scalar_ptr_increment(m), m);
}

/**
* Return a `var_value` with inner type as a row vector with specified
* dimensionality made up of the next scalars.
*
* @param m Number of rows in the vector to read.
* @return Column vector made up of the next scalars.
*/
template <typename T_ = T, require_st_var<T_> * = nullptr>
inline var_row_vector_t var_row_vector(size_t m) {
if (m == 0)
return var_row_vector_t(Eigen::RowVectorXd(0));
return stan::math::to_var_value(
map_row_vector_t(&scalar_ptr_increment(m), m));
}

/**
* Return a row vector of specified dimensionality made up of
* the next scalars.
*
* @param m Number of rows in the vector to read.
* @return Column vector made up of the next scalars.
*/
template <typename T_ = T, require_st_arithmetic<T_> * = nullptr>
inline row_vector_t var_row_vector(size_t m) {
return this->row_vector(m);
}

/**
* Return a row vector of specified dimensionality made up of
* the next scalars. The constraint is a no-op.
Expand Down Expand Up @@ -276,6 +337,53 @@ class reader {
return map_matrix_t(&scalar_ptr_increment(m * n), m, n);
}

/**
* Return a `var_value` with inner type matrix with the specified
* dimensionality made up of the next scalars arranged in column-major order.
*
* Row-major reading means that if a matrix of <code>m=2</code>
* rows and <code>n=3</code> columns is read and the next
* scalar values are <code>1,2,3,4,5,6</code>, the result is
*
* <pre>
* a = 1 4
* 2 5
* 3 6</pre>
*
* @param m Number of rows.
* @param n Number of columns.
* @return Eigen::Matrix made up of the next scalars.
*/
template <typename T_ = T, require_st_var<T_> * = nullptr>
inline var_matrix_t var_matrix(size_t m, size_t n) {
if (m == 0 || n == 0)
return var_matrix_t(Eigen::MatrixXd(0, 0));
return stan::math::to_var_value(
map_matrix_t(&scalar_ptr_increment(m * n), m, n));
}

/**
* Return a matrix of the specified dimensionality made up of
* the next scalars arranged in column-major order.
*
* Row-major reading means that if a matrix of <code>m=2</code>
* rows and <code>n=3</code> columns is read and the next
* scalar values are <code>1,2,3,4,5,6</code>, the result is
*
* <pre>
* a = 1 4
* 2 5
* 3 6</pre>
*
* @param m Number of rows.
* @param n Number of columns.
* @return Eigen::Matrix made up of the next scalars.
*/
template <typename T_ = T, require_st_arithmetic<T_> * = nullptr>
inline matrix_t var_matrix(size_t m, size_t n) {
return this->matrix(m, n);
}

/**
* Return a matrix of the specified dimensionality made up of
* the next scalars arranged in column-major order. The
Expand Down
3 changes: 2 additions & 1 deletion src/stan/io/stan_csv_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <boost/algorithm/string.hpp>
#include <stan/math/prim.hpp>
#include <cctype>
#include <istream>
#include <iostream>
#include <sstream>
Expand Down Expand Up @@ -178,7 +179,7 @@ class stan_csv_reader {
std::ostream* out, bool prettify_name = true) {
std::string line;

if (in.peek() != 'l')
if (!std::isalpha(in.peek()))
return false;

std::getline(in, line);
Expand Down
1 change: 1 addition & 0 deletions src/stan/lang/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include <stan/lang/generator/generate_member_var_decls.hpp>
#include <stan/lang/generator/generate_member_var_decls_all.hpp>
#include <stan/lang/generator/generate_model_name_method.hpp>
#include <stan/lang/generator/generate_model_compile_info_method.hpp>
#include <stan/lang/generator/generate_model_typedef.hpp>
#include <stan/lang/generator/generate_namespace_end.hpp>
#include <stan/lang/generator/generate_namespace_start.hpp>
Expand Down
2 changes: 2 additions & 0 deletions src/stan/lang/generator/generate_cpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <stan/lang/generator/generate_log_prob.hpp>
#include <stan/lang/generator/generate_member_var_decls_all.hpp>
#include <stan/lang/generator/generate_model_name_method.hpp>
#include <stan/lang/generator/generate_model_compile_info_method.hpp>
#include <stan/lang/generator/generate_model_typedef.hpp>
#include <stan/lang/generator/generate_namespace_end.hpp>
#include <stan/lang/generator/generate_namespace_start.hpp>
Expand Down Expand Up @@ -70,6 +71,7 @@ void generate_cpp(const program& prog, const std::string& model_name,
generate_dims_method(prog, o);
generate_write_array_method(prog, model_name, o);
generate_model_name_method(model_name, o);
generate_model_compile_info_method(o);
generate_constrained_param_names_method(prog, o);
generate_unconstrained_param_names_method(prog, o);
generate_class_decl_end(o);
Expand Down
26 changes: 26 additions & 0 deletions src/stan/lang/generator/generate_model_compile_info_method.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef STAN_LANG_GENERATOR_GENERATE_MODEL_COMPILE_INFO_METHOD_HPP
#define STAN_LANG_GENERATOR_GENERATE_MODEL_COMPILE_INFO_METHOD_HPP

#include <stan/lang/ast.hpp>
#include <stan/lang/generator/constants.hpp>
#include <ostream>
#include <string>

namespace stan {
namespace lang {

/**
* Generate the <code>model_compile_info</code> method on the specified stream.
*
* @param[in,out] o stream for generating
*/
void generate_model_compile_info_method(std::ostream& o) {
o << INDENT << "std::vector<std::string> model_compile_info() const {" << EOL
<< INDENT2 << "std::vector<std::string> stanc_info;" << EOL << INDENT2
<< "stanc_info.push_back(\"stanc_version = stanc2\");" << EOL << INDENT2
<< "return stanc_info;" << EOL << INDENT << "}" << EOL2;
}

} // namespace lang
} // namespace stan
#endif

0 comments on commit da00166

Please sign in to comment.