NumCpp  2.5.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
ones.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 #include "NumCpp/Core/Shape.hpp"
32 #include "NumCpp/Core/Types.hpp"
34 #include "NumCpp/NdArray.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
48  template<typename dtype>
49  NdArray<dtype> ones(uint32 inSquareSize)
50  {
52 
53  return full(inSquareSize, inSquareSize, dtype{ 1 });
54  }
55 
56  //============================================================================
57  // Method Description:
67  template<typename dtype>
68  NdArray<dtype> ones(uint32 inNumRows, uint32 inNumCols)
69  {
71 
72  return full(inNumRows, inNumCols, dtype{ 1 });
73  }
74 
75  //============================================================================
76  // Method Description:
86  template<typename dtype>
87  NdArray<dtype> ones(const Shape& inShape)
88  {
90 
91  return full(inShape, dtype{ 1 });
92  }
93 } // namespace nc
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:50
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
Definition: Coordinate.hpp:45
NdArray< dtype > full(uint32 inSquareSize, dtype inFillValue)
Definition: full.hpp:48
NdArray< dtype > ones(uint32 inSquareSize)
Definition: ones.hpp:49
std::uint32_t uint32
Definition: Types.hpp:40