repmat.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. // At least for Dense matrices this is replaced by `replicate` e.g., dst = src.replicate(n,m);
  17. // http://forum.kde.org/viewtopic.php?f=74&t=90876#p173517
  18. // Ideally this is a super overloaded function that behaves just like
  19. // matlab's repmat
  20. // Replicate and tile a matrix
  21. //
  22. // Templates:
  23. // T should be a eigen matrix primitive type like int or double
  24. // Inputs:
  25. // A m by n input matrix
  26. // r number of row-direction copies
  27. // c number of col-direction copies
  28. // Outputs:
  29. // B r*m by c*n output matrix
  30. //
  31. template <typename DerivedA,typename DerivedB>
  32. IGL_INLINE void repmat(
  33. const Eigen::PlainObjectBase<DerivedA> & A,
  34. const int r,
  35. const int c,
  36. Eigen::PlainObjectBase<DerivedB> & B);
  37. template <typename T>
  38. IGL_INLINE void repmat(
  39. const Eigen::SparseMatrix<T> & A,
  40. const int r,
  41. const int c,
  42. Eigen::SparseMatrix<T> & B);
  43. }
  44. #ifndef IGL_STATIC_LIBRARY
  45. # include "repmat.cpp"
  46. #endif
  47. #endif