NumCpp  2.8.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
identity.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include "NumCpp/NdArray.hpp"
31 
32 namespace nc
33 {
34  //============================================================================
35  // Method Description:
46  template<typename dtype>
48  {
49  NdArray<dtype> returnArray(inSquareSize);
50  returnArray.zeros();
51  for (uint32 i = 0; i < inSquareSize; ++i)
52  {
53  returnArray(i, i) = dtype{ 1 };
54  }
55 
56  return returnArray;
57  }
58 } // namespace nc
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
NdArray< dtype > & zeros() noexcept
Definition: NdArrayCore.hpp:4668
Definition: Coordinate.hpp:45
NdArray< dtype > identity(uint32 inSquareSize)
Definition: identity.hpp:47
std::uint32_t uint32
Definition: Types.hpp:40