|
@@ -1,11 +1,12 @@
|
|
// This file is part of libigl, a simple c++ geometry processing library.
|
|
// This file is part of libigl, a simple c++ geometry processing library.
|
|
//
|
|
//
|
|
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
|
|
|
|
|
+// Copyright (C) 2016 Alec Jacobson <alecjacobson@gmail.com>
|
|
//
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
#include "sum.h"
|
|
#include "sum.h"
|
|
|
|
+#include "redux.h"
|
|
|
|
|
|
template <typename T>
|
|
template <typename T>
|
|
IGL_INLINE void igl::sum(
|
|
IGL_INLINE void igl::sum(
|
|
@@ -13,8 +14,7 @@ IGL_INLINE void igl::sum(
|
|
const int dim,
|
|
const int dim,
|
|
Eigen::SparseVector<T>& S)
|
|
Eigen::SparseVector<T>& S)
|
|
{
|
|
{
|
|
- // dim must be 2 or 1
|
|
|
|
- assert(dim == 1 || dim == 2);
|
|
|
|
|
|
+ assert((dim == 1 || dim == 2) && "dim must be 2 or 1");
|
|
// Get size of input
|
|
// Get size of input
|
|
int m = X.rows();
|
|
int m = X.rows();
|
|
int n = X.cols();
|
|
int n = X.cols();
|
|
@@ -42,7 +42,16 @@ IGL_INLINE void igl::sum(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
|
|
|
|
+template <typename AType, typename DerivedB>
|
|
|
|
+IGL_INLINE void igl::sum(
|
|
|
|
+ const Eigen::SparseMatrix<AType> & A,
|
|
|
|
+ const int dim,
|
|
|
|
+ Eigen::PlainObjectBase<DerivedB>& B)
|
|
|
|
+{
|
|
|
|
+ typedef typename DerivedB::Scalar Scalar;
|
|
|
|
+ igl::redux(A,dim,[](Scalar a, Scalar b){ return a+b;},B);
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
#ifdef IGL_STATIC_LIBRARY
|