columnize.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_COLUMNIZE_H
  9. #define IGL_COLUMNIZE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// "Columnize" a stack of block matrices. If A = [A1,A2,A3,...,Ak] with each A*
  15. /// an m by n block then this produces the column vector whose entries are
  16. /// B(j*m*k+i*k+b) = A(i,b*n+j);
  17. /// or if A = [A1;A2;...;Ak] then
  18. /// B(j*m*k+i*k+b) = A(i+b*m,j);
  19. ///
  20. /// @tparam T should be a eigen matrix primitive type like int or double
  21. /// @param[in] A m*k by n (dim: 1) or m by n*k (dim: 2) eigen Matrix of type T values
  22. /// @param[in] k number of blocks
  23. /// @param[in] dim dimension in which blocks are stacked
  24. /// @param[out] B m*n*k eigen vector of type T values,
  25. ///
  26. /// \see transpose_blocks
  27. template <typename DerivedA, typename DerivedB>
  28. IGL_INLINE void columnize(
  29. const Eigen::MatrixBase<DerivedA> & A,
  30. const int k,
  31. const int dim,
  32. Eigen::PlainObjectBase<DerivedB> & B);
  33. }
  34. #ifndef IGL_STATIC_LIBRARY
  35. # include "columnize.cpp"
  36. #endif
  37. #endif