Eigen::MatrixXd evaluate_terms(const Eigen::MatrixXd& locations) { return (locations.transposed().array().log().matrix()*exponents).array().exp(); //each row is [1 x x^2 ....] }