dot_row.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Daniele Panozzo <[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_DOT_ROW_H
  9. #define IGL_DOT_ROW_H
  10. #include "igl/igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Compute the dot product between each row of A and B
  15. ///
  16. /// @tparam DerivedV derived from vertex positions matrix type: i.e. MatrixXd
  17. /// @param[in] A eigen matrix r by c
  18. /// @param[in] B eigen matrix r by c
  19. /// @param[out] d a column vector with r entries that contains the dot product of each corresponding row of A and B
  20. ///
  21. /// \note Unfortunately, Eigen does not support `A.rowwise().dot(B.rowwise())`
  22. /// so this function is a wrapper around the less obvious and less convenient
  23. /// `(A.array() * B.array()).rowwise().sum()`.
  24. template <typename DerivedV>
  25. IGL_INLINE DerivedV dot_row(
  26. const Eigen::PlainObjectBase<DerivedV>& A,
  27. const Eigen::PlainObjectBase<DerivedV>& B);
  28. }
  29. #ifndef IGL_STATIC_LIBRARY
  30. # include "dot_row.cpp"
  31. #endif
  32. #endif