Closed faze-geek closed 6 months ago
Do you have a more specific question, I'm not certain what you are really asking?
The dtype
is handled throughout the library as a template parameter, for example:
auto data = nc::NdArray<double>{5, 6};
This will create an NdArray
of dtype
double and dimensions 5x6.
Hi @dpilger26 . There are various dtypes we in numpy - https://numpy.org/doc/stable/reference/arrays.dtypes.html
I meant how do you smartly handle the dtype
, ensure an annotation of right size and memory is used.
Like If I want to pick int32
(integer of 32 bits) or let's say something more advanced like complex128
(floating point complex number of 128 bits), what will be the cpp equivalent used.
If you can point me out to the files where the dtypes for NumCPP are designed it will be helpful as well.
I don't think you are understanding... it sounds like maybe you come from a Python background and haven't done a lot of C++? The dtypes
aren't "designed" like you say. The dtype
is a template parameter into NdArray<dtype>
, and can be any C++ arithmetic type, as well as std::complex<T>
, and can also act as an array for structured data types while disabling the arithmetic operations. The data is stored under the hood as a contiguous, row major block of memory of the chosen dtype
. The NdArrayCore.hpp
file is where this is all defined:
https://github.com/dpilger26/NumCpp/blob/master/include/NumCpp/NdArray/NdArrayCore.hpp
I got what I wanted. Thanks for answering my silly doubts :)
@dpilger26
The
dtype
is a template parameter intoNdArray<dtype>
, and can be any C++ arithmetic type, as well asstd::complex<T>
Can the dtype
be precision types like int8
, int16
, int32
, int64
as well or all integers are just int
?
I think for precision types C++ libraries like cstdint
provide int8_t
, int16_t
and so on.
I see that is handled here. Thanks ! https://github.com/dpilger26/NumCpp/blob/5e40aab74d14e257d65d3dc385c9ff9e2120c60e/include/NumCpp/Core/Types.hpp#L30-L43
Hello everyone, This is more of a doubt than an issue, I could not find a discussion forum or mailing list so I'm asking it here itself. I am new to this interesting idea of implementing Numpy through CPP and had a very basic doubt.
How are the various
dtypes
of Numpy ndarray likeint8
,int16
,int32
,float32
handled in c++ ? Can someone point me to the implementation and briefly explain the thought behind it ?