NumCpp  2.8.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
fillDiagnol.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include "NumCpp/Core/Shape.hpp"
31 #include "NumCpp/Core/Types.hpp"
32 #include "NumCpp/NdArray.hpp"
33 
34 namespace nc
35 {
36  //============================================================================
37  // Method Description:
45  template<typename dtype>
46  void fillDiagonal(NdArray<dtype>& inArray, dtype inValue) noexcept
47  {
48  const auto inShape = inArray.shape();
49  for (uint32 row = 0; row < inShape.rows; ++row)
50  {
51  if (row < inShape.cols)
52  {
53  inArray(row, row) = inValue;
54  }
55  }
56  }
57 } // namespace nc
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
Definition: Coordinate.hpp:45
void fillDiagonal(NdArray< dtype > &inArray, dtype inValue) noexcept
Definition: fillDiagnol.hpp:46
std::uint32_t uint32
Definition: Types.hpp:40