matrix_to_list.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  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_MATRIX_TO_LIST_H
  9. #define IGL_MATRIX_TO_LIST_H
  10. #include "igl_inline.h"
  11. #include <vector>
  12. #include <Eigen/Dense>
  13. namespace igl
  14. {
  15. // Convert a matrix to a list (std::vector) of row vectors of the same size
  16. // Template:
  17. // Mat Matrix type, must implement:
  18. // .resize(m,n)
  19. // .row(i) = Row
  20. // T type that can be safely cast to type in Mat via '='
  21. // Inputs:
  22. // V a m-long list of vectors of size n
  23. // Outputs:
  24. // M an m by n matrix
  25. //
  26. // See also: list_to_matrix
  27. template <typename DerivedM>
  28. IGL_INLINE void matrix_to_list(
  29. const Eigen::MatrixBase<DerivedM> & M,
  30. std::vector<std::vector<typename DerivedM::Scalar > > & V);
  31. // For vector input
  32. template <typename DerivedM>
  33. IGL_INLINE void matrix_to_list(
  34. const Eigen::MatrixBase<DerivedM> & M,
  35. std::vector<typename DerivedM::Scalar > & V);
  36. // Return wrapper
  37. template <typename DerivedM>
  38. IGL_INLINE std::vector<typename DerivedM::Scalar > matrix_to_list(
  39. const Eigen::MatrixBase<DerivedM> & M);
  40. }
  41. #ifndef IGL_STATIC_LIBRARY
  42. # include "matrix_to_list.cpp"
  43. #endif
  44. #endif