Skip to content
Closed
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
2 changes: 1 addition & 1 deletion stan/math/opencl/kernel_generator/load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class load_
* Creates a deep copy of this expression.
* @return copy of \c *this
*/
inline load_<T&> deep_copy() const & { return load_<T&>(a_); }
inline load_<T&> deep_copy() const& { return load_<T&>(a_); }
inline load_<T> deep_copy() && { return load_<T>(std::forward<T>(a_)); }

/**
Expand Down
16 changes: 11 additions & 5 deletions stan/math/prim/fun/add.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <type_traits>
Comment thread
andrjohns marked this conversation as resolved.

namespace stan {
namespace math {
Expand All @@ -22,7 +23,8 @@ namespace math {
* dimensions.
*/
template <typename Mat1, typename Mat2,
typename = require_all_eigen_t<Mat1, Mat2>>
require_all_eigen_t<Mat1, Mat2>* = nullptr,
require_all_not_eigen_vt<is_var, Mat1, Mat2>* = nullptr>
inline auto add(const Mat1& m1, const Mat2& m2) {
check_matching_dims("add", "m1", m1, "m2", m2);
return (m1 + m2).eval();
Expand All @@ -37,8 +39,10 @@ inline auto add(const Mat1& m1, const Mat2& m2) {
* @param c Scalar.
* @return The matrix plus the scalar.
*/
template <typename Mat, typename Scal, typename = require_eigen_t<Mat>,
typename = require_stan_scalar_t<Scal>>
template <typename Mat, typename Scal, require_eigen_t<Mat>* = nullptr,
require_stan_scalar_t<Scal>* = nullptr,
require_not_var_t<Scal>* = nullptr,
require_not_eigen_vt<is_var, Mat>* = nullptr>
inline auto add(const Mat& m, const Scal c) {
return (m.array() + c).matrix().eval();
}
Expand All @@ -52,8 +56,10 @@ inline auto add(const Mat& m, const Scal c) {
* @param m Matrix.
* @return The scalar plus the matrix.
*/
template <typename Scal, typename Mat, typename = require_stan_scalar_t<Scal>,
typename = require_eigen_t<Mat>>
template <typename Mat, typename Scal, require_eigen_t<Mat>* = nullptr,
require_stan_scalar_t<Scal>* = nullptr,
require_not_var_t<Scal>* = nullptr,
require_not_eigen_vt<is_var, Mat>* = nullptr>
inline auto add(const Scal c, const Mat& m) {
return (c + m.array()).matrix().eval();
}
Expand Down
16 changes: 11 additions & 5 deletions stan/math/prim/fun/subtract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <type_traits>

namespace stan {
namespace math {
Expand All @@ -20,7 +21,8 @@ namespace math {
* @return Difference between first matrix and second matrix.
*/
template <typename Mat1, typename Mat2,
typename = require_all_eigen_t<Mat1, Mat2>>
require_all_eigen_t<Mat1, Mat2>* = nullptr,
require_all_not_eigen_vt<is_var, Mat1, Mat2>* = nullptr>
inline auto subtract(const Mat1& m1, const Mat2& m2) {
check_matching_dims("subtract", "m1", m1, "m2", m2);
return (m1 - m2).eval();
Expand All @@ -36,8 +38,10 @@ inline auto subtract(const Mat1& m1, const Mat2& m2) {
* @param m Matrix or expression.
* @return The scalar minus the matrix.
*/
template <typename Scal, typename Mat, typename = require_stan_scalar_t<Scal>,
typename = require_eigen_t<Mat>>
template <typename Mat, typename Scal, require_eigen_t<Mat>* = nullptr,
require_stan_scalar_t<Scal>* = nullptr,
require_not_var_t<Scal>* = nullptr,
require_not_eigen_vt<is_var, Mat>* = nullptr>
inline auto subtract(const Scal c, const Mat& m) {
return (c - m.array()).matrix().eval();
}
Expand All @@ -52,8 +56,10 @@ inline auto subtract(const Scal c, const Mat& m) {
* @param c Scalar.
* @return The matrix minus the scalar.
*/
template <typename Mat, typename Scal, typename = require_eigen_t<Mat>,
typename = require_stan_scalar_t<Scal>>
template <typename Mat, typename Scal, require_eigen_t<Mat>* = nullptr,
require_stan_scalar_t<Scal>* = nullptr,
require_not_var_t<Scal>* = nullptr,
require_not_eigen_vt<is_var, Mat>* = nullptr>
inline auto subtract(const Mat& m, const Scal c) {
return (m.array() - c).matrix().eval();
}
Expand Down
2 changes: 2 additions & 0 deletions stan/math/rev/fun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <stan/math/rev/fun/abs.hpp>
#include <stan/math/rev/fun/acos.hpp>
#include <stan/math/rev/fun/acosh.hpp>
#include <stan/math/rev/fun/add.hpp>
#include <stan/math/rev/fun/as_bool.hpp>
#include <stan/math/rev/fun/arg.hpp>
#include <stan/math/rev/fun/asin.hpp>
Expand Down Expand Up @@ -127,6 +128,7 @@
#include <stan/math/rev/fun/squared_distance.hpp>
#include <stan/math/rev/fun/stan_print.hpp>
#include <stan/math/rev/fun/step.hpp>
#include <stan/math/rev/fun/subtract.hpp>
#include <stan/math/rev/fun/sum.hpp>
#include <stan/math/rev/fun/tan.hpp>
#include <stan/math/rev/fun/tanh.hpp>
Expand Down
Loading