NumCpp  1.0
A C++ implementation of the Python Numpy library
diag.hpp
Go to the documentation of this file.
1 #pragma once
30 
31 #include "NumCpp/NdArray.hpp"
32 #include "NumCpp/Core/Types.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
51  template<typename dtype>
52  NdArray<dtype> diag(const NdArray<dtype>& inArray, int32 k = 0)
53  {
54  if (inArray.isflat())
55  {
56  return diagflat(inArray, k);
57  }
58  else
59  {
60  return diagonal(inArray, k, Axis::ROW);
61  }
62  }
63 }
nc::diag
NdArray< dtype > diag(const NdArray< dtype > &inArray, int32 k=0)
Definition: diag.hpp:52
nc::int32
std::int32_t int32
Definition: Types.hpp:37
nc::Axis::ROW
@ ROW
nc::NdArray< dtype >
NdArray.hpp
nc::diagonal
NdArray< dtype > diagonal(const NdArray< dtype > &inArray, int32 inOffset=0, Axis inAxis=Axis::ROW)
Definition: diagonal.hpp:49
nc::NdArray::isflat
bool isflat() const noexcept
Definition: NdArrayCore.hpp:2874
diagonal.hpp
nc::diagflat
NdArray< dtype > diagflat(const NdArray< dtype > &inArray, int32 k=0)
Definition: diagflat.hpp:52
nc
Definition: Coordinate.hpp:45
Types.hpp
diagflat.hpp