Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var matrix specializations for a-c unary functions in rev #2256

Merged
merged 30 commits into from
Dec 19, 2020
Merged
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0c52267
adds unary functions from a to c for varmat
SteveBronder Dec 10, 2020
17b853d
Merge remote-tracking branch 'origin/develop' into feature/varmat-a-t…
SteveBronder Dec 12, 2020
2f8da9f
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 12, 2020
fe2354c
update docs
SteveBronder Dec 14, 2020
afda49a
Merge commit '7f3792baa9e91438e79a2cf6594a38d105c9b24e' into HEAD
yashikno Dec 14, 2020
91d1472
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 14, 2020
da21330
Merge remote-tracking branch 'origin/develop' into feature/varmat-a-t…
SteveBronder Dec 15, 2020
86d6f8a
add tests for vectors of varmat
SteveBronder Dec 15, 2020
13974c1
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 15, 2020
77f77e8
update abs so it can be vectorized
SteveBronder Dec 15, 2020
1768e1e
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 15, 2020
198bec3
update abs so it can be vectorized
SteveBronder Dec 15, 2020
010ebaf
Merge branch 'feature/varmat-a-to-c-unary' of github.com:stan-dev/mat…
SteveBronder Dec 15, 2020
fac9b65
update with develop, write out sin and tan
SteveBronder Dec 17, 2020
11e3459
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 17, 2020
3a02c30
updates to use cwiseproduct()
SteveBronder Dec 17, 2020
237f6a0
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 17, 2020
0e610cf
update tan test
SteveBronder Dec 17, 2020
37d61ac
update tan requires
SteveBronder Dec 17, 2020
b0738f7
Merge commit '72552dcc6040018b35d2bb1303b461493b815d95' into HEAD
yashikno Dec 17, 2020
ba7dae7
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 17, 2020
8129f72
update tan requires
SteveBronder Dec 17, 2020
88c35d9
update tan requires
SteveBronder Dec 17, 2020
4fa4816
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 17, 2020
0db6223
Fixes tests and docs for var<matrix> trig functions and apply_scalar_…
SteveBronder Dec 18, 2020
a7deb36
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 18, 2020
7e41553
Updated abs/fabs tests to be like the others (Issue #2101)
bbbales2 Dec 18, 2020
b26159f
remove .noalias() from trig functions in rev
SteveBronder Dec 18, 2020
812ae25
Merge commit '3d03131bdcbb2d33878f4117c857ac6404c7e10e' into HEAD
yashikno Dec 18, 2020
c5caa59
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Dec 18, 2020
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
84 changes: 42 additions & 42 deletions stan/math/prim/fun/abs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,50 @@
namespace stan {
namespace math {

/**
* Structure to wrap `abs()` so it can be vectorized.
*
* @tparam T type of variable
* @param x argument
* @return Arc cosine of variable in radians.
*/
struct abs_fun {
template <typename T>
static inline T fun(const T& x) {
using std::fabs;
return fabs(x);
}
};
/**
* Structure to wrap `abs()` so it can be vectorized.
*
* @tparam T type of variable
* @param x argument
* @return Arc cosine of variable in radians.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute value

*/
struct abs_fun {
template <typename T>
static inline T fun(const T& x) {
using std::fabs;
return fabs(x);
}
};

/**
* Returns the elementwise `abs()` of the input,
* which may be a scalar or any Stan container of numeric scalars.
*
* @tparam Container type of container
* @param x argument
* @return Arc cosine of each variable in the container, in radians.
*/
template <typename Container,
require_not_container_st<std::is_arithmetic, Container>* = nullptr,
require_not_var_matrix_t<Container>* = nullptr>
inline auto abs(const Container& x) {
return apply_scalar_unary<abs_fun, Container>::apply(x);
}
/**
* Returns the elementwise `abs()` of the input,
* which may be a scalar or any Stan container of numeric scalars.
*
* @tparam Container type of container
* @param x argument
* @return Arc cosine of each variable in the container, in radians.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute value

*/
template <typename Container,
require_not_container_st<std::is_arithmetic, Container>* = nullptr,
require_not_var_matrix_t<Container>* = nullptr>
inline auto abs(const Container& x) {
return apply_scalar_unary<abs_fun, Container>::apply(x);
}

/**
* Version of `abs()` that accepts std::vectors, Eigen Matrix/Array objects
* or expressions, and containers of these.
*
* @tparam Container Type of x
* @param x argument
* @return Arc cosine of each variable in the container, in radians.
*/
template <typename Container,
require_container_st<std::is_arithmetic, Container>* = nullptr>
inline auto abs(const Container& x) {
return apply_vector_unary<Container>::apply(
x, [](const auto& v) { return v.array().abs(); });
}
/**
* Version of `abs()` that accepts std::vectors, Eigen Matrix/Array objects
* or expressions, and containers of these.
*
* @tparam Container Type of x
* @param x argument
* @return Arc cosine of each variable in the container, in radians.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute value

*/
template <typename Container,
require_container_st<std::is_arithmetic, Container>* = nullptr>
inline auto abs(const Container& x) {
return apply_vector_unary<Container>::apply(
x, [](const auto& v) { return v.array().abs(); });
}

namespace internal {
/**
Expand Down