// // Created by cflin on 4/20/23. // #ifndef TOP3D_TENSORWRAPPER_H #define TOP3D_TENSORWRAPPER_H #include namespace da::sha { namespace top { template class TensorWrapper : public Eigen::Tensor { public: using Base = Eigen::Tensor; using Eigen::Tensor::Tensor; template Scalar & operator()(typename Base::Index firstIndex, typename Base::Index secondIndex, IndexTypes... otherIndices) { return Base::operator()( Eigen::array{{firstIndex, secondIndex, otherIndices...}}); } template const Scalar &operator()(typename Base::Index firstIndex, typename Base::Index secondIndex, IndexTypes... otherIndices) const { 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 } // da::sha #endif //TOP3D_TENSORWRAPPER_H