NumCpp
2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
frombuffer.hpp
Go to the documentation of this file.
1
#pragma once
29
30
#include "
NumCpp/Core/Internal/Error.hpp
"
31
#include "
NumCpp/Core/Types.hpp
"
32
#include "
NumCpp/NdArray.hpp
"
33
34
namespace
nc
35
{
36
//============================================================================
37
// Method Description:
47
template
<
typename
dtype>
48
NdArray<dtype>
frombuffer
(
const
char
* inBufferPtr,
uint32
inNumBytes)
49
{
50
if
(inNumBytes %
sizeof
(dtype) != 0)
51
{
52
THROW_INVALID_ARGUMENT_ERROR
(
"inNumBytes % sizeof(dtype) != 0"
);
53
}
54
55
const
auto
numElements =
static_cast<
uint32
>
(inNumBytes /
sizeof
(dtype));
56
return
NdArray<dtype>
(
reinterpret_cast<
const
dtype*
>
(inBufferPtr), numElements);
57
}
58
}
// namespace nc
nc::frombuffer
NdArray< dtype > frombuffer(const char *inBufferPtr, uint32 inNumBytes)
Definition:
frombuffer.hpp:48
Error.hpp
nc::NdArray< dtype >
nc::uint32
std::uint32_t uint32
Definition:
Types.hpp:40
NdArray.hpp
nc
Definition:
Coordinate.hpp:44
THROW_INVALID_ARGUMENT_ERROR
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition:
Error.hpp:36
Types.hpp
include
NumCpp
Functions
frombuffer.hpp
Generated by
1.8.17