repmat.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_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. /// Replicate and tile a matrix
  17. ///
  18. /// @tparam T should be a eigen matrix primitive type like int or double
  19. /// @param[in] A m by n input matrix
  20. /// @param[in] r number of row-direction copies
  21. /// @param[in] c number of col-direction copies
  22. /// @param[out] B r*m by c*n output matrix
  23. ///
  24. /// \note At least for Dense matrices this is replaced by `replicate` e.g., dst = src.replicate(n,m);
  25. /// http://forum.kde.org/viewtopic.php?f=74&t=90876#p173517
  26. ///
  27. template <typename DerivedA,typename DerivedB>
  28. IGL_INLINE void repmat(
  29. const Eigen::MatrixBase<DerivedA> & A,
  30. const int r,
  31. const int c,
  32. Eigen::PlainObjectBase<DerivedB> & B);
  33. /// \overload
  34. template <typename T, int majorType>
  35. IGL_INLINE void repmat(
  36. const Eigen::SparseMatrix<T, majorType> & A,
  37. const int r,
  38. const int c,
  39. Eigen::SparseMatrix<T, majorType> & B);
  40. }
  41. #ifndef IGL_STATIC_LIBRARY
  42. # include "repmat.cpp"
  43. #endif
  44. #endif