| class circulant_functor { |
| circulant_functor(const ArgType& arg) : m_vec(arg) {} |
| const typename ArgType::Scalar& operator() (Index row, Index col) const { |
| if (index < 0) index += m_vec.size(); |
| struct circulant_helper { |
| typedef Matrix<typename ArgType::Scalar, |
| ArgType::SizeAtCompileTime, |
| ArgType::SizeAtCompileTime, |
| ArgType::MaxSizeAtCompileTime, |
| ArgType::MaxSizeAtCompileTime> MatrixType; |
| CwiseNullaryOp<circulant_functor<ArgType>, typename circulant_helper<ArgType>::MatrixType> |
| makeCirculant(const Eigen::MatrixBase<ArgType>& arg) |
| typedef typename circulant_helper<ArgType>::MatrixType MatrixType; |
| return MatrixType::NullaryExpr(arg.size(), arg.size(), circulant_functor<ArgType>(arg.derived())); |
| mat = makeCirculant(vec); |
| std::cout << mat << std::endl; |