Skip to content

Commit

Permalink
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-buildbot committed Aug 4, 2023
1 parent 1bfd431 commit 119099d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
46 changes: 23 additions & 23 deletions stan/math/rev/core/arena_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class arena_matrix : public Eigen::Map<MatrixType> {
auto other
= make_chainable_ptr(plain_type_t<MatrixType>(std::move(x)));
// other has it's rows and cols swapped already if it needed that
return base_map_t(&(other->coeffRef(0)), other->rows(), other->cols());
return base_map_t(&(other->coeffRef(0)), other->rows(),
other->cols());
} else {
base_map_t map(
ChainableStack::instance_->memalloc_.alloc_array<Scalar>(
Expand Down Expand Up @@ -156,29 +157,28 @@ class arena_matrix : public Eigen::Map<MatrixType> {
template <typename T, require_not_arena_matrix_t<T>* = nullptr>
arena_matrix& operator=(T&& a) {
using T_t = std::decay_t<T>;
if (std::is_rvalue_reference<T&&>::value
&& is_plain_type<T_t>::value) {
// Note: plain_type_t here does nothing since T_t is plain type
auto other
= make_chainable_ptr(plain_type_t<MatrixType>(std::move(a)));
new (this) Base(&(other->coeffRef(0)), other->rows(), other->cols());
return *this;
if (std::is_rvalue_reference<T&&>::value && is_plain_type<T_t>::value) {
// Note: plain_type_t here does nothing since T_t is plain type
auto other = make_chainable_ptr(plain_type_t<MatrixType>(std::move(a)));
new (this) Base(&(other->coeffRef(0)), other->rows(), other->cols());
return *this;
} else {
// do we need to transpose?
if ((RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1)
|| (ColsAtCompileTime == 1 && T_t::RowsAtCompileTime == 1)) {
// placement new changes what data map points to - there is no allocation
new (this) Base(
ChainableStack::instance_->memalloc_.alloc_array<Scalar>(a.size()),
a.cols(), a.rows());

} else {
new (this) Base(
ChainableStack::instance_->memalloc_.alloc_array<Scalar>(a.size()),
a.rows(), a.cols());
}
Base::operator=(a);
return *this;
// do we need to transpose?
if ((RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1)
|| (ColsAtCompileTime == 1 && T_t::RowsAtCompileTime == 1)) {
// placement new changes what data map points to - there is no
// allocation
new (this) Base(
ChainableStack::instance_->memalloc_.alloc_array<Scalar>(a.size()),
a.cols(), a.rows());

} else {
new (this) Base(
ChainableStack::instance_->memalloc_.alloc_array<Scalar>(a.size()),
a.rows(), a.cols());
}
Base::operator=(a);
return *this;
}
}
};
Expand Down
6 changes: 4 additions & 2 deletions test/unit/math/rev/fun/fill_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ TEST_F(AgradRev, fillVarMatDouble) {
using stan::math::fill;
using stan::math::sum;
using stan::math::var_value;
Matrix<double, Dynamic, 1> y_val = Matrix<double, Dynamic, 1>::Constant(3, 2.0);
Matrix<double, Dynamic, 1> y_val
= Matrix<double, Dynamic, 1>::Constant(3, 2.0);
var_value<Matrix<double, Dynamic, 1>> y(y_val);
fill(y, 3.0);
EXPECT_EQ(3, y.size());
Expand All @@ -79,7 +80,8 @@ TEST_F(AgradRev, fillVarMatVar) {
using stan::math::sum;
using stan::math::var;
using stan::math::var_value;
Matrix<double, Dynamic, 1> y_val = Matrix<double, Dynamic, 1>::Constant(3, 2.0);
Matrix<double, Dynamic, 1> y_val
= Matrix<double, Dynamic, 1>::Constant(3, 2.0);
var_value<Matrix<double, Dynamic, 1>> y(y_val);
var z(3.0);
fill(y, z);
Expand Down

0 comments on commit 119099d

Please sign in to comment.