-
Notifications
You must be signed in to change notification settings - Fork 398
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
sign function #99
sign function #99
Conversation
Since #85 was merged, this needs to be rebased on master and use the new pattern for ufuncs. |
include/xtensor/xmath.hpp
Outdated
-> detail::get_xfunction_free_type<E> | ||
{ | ||
using functor_type = detail::mf_type<E>; | ||
return detail::make_xfunction((functor_type)detail::sign_impl, e.derived_cast()); |
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.
e.derived_cast
-> std::forward<E>(e)
include/xtensor/xmath.hpp
Outdated
{ | ||
return std::numeric_limits<T>::quiet_NaN(); | ||
} | ||
return x == 0 ? copysign(T(0), x) : copysign(T(1), x); |
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.
this is what causes the windows failure. One cannot have multiple return
statements in a constexpr function. So this leaves you with
return std::isnan(x)? std::numeric_limits<T>::quiet_NaN() : (x == 0 ? copysign(T(0), x) : copysign(T(1), x));
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.
Is the statement about isnan required?
Would the last statement suffice?
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.
I was about to remove the constexpr, but I guess going with your solution will work as well.
The isnan is what numpy is doing. Not sure if required.
You can decide! ;)
I think that it would make sense for me to squash these few commits together while merging. |
Sure
…On Feb 2, 2017 12:09, "Sylvain Corlay" ***@***.***> wrote:
I think that it would make sense for me to squash these few commits
together while merging.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#99 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA2BPgRMNGmyNY4eJKQVtAXA3Q1iCxsWks5rYblMgaJpZM4L0S53>
.
|
Behaves equivalent to numpy's sign function.