NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
diag.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include "NumCpp/Core/Types.hpp"
33#include "NumCpp/NdArray.hpp"
34
35namespace 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:139
bool isflat() const noexcept
Definition: NdArrayCore.hpp:2945
Definition: Cartesian.hpp:40
NdArray< dtype > diagonal(const NdArray< dtype > &inArray, int32 inOffset=0, Axis inAxis=Axis::ROW)
Definition: diagonal.hpp:47
NdArray< dtype > diag(const NdArray< dtype > &inArray, int32 k=0)
Definition: diag.hpp:51
NdArray< dtype > diagflat(const NdArray< dtype > &inArray, int32 k=0)
Definition: diagflat.hpp:51
std::int32_t int32
Definition: Types.hpp:36