Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stan/math/fwd/scal/fun/inc_beta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ namespace stan {
T d_a; T d_b; T d_x;

grad_reg_inc_beta(d_a, d_b, a.val_, b.val_, x.val_,
digamma(a.val_), digamma(b.val_),
digamma(a.val_+b.val_),
exp(lbeta(a.val_, b.val_)));
d_x = pow((1-x.val_), b.val_-1)*pow(x.val_, a.val_-1)
digamma(a.val_), digamma(b.val_),
digamma(a.val_ + b.val_),
exp(lbeta(a.val_, b.val_)));
d_x = pow((1 - x.val_), b.val_-1) * pow(x.val_, a.val_ - 1)
/ exp(lbeta(a.val_, b.val_));
return fvar<T>(inc_beta(a.val_, b.val_, x.val_),
a.d_ * d_a + b.d_ * d_b + x.d_ * d_x);
Expand Down
3 changes: 2 additions & 1 deletion stan/math/memory/stack_alloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ namespace stan {
// big fun to inline, but only called twice
inline char* eight_byte_aligned_malloc(size_t size) {
char* ptr = static_cast<char*>(malloc(size));
if (!ptr) return ptr; // malloc failed to alloc
if (!ptr)
return ptr; // malloc failed to alloc
if (!is_aligned(ptr, 8U)) {
std::stringstream s;
s << "invalid alignment to 8 bytes, ptr="
Expand Down
4 changes: 2 additions & 2 deletions stan/math/prim/arr/err/check_ordered.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ namespace stan {
const std::string& name,
const std::vector<T_y>& y) {
for (size_t n = 1; n < y.size(); n++) {
if (!(y[n] > y[n-1])) {
if (!(y[n] > y[n - 1])) {
std::ostringstream msg1;
msg1 << "is not a valid ordered vector."
<< " The element at " << stan::error_index::value + n
<< " is ";
std::string msg1_str(msg1.str());
std::ostringstream msg2;
msg2 << ", but should be greater than the previous element, "
<< y[n-1];
<< y[n - 1];
std::string msg2_str(msg2.str());
domain_error(function, name, y[n],
msg1_str.c_str(), msg2_str.c_str());
Expand Down
3 changes: 2 additions & 1 deletion stan/math/prim/arr/fun/sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace stan {
*/
template <typename T>
inline T sum(const std::vector<T>& xs) {
if (xs.size() == 0) return 0;
if (xs.size() == 0)
return 0;
T sum(xs[0]);
for (size_t i = 1; i < xs.size(); ++i)
sum += xs[i];
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/arr/functor/integrate_ode_rk45.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace stan {
std::vector<double> ts_vec(ts.size() + 1);
ts_vec[0] = t0;
for (size_t n = 0; n < ts.size(); n++)
ts_vec[n+1] = ts[n];
ts_vec[n + 1] = ts[n];

std::vector<std::vector<double> > y_coupled(ts_vec.size());
coupled_ode_observer observer(y_coupled);
Expand Down
4 changes: 2 additions & 2 deletions stan/math/prim/mat/err/check_ordered.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ namespace stan {
typedef typename index_type<Matrix<T_y, Dynamic, 1> >::type size_t;

for (size_t n = 1; n < y.size(); n++) {
if (!(y[n] > y[n-1])) {
if (!(y[n] > y[n - 1])) {
std::ostringstream msg1;
msg1 << "is not a valid ordered vector."
<< " The element at " << stan::error_index::value + n
<< " is ";
std::string msg1_str(msg1.str());
std::ostringstream msg2;
msg2 << ", but should be greater than the previous element, "
<< y[n-1];
<< y[n - 1];
std::string msg2_str(msg2.str());
domain_error(function, name, y[n],
msg1_str.c_str(), msg2_str.c_str());
Expand Down
3 changes: 2 additions & 1 deletion stan/math/prim/mat/fun/autocorrelation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace stan {
* a minimum number of zeros are padded.
*/
size_t fft_next_good_size(size_t N) {
if (N <= 2) return 2;
if (N <= 2)
return 2;
while (true) {
size_t m = N;
while ((m % 2) == 0) m /= 2;
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/autocovariance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace stan {
Eigen::FFT<T>& fft) {
autocorrelation(y, acov, fft);

T var = variance(y) * (y.size()-1) / y.size();
T var = variance(y) * (y.size() - 1) / y.size();
for (size_t i = 0; i < y.size(); i++) {
acov[i] *= var;
}
Expand Down
4 changes: 2 additions & 2 deletions stan/math/prim/mat/fun/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ namespace stan {
block(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& m,
size_t i, size_t j, size_t nrows, size_t ncols) {
check_row_index("block", "i", m, i);
check_row_index("block", "i+nrows-1", m, i+nrows-1);
check_row_index("block", "i+nrows-1", m, i + nrows - 1);
check_column_index("block", "j", m, j);
check_column_index("block", "j+ncols-1", m, j+ncols-1);
check_column_index("block", "j+ncols-1", m, j + ncols - 1);
return m.block(i - 1, j - 1, nrows, ncols);
}

Expand Down
6 changes: 4 additions & 2 deletions stan/math/prim/mat/fun/cholesky_corr_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace stan {
for (int i = 0; i < k_choose_2; ++i)
z(i) = corr_constrain(y(i));
Matrix<T, Dynamic, Dynamic> x(K, K);
if (K == 0) return x;
if (K == 0)
return x;
T zero(0);
for (int j = 1; j < K; ++j)
for (int i = 0; i < j; ++i)
Expand Down Expand Up @@ -62,7 +63,8 @@ namespace stan {
for (int i = 0; i < k_choose_2; ++i)
z(i) = corr_constrain(y(i), lp);
Matrix<T, Dynamic, Dynamic> x(K, K);
if (K == 0) return x;
if (K == 0)
return x;
T zero(0);
for (int j = 1; j < K; ++j)
for (int i = 0; i < j; ++i)
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/corr_matrix_free.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace stan {
typedef typename index_type<Matrix<T, Dynamic, 1> >::type size_type;

size_type k = y.rows();
size_type k_choose_2 = (k * (k-1)) / 2;
size_type k_choose_2 = (k * (k - 1)) / 2;
Array<T, Dynamic, 1> x(k_choose_2);
Array<T, Dynamic, 1> sds(k);
bool successful = factor_cov_matrix(y, x, sds);
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/cov_matrix_free_lkj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace stan {
check_nonzero_size("cov_matrix_free_lkj", "y", y);
check_square("cov_matrix_free_lkj", "y", y);
size_type k = y.rows();
size_type k_choose_2 = (k * (k-1)) / 2;
size_type k_choose_2 = (k * (k - 1)) / 2;
Array<T, Dynamic, 1> cpcs(k_choose_2);
Array<T, Dynamic, 1> sds(k);
bool successful = factor_cov_matrix(y, cpcs, sds);
Expand Down
6 changes: 3 additions & 3 deletions stan/math/prim/mat/fun/csr_to_dense_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace stan {
/** \addtogroup csr_format
* @{
*/
/**
/**
* Construct a dense Eigen matrix from the CSR format components.
*
* @tparam T Type of matrix entries.
Expand Down Expand Up @@ -44,10 +44,10 @@ namespace stan {

check_positive("csr_to_dense_matrix", "m", m);
check_positive("csr_to_dense_matrix", "n", n);
check_size_match("csr_to_dense_matrix", "m", m, "u", u.size()-1);
check_size_match("csr_to_dense_matrix", "m", m, "u", u.size() - 1);
check_size_match("csr_to_dense_matrix", "w", w.size(), "v", v.size());
check_size_match("csr_to_dense_matrix", "u/z",
u[m-1] + csr_u_to_z(u, m - 1) - 1,
u[m - 1] + csr_u_to_z(u, m - 1) - 1,
"v", v.size());
for (size_t i = 0; i < v.size(); ++i)
check_range("csr_to_dense_matrix", "v[]", n, v[i]);
Expand Down
4 changes: 2 additions & 2 deletions stan/math/prim/mat/fun/cumulative_sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace stan {
return result;
result[0] = x[0];
for (size_t i = 1; i < result.size(); ++i)
result[i] = x[i] + result[i-1];
result[i] = x[i] + result[i - 1];
return result;
}

Expand All @@ -52,7 +52,7 @@ namespace stan {
return result;
result(0) = m(0);
for (int i = 1; i < result.size(); ++i)
result(i) = m(i) + result(i-1);
result(i) = m(i) + result(i - 1);
return result;
}
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/factor_U.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace stan {
CPCs.segment(position, pull) = temp;
acc.tail(pull) *= 1.0 - temp.square();
}
CPCs = 0.5 * ( (1.0 + CPCs) / (1.0 - CPCs) ).log(); // now unbounded
CPCs = 0.5 * ((1.0 + CPCs) / (1.0 - CPCs)).log(); // now unbounded
}

}
Expand Down
3 changes: 2 additions & 1 deletion stan/math/prim/mat/fun/factor_cov_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace stan {
size_t K = sds.rows();

sds = Sigma.diagonal().array();
if ( (sds <= 0.0).any() ) return false;
if ((sds <= 0.0).any())
return false;
sds = sds.sqrt();

Eigen::DiagonalMatrix<T, Eigen::Dynamic> D(K);
Expand Down
17 changes: 9 additions & 8 deletions stan/math/prim/mat/fun/get_base1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1(x[i1 - 1], i2, error_msg, idx+1);
return get_base1(x[i1 - 1], i2, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1(x[i1 - 1], i2, i3, error_msg, idx+1);
return get_base1(x[i1 - 1], i2, i3, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -118,7 +118,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1(x[i1 - 1], i2, i3, i4, error_msg, idx+1);
return get_base1(x[i1 - 1], i2, i3, i4, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -152,7 +152,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1(x[i1 - 1], i2, i3, i4, i5, error_msg, idx+1);
return get_base1(x[i1 - 1], i2, i3, i4, i5, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -188,7 +188,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, error_msg, idx+1);
return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -226,7 +226,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx+1);
return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -267,7 +267,8 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8, error_msg, idx+1);
return get_base1(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8, error_msg,
idx + 1);
}

/**
Expand Down Expand Up @@ -297,7 +298,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
return x.block(m-1, 0, 1, x.cols());
return x.block(m - 1, 0, 1, x.cols());
}

/**
Expand Down
15 changes: 8 additions & 7 deletions stan/math/prim/mat/fun/get_base1_lhs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1_lhs(x[i1 - 1], i2, i3, error_msg, idx+1);
return get_base1_lhs(x[i1 - 1], i2, i3, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -119,7 +119,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, error_msg, idx+1);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -153,7 +153,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, error_msg, idx+1);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, error_msg, idx+1);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -228,7 +228,8 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg, idx+1);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, error_msg,
idx + 1);
}

/**
Expand Down Expand Up @@ -270,7 +271,7 @@ namespace stan {
size_t idx) {
check_range("[]", "x", x.size(), i1, idx, error_msg);
return get_base1_lhs(x[i1 - 1], i2, i3, i4, i5, i6, i7, i8,
error_msg, idx+1);
error_msg, idx + 1);
}

/**
Expand Down Expand Up @@ -301,7 +302,7 @@ namespace stan {
const std::string& error_msg,
size_t idx) {
check_range("[]", "rows of x", x.rows(), m, idx, error_msg);
return x.block(m-1, 0, 1, x.cols());
return x.block(m - 1, 0, 1, x.cols());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/ordered_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace stan {
return y;
y[0] = x[0];
for (size_type i = 1; i < k; ++i)
y[i] = y[i-1] + exp(x[i]);
y[i] = y[i - 1] + exp(x[i]);
return y;
}

Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/ordered_free.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace stan {
return x;
x[0] = y[0];
for (size_type i = 1; i < k; ++i)
x[i] = log(y[i] - y[i-1]);
x[i] = log(y[i] - y[i - 1]);
return x;
}
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/positive_ordered_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace stan {
return y;
y[0] = exp(x[0]);
for (size_type i = 1; i < k; ++i)
y[i] = y[i-1] + exp(x[i]);
y[i] = y[i - 1] + exp(x[i]);
return y;
}

Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/positive_ordered_free.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace stan {
return x;
x[0] = log(y[0]);
for (size_type i = 1; i < k; ++i)
x[i] = log(y[i] - y[i-1]);
x[i] = log(y[i] - y[i - 1]);
return x;
}
}
Expand Down
Loading