| 509 | struct LogbChecked { |
| 510 | template <typename T, typename Arg0, typename Arg1> |
| 511 | static enable_if_floating_value<T> Call(KernelContext*, Arg0 x, Arg1 base, Status* st) { |
| 512 | static_assert(std::is_same<T, Arg0>::value, ""); |
| 513 | static_assert(std::is_same<Arg0, Arg1>::value, ""); |
| 514 | if (x == 0.0 || base == 0.0) { |
| 515 | *st = Status::Invalid("logarithm of zero"); |
| 516 | return x; |
| 517 | } else if (x < 0.0 || base < 0.0) { |
| 518 | *st = Status::Invalid("logarithm of negative number"); |
| 519 | return x; |
| 520 | } |
| 521 | return std::log(x) / std::log(base); |
| 522 | } |
| 523 | }; |
| 524 | |
| 525 | // Generate a kernel given a bitwise arithmetic functor. Assumes the |