@@ -282,6 +282,7 @@ template <class T> class TableMixedStrategyProfileRep : public MixedStrategyProf
282282 std::unique_ptr<MixedStrategyProfileRep<T>> Copy () const override ;
283283 T GetPayoff (int pl) const override ;
284284 T GetPayoffDeriv (int pl, const GameStrategy &) const override ;
285+ bool GetPayoffDerivs (int pl, Vector<T> &p_derivs) const override ;
285286 T GetPayoffDeriv (int pl, const GameStrategy &, const GameStrategy &) const override ;
286287};
287288
@@ -322,6 +323,26 @@ T TableMixedStrategyProfileRep<T>::GetPayoffDeriv(int pl, const GameStrategy &st
322323 return value;
323324}
324325
326+ template <class T >
327+ bool TableMixedStrategyProfileRep<T>::GetPayoffDerivs(int pl, Vector<T> &p_derivs) const
328+ {
329+ const auto game = this ->GetSupport ().GetGame ();
330+ auto &g = dynamic_cast <GameTableRep &>(*game);
331+ const auto player = game->GetPlayer (pl);
332+ p_derivs = T{0 };
333+ auto segment = this ->m_offsets .segment (pl);
334+ for (auto [index, prob] : ProductDistribution<T>(this ->m_probs , this ->m_offsets , pl)) {
335+ auto deriv_it = p_derivs.begin ();
336+ for (const auto base_index : segment) {
337+ if (const auto outcome = g.m_results [base_index + index]) {
338+ *deriv_it += prob * outcome->template GetPayoff <T>(player);
339+ ++deriv_it;
340+ }
341+ }
342+ }
343+ return true ;
344+ }
345+
325346template <class T >
326347T TableMixedStrategyProfileRep<T>::GetPayoffDeriv(int pl, const GameStrategy &strategy1,
327348 const GameStrategy &strategy2) const
0 commit comments