accumarray.cpp 784 B

12345678910111213141516171819202122
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 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 <test_common.h>
  9. #include <igl/accumarray.h>
  10. TEST_CASE("accumarray: matlab_help", "[igl]")
  11. {
  12. const Eigen::VectorXd V =
  13. (Eigen::VectorXd(5) << 101,102,103,104,105).finished();
  14. const Eigen::VectorXi S =
  15. (Eigen::VectorXi(5) << 0,2,3,2,3).finished();
  16. Eigen::VectorXd A;
  17. igl::accumarray(S,V,A);
  18. const Eigen::VectorXd Agt =
  19. (Eigen::VectorXd(4) << 101,0,206,208).finished();
  20. test_common::assert_eq(A,Agt);
  21. }