NumCpp  2.8.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
diag.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include "NumCpp/Core/Types.hpp"
33 #include "NumCpp/NdArray.hpp"
34 
35 namespace nc
36 {
37  //============================================================================
38  // Method Description:
50  template<typename dtype>
51  NdArray<dtype> diag(const NdArray<dtype>& inArray, int32 k = 0)
52  {
53  if (inArray.isflat())
54  {
55  return diagflat(inArray, k);
56  }
57 
58  return diagonal(inArray, k, Axis::ROW);
59  }
60 } // namespace nc
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
bool isflat() const noexcept
Definition: NdArrayCore.hpp:2847
Definition: Coordinate.hpp:45
NdArray< dtype > diag(const NdArray< dtype > &inArray, int32 k=0)
Definition: diag.hpp:51
NdArray< dtype > diagonal(const NdArray< dtype > &inArray, int32 inOffset=0, Axis inAxis=Axis::ROW)
Definition: diagonal.hpp:47
std::int32_t int32
Definition: Types.hpp:36
NdArray< dtype > diagflat(const NdArray< dtype > &inArray, int32 k=0)
Definition: diagflat.hpp:51