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