#include "repdiag.h" #ifndef IGL_NO_OPENGL // Bug in unsupported/Eigen/SparseExtra needs iostream first #include #include template IGL_INLINE void igl::repdiag( const Eigen::SparseMatrix& A, const int d, Eigen::SparseMatrix& B) { int m = A.rows(); int n = A.cols(); // Should be able to *easily* do this in coherent order without // dynamicsparsematrix Eigen::DynamicSparseMatrix dyn_B(m*d,n*d); // Reserve enough space for new non zeros dyn_B.reserve(d*A.nonZeros()); // loop over reps for(int i=0;i::InnerIterator it(A,k); it; ++it) { dyn_B.coeffRef(i*m+it.row(),i*n+it.col()) += it.value(); } } } B = Eigen::SparseMatrix(dyn_B); } template IGL_INLINE void igl::repdiag( const Eigen::Matrix & A, const int d, Eigen::Matrix & B) { int m = A.rows(); int n = A.cols(); B.resize(m*d,n*d); B.array() *= 0; for(int i = 0;i IGL_INLINE Mat igl::repdiag(const Mat & A, const int d) { Mat B; repdiag(A,d,B); return B; } #ifndef IGL_HEADER_ONLY // Explicit template specialization // generated by autoexplicit.sh template void igl::repdiag(Eigen::SparseMatrix const&, int, Eigen::SparseMatrix&); // generated by autoexplicit.sh template Eigen::SparseMatrix igl::repdiag >(Eigen::SparseMatrix const&, int); #endif #endif