// // Created by cflin on 4/20/23. // #ifndef TOP3D_TENSORWRAPPER_H #define TOP3D_TENSORWRAPPER_H #include namespace top { template class TensorWrapper : public Eigen::Tensor { public: using Base = Eigen::Tensor; using Eigen::Tensor::Tensor; template Scalar &operator()(Base::Index firstIndex,Base::Index secondIndex, IndexTypes... otherIndices) { return Base::operator()(Eigen::array{{firstIndex, secondIndex, otherIndices...}}); } const Eigen::Matrix operator()(const Eigen::MatrixXi &indices)const { Eigen::Matrix result(indices.rows()); for (int i = 0; i < indices.rows(); ++i) { result(i) = Base::operator()(indices(i, 0), indices(i, 1), indices(i, 2)); } return result; } }; } // top #endif //TOP3D_TENSORWRAPPER_H