concat.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #include "concat.h"
  9. #include <cstdio>
  10. template <typename T>
  11. IGL_INLINE void igl::concat(
  12. const T A,
  13. const T B,
  14. const bool horiz,
  15. T& O)
  16. {
  17. if (horiz)
  18. {
  19. // O = [A,B]
  20. assert(A.rows() == B.rows());
  21. O = T(A.rows(),A.cols()+B.cols());
  22. O << A,B;
  23. }
  24. else
  25. {
  26. // O = [A;B]
  27. assert(A.cols() == B.cols());
  28. O = T(A.rows()+B.rows(),A.cols());
  29. O << A,B;
  30. }
  31. }
  32. template <typename T>
  33. IGL_INLINE T igl::concat(
  34. const T A,
  35. const T B,
  36. bool horiz
  37. )
  38. {
  39. T O = T(1,1);
  40. concat(A,B,horiz,O);
  41. return O;
  42. }
  43. #ifndef IGL_HEADER_ONLY
  44. // Explicit template specialization
  45. #endif