PlainVector.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2024 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_PLAINVECTOR_H
  9. #define IGL_PLAINVECTOR_H
  10. #include <Eigen/Core>
  11. #include "PlainMatrix.h"
  12. namespace igl
  13. {
  14. // PlainVectorHelper to determine correct matrix type based on Derived and Size
  15. template <typename Derived, int Size, int Options>
  16. struct PlainVectorHelper {
  17. // Conditional Type: Column vector if is_column_vector is true, otherwise row vector
  18. using Type = Eigen::Matrix<
  19. typename Derived::Scalar,
  20. (Derived::ColsAtCompileTime == 1 && Derived::RowsAtCompileTime != 1) ? Size : 1,
  21. (Derived::ColsAtCompileTime == 1 && Derived::RowsAtCompileTime != 1) ? 1 : Size,
  22. Options>;
  23. };
  24. /// \see PlainMatrix
  25. template <
  26. typename Derived,
  27. int Size = (Derived::ColsAtCompileTime == 1 && Derived::RowsAtCompileTime != 1) ? Derived::RowsAtCompileTime : Derived::ColsAtCompileTime,
  28. int Options = get_options<Derived>::value>
  29. using PlainVector = typename PlainVectorHelper<Derived, Size, Options>::Type;
  30. }
  31. #endif