repmat.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_REPMAT_H
  9. #define IGL_REPMAT_H
  10. #include "igl_inline.h"
  11. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  12. #include <Eigen/Dense>
  13. #include <Eigen/Sparse>
  14. namespace igl
  15. {
  16. // Ideally this is a super overloaded function that behaves just like
  17. // matlab's repmat
  18. // Replicate and tile a matrix
  19. //
  20. // Templates:
  21. // T should be a eigen matrix primitive type like int or double
  22. // Inputs:
  23. // A m by n input matrix
  24. // r number of row-direction copies
  25. // c number of col-direction copies
  26. // Outputs:
  27. // B r*m by c*n output matrix
  28. //
  29. template <typename DerivedA,typename DerivedB>
  30. IGL_INLINE void repmat(
  31. const Eigen::PlainObjectBase<DerivedA> & A,
  32. const int r,
  33. const int c,
  34. Eigen::PlainObjectBase<DerivedB> & B);
  35. template <typename T>
  36. IGL_INLINE void repmat(
  37. const Eigen::SparseMatrix<T> & A,
  38. const int r,
  39. const int c,
  40. Eigen::SparseMatrix<T> & B);
  41. }
  42. #ifdef IGL_HEADER_ONLY
  43. # include "repmat.cpp"
  44. #endif
  45. #endif