columnize.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_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. // Templates:
  21. // T should be a eigen matrix primitive type like int or double
  22. // Inputs:
  23. // A m*k by n (dim: 1) or m by n*k (dim: 2) eigen Matrix of type T values
  24. // k number of blocks
  25. // dim dimension in which blocks are stacked
  26. // Output
  27. // B m*n*k eigen vector of type T values,
  28. //
  29. // See also: transpose_blocks
  30. template <typename DerivedA, typename DerivedB>
  31. IGL_INLINE void columnize(
  32. const Eigen::PlainObjectBase<DerivedA> & A,
  33. const int k,
  34. const int dim,
  35. Eigen::PlainObjectBase<DerivedB> & B);
  36. }
  37. #ifndef IGL_STATIC_LIBRARY
  38. # include "columnize.cpp"
  39. #endif
  40. #endif