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