|
@@ -11,12 +11,12 @@
|
|
|
#include <vector>
|
|
|
#include <unsupported/Eigen/SparseExtra>
|
|
|
|
|
|
-template <typename T>
|
|
|
+template <typename TX, typename TY>
|
|
|
IGL_INLINE void igl::slice(
|
|
|
- const Eigen::SparseMatrix<T>& X,
|
|
|
+ const Eigen::SparseMatrix<TX>& X,
|
|
|
const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
|
|
|
const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
|
|
|
- Eigen::SparseMatrix<T>& Y)
|
|
|
+ Eigen::SparseMatrix<TY>& Y)
|
|
|
{
|
|
|
#if 1
|
|
|
int xm = X.rows();
|
|
@@ -51,7 +51,7 @@ IGL_INLINE void igl::slice(
|
|
|
CI[C(i)].push_back(i);
|
|
|
}
|
|
|
// Resize output
|
|
|
- Eigen::DynamicSparseMatrix<T, Eigen::RowMajor> dyn_Y(ym,yn);
|
|
|
+ Eigen::DynamicSparseMatrix<TY, Eigen::RowMajor> dyn_Y(ym,yn);
|
|
|
// Take a guess at the number of nonzeros (this assumes uniform distribution
|
|
|
// not banded or heavily diagonal)
|
|
|
dyn_Y.reserve((X.nonZeros()/(X.rows()*X.cols())) * (ym*yn));
|
|
@@ -59,7 +59,7 @@ IGL_INLINE void igl::slice(
|
|
|
for(int k=0; k<X.outerSize(); ++k)
|
|
|
{
|
|
|
// Iterate over inside
|
|
|
- for(typename Eigen::SparseMatrix<T>::InnerIterator it (X,k); it; ++it)
|
|
|
+ for(typename Eigen::SparseMatrix<TX>::InnerIterator it (X,k); it; ++it)
|
|
|
{
|
|
|
std::vector<int>::iterator rit, cit;
|
|
|
for(rit = RI[it.row()].begin();rit != RI[it.row()].end(); rit++)
|
|
@@ -71,7 +71,7 @@ IGL_INLINE void igl::slice(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Y = Eigen::SparseMatrix<T>(dyn_Y);
|
|
|
+ Y = Eigen::SparseMatrix<TY>(dyn_Y);
|
|
|
#else
|
|
|
|
|
|
// Alec: This is _not_ valid for arbitrary R,C since they don't necessary
|
|
@@ -134,12 +134,12 @@ IGL_INLINE void igl::slice(
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-template <typename Mat>
|
|
|
+template <typename MatX, typename MatY>
|
|
|
IGL_INLINE void igl::slice(
|
|
|
- const Mat& X,
|
|
|
+ const MatX& X,
|
|
|
const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
|
|
|
const int dim,
|
|
|
- Mat& Y)
|
|
|
+ MatY& Y)
|
|
|
{
|
|
|
Eigen::VectorXi C;
|
|
|
switch(dim)
|
|
@@ -168,12 +168,12 @@ IGL_INLINE void igl::slice(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-template <typename DerivedX>
|
|
|
+template <typename DerivedX, typename DerivedY>
|
|
|
IGL_INLINE void igl::slice(
|
|
|
const Eigen::PlainObjectBase<DerivedX> & X,
|
|
|
const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
|
|
|
const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
|
|
|
- Eigen::PlainObjectBase<DerivedX> & Y)
|
|
|
+ Eigen::PlainObjectBase<DerivedY> & Y)
|
|
|
{
|
|
|
#ifndef NDEBUG
|
|
|
int xm = X.rows();
|
|
@@ -207,11 +207,11 @@ IGL_INLINE void igl::slice(
|
|
|
}
|
|
|
|
|
|
|
|
|
-template <typename DerivedX>
|
|
|
+template <typename DerivedX, typename DerivedY>
|
|
|
IGL_INLINE void igl::slice(
|
|
|
const Eigen::PlainObjectBase<DerivedX> & X,
|
|
|
const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
|
|
|
- Eigen::PlainObjectBase<DerivedX> & Y)
|
|
|
+ Eigen::PlainObjectBase<DerivedY> & Y)
|
|
|
{
|
|
|
// phony column indices
|
|
|
Eigen::Matrix<int,Eigen::Dynamic,1> C;
|
|
@@ -243,24 +243,8 @@ IGL_INLINE Eigen::PlainObjectBase<DerivedX> igl::slice(
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
|
// Explicit template specialization
|
|
|
-// generated by autoexplicit.sh
|
|
|
-template void igl::slice<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
|
|
-// generated by autoexplicit.sh
|
|
|
-template void igl::slice<Eigen::Matrix<float, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> >&);
|
|
|
-// generated by autoexplicit.sh
|
|
|
-template void igl::slice<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
|
|
-// generated by autoexplicit.sh
|
|
|
-template void igl::slice<Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);
|
|
|
-// generated by autoexplicit.sh
|
|
|
-template void igl::slice<double>(Eigen::SparseMatrix<double, 0, int> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<double, 0, int>&);
|
|
|
-template void igl::slice<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
|
|
-template void igl::slice<Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
|
|
-template void igl::slice<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
|
|
|
-template void igl::slice<Eigen::SparseMatrix<double, 0, int> >(Eigen::SparseMatrix<double, 0, int> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int, Eigen::SparseMatrix<double, 0, int>&);
|
|
|
template Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > igl::slice<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int);
|
|
|
template Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > igl::slice<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int);
|
|
|
-template void igl::slice<std::complex<double> >(Eigen::SparseMatrix<std::complex<double>, 0, int> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<std::complex<double>, 0, int>&);
|
|
|
-template void igl::slice<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::Matrix<double, -1, 3, 0, -1, 3> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int, Eigen::Matrix<double, -1, 3, 0, -1, 3>&);
|
|
|
template Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > igl::slice<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&);
|
|
|
template Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > igl::slice<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int);
|
|
|
template Eigen::PlainObjectBase<Eigen::Matrix<double, 1, -1, 1, 1, -1> > igl::slice<Eigen::Matrix<double, 1, -1, 1, 1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, -1, 1, 1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, int);
|