-
-
Notifications
You must be signed in to change notification settings - Fork 203
Issue 1232 - variadic is_nan function #1233
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
Merged
syclik
merged 21 commits into
stan-dev:develop
from
andrjohns:feature/issue-1232-variadic-is-nan
Jul 9, 2019
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6db5eac
Add variadic is_nan function
8cfb161
Merged 'develop'.
ad06c0c
Add doc
44d5d8d
Add tests for variadic calls
8747c63
Merged 'develop'.
302396d
Improvements to doc
642d4bc
Separate variadic is_any_nan from single input is_nan
d34745e
Fix headers
954b37f
Better testing and passing by reference
f1e26d3
Merged 'develop'.
313b284
[Jenkins] auto-formatting by clang-format version 5.0.0-3~16.04.1 (ta…
stan-buildbot d9587d9
Use consistent templating with is_nan functions
5f1dcb7
[Jenkins] auto-formatting by clang-format version 6.0.0 (tags/google/…
stan-buildbot 65e5660
Fix type traits templating
e277651
Remove unnecessary pass-by-reference and style changes
31f33be
[Jenkins] auto-formatting by clang-format version 6.0.0 (tags/google/…
stan-buildbot 0e3cc54
Merged 'develop'.
ca786de
Fix headers after merging develop
43764d8
Revert autodiff is_nan to develop
cf8dc2f
Merged 'develop'.
66f8df6
Fix cpplint
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #ifndef STAN_MATH_PRIM_SCAL_FUN_IS_ANY_NAN_HPP | ||
| #define STAN_MATH_PRIM_SCAL_FUN_IS_ANY_NAN_HPP | ||
|
|
||
| #include <stan/math/prim/scal/fun/is_nan.hpp> | ||
| #include <utility> | ||
|
|
||
| namespace stan { | ||
| namespace math { | ||
|
|
||
| /** | ||
| * Returns true if the input is NaN and false otherwise. | ||
| * | ||
| * Delegates to <code>stan::math::is_nan</code> so that | ||
| * appropriate specializations can be loaded for autodiff | ||
| * types. | ||
| * | ||
| * @param x Value to test. | ||
| * @return <code>true</code> if the value is NaN. | ||
| */ | ||
| template <typename T> | ||
| inline bool is_any_nan(const T& x) { | ||
| return is_nan(x); | ||
| } | ||
|
|
||
| /** | ||
| * Returns <code>true</code> if any input is NaN and false otherwise. | ||
| * | ||
| * Delegates to <code>stan::math::is_nan</code>. | ||
| * | ||
| * @param x first argument | ||
| * @param xs parameter pack of remaining arguments to forward to function | ||
| * @return <code>true</code> if any value is NaN | ||
| */ | ||
| template <typename T, typename... Ts> | ||
| inline bool is_any_nan(const T& x, const Ts&... xs) { | ||
| return is_any_nan(x) || is_any_nan(std::forward<const Ts>(xs)...); | ||
| } | ||
| } // namespace math | ||
| } // namespace stan | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| #define STAN_MATH_PRIM_SCAL_FUN_LOG_FALLING_FACTORIAL_HPP | ||
|
|
||
| #include <stan/math/prim/scal/err/check_positive.hpp> | ||
| #include <stan/math/prim/scal/fun/is_nan.hpp> | ||
| #include <stan/math/prim/scal/fun/is_any_nan.hpp> | ||
| #include <stan/math/prim/scal/fun/lgamma.hpp> | ||
| #include <stan/math/prim/scal/fun/constants.hpp> | ||
| #include <stan/math/prim/scal/meta/return_type.hpp> | ||
|
|
@@ -54,7 +54,7 @@ namespace math { | |
| template <typename T1, typename T2> | ||
| inline typename return_type<T1, T2>::type log_falling_factorial(const T1 x, | ||
| const T2 n) { | ||
| if (is_nan(x) || is_nan(n)) | ||
| if (is_any_nan(x, n)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [comment] |
||
| return NOT_A_NUMBER; | ||
| static const char* function = "log_falling_factorial"; | ||
| check_positive(function, "first argument", x); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here as in the issue for changing all of these. At most, this should be
so primitives get passed by value.