NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
ldexp.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31
35#include "NumCpp/Core/Types.hpp"
36#include "NumCpp/NdArray.hpp"
37
38namespace nc
39{
40 //============================================================================
41 // Method Description:
51 template<typename dtype>
52 dtype ldexp(dtype inValue1, uint8 inValue2) noexcept
53 {
55
56 return static_cast<dtype>(std::ldexp(static_cast<double>(inValue1), inValue2));
57 }
58
59 //============================================================================
60 // Method Description:
70 template<typename dtype>
71 NdArray<dtype> ldexp(const NdArray<dtype>& inArray1, const NdArray<uint8>& inArray2)
72 {
73 if (inArray1.shape() != inArray2.shape())
74 {
75 THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
76 }
77
78 NdArray<dtype> returnArray(inArray1.shape());
80 inArray1.cend(),
81 inArray2.cbegin(),
82 returnArray.begin(),
83 [](dtype inValue1, uint8 inValue2) noexcept -> dtype
84 { return ldexp(inValue1, inValue2); });
85
86 return returnArray;
87 }
88} // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1361
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1669
iterator begin() noexcept
Definition NdArrayCore.hpp:1311
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition StlAlgorithms.hpp:776
Definition Cartesian.hpp:39
std::uint8_t uint8
Definition Types.hpp:42
dtype ldexp(dtype inValue1, uint8 inValue2) noexcept
Definition ldexp.hpp:52