File tree 1 file changed +4
-3
lines changed
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -2664,8 +2664,8 @@ namespace detail {
2664
2664
XTL_REQUIRES (is_reducer_options<EVS>)>
2665
2665
inline auto nanvar(E&& e, EVS es = EVS())
2666
2666
{
2667
- decltype ( auto ) sc = detail::shared_forward<E >(e);
2668
- return nanmean<T>(square (sc - nanmean<T>(sc )), es);
2667
+ auto cached_mean = nanmean<T >(e, es)( );
2668
+ return nanmean<T>(square (std::forward<E>(e) - std::move (cached_mean )), es);
2669
2669
}
2670
2670
2671
2671
template <class T = void , class E , class EVS = DEFAULT_STRATEGY_REDUCERS,
@@ -2702,7 +2702,8 @@ namespace detail {
2702
2702
// note: forcing copy of first axes argument -- is there a better solution?
2703
2703
auto axes_copy = axes;
2704
2704
using result_type = typename std::conditional_t <std::is_same<T, void >::value, double , T>;
2705
- auto inner_mean = nanmean<result_type>(sc, std::move (axes_copy));
2705
+ // always eval to prevent repeated evaluations in the next calls
2706
+ auto inner_mean = eval (nanmean<result_type>(sc, std::move (axes_copy), evaluation_strategy::immediate));
2706
2707
2707
2708
// fake keep_dims = 1
2708
2709
auto keep_dim_shape = e.shape ();
You can’t perform that action at this time.
0 commit comments