NumCpp  2.9.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
rot90.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include "NumCpp/Core/Types.hpp"
34 #include "NumCpp/NdArray.hpp"
35 
36 namespace nc
37 {
38  //============================================================================
39  // Method Description:
49  template<typename dtype>
50  NdArray<dtype> rot90(const NdArray<dtype>& inArray, uint8 inK = 1)
51  {
52  inK %= 4;
53  switch (inK)
54  {
55  case 0:
56  {
57  return inArray;
58  }
59  case 1:
60  {
61  return flipud(inArray.transpose());
62  }
63  case 2:
64  {
65  return flip(inArray, Axis::NONE);
66  }
67  case 3:
68  {
69  return fliplr(inArray.transpose());
70  }
71  default:
72  {
73  // this isn't actually possible, just putting this here to get rid
74  // of the compiler warning.
75  return {};
76  }
77  }
78  }
79 } // namespace nc
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4457
Definition: Coordinate.hpp:45
NdArray< dtype > flipud(const NdArray< dtype > &inArray)
Definition: flipud.hpp:46
NdArray< dtype > rot90(const NdArray< dtype > &inArray, uint8 inK=1)
Definition: rot90.hpp:50
std::uint8_t uint8
Definition: Types.hpp:42
NdArray< dtype > flip(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: flip.hpp:47
NdArray< dtype > fliplr(const NdArray< dtype > &inArray)
Definition: fliplr.hpp:46