<p>In <a href="https://github.com/mlpack/mlpack/pull/694#discussion_r68357573">src/mlpack/core/data/imputation_methods/mean_imputation.hpp</a>:</p>
<pre style='color:#555'>&gt; +    double sum;
&gt; +    size_t elems = 0; // excluding nan or missing target
&gt; +
&gt; +    using PairType = std::pair&lt;size_t, size_t&gt;;
&gt; +    // dimensions and indexes are saved as pairs inside this vector.
&gt; +    std::vector&lt;PairType&gt; targets;
&gt; +
&gt; +    // calculate number of elements and sum of them excluding mapped value or
&gt; +    // nan. while doing that, remember where mappedValue or NaN exists.
&gt; +    if (transpose)
&gt; +    {
&gt; +      for (size_t i = 0; i &lt; input.n_rows; ++i)
&gt; +      {
&gt; +        if (input(i, dimension) == mappedValue)
&gt; +        {
&gt; +          targets.push_back(std::make_pair(i, dimension));
</pre>
<p>Another approach(maybe you already know)--targets.emplace_back(i, dimension);</p>

<p>Different with push_back is emplace_back will construct the value directly,it may(or may not) provide better performance. Pick the one you like :)</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/pull/694/files/da4e40981c40e171858f41de4e85e08af2c7e48d..d8618ec909005b0453f0a3803ac1e6cc5e588f1f#r68357573">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFGQv2TUzk2ZiC90wRICx-PCM92D0ks5qO3YDgaJpZM4I07W-">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFBd1KMtrbyM1DPhl7rr3HgcJhLz7ks5qO3YDgaJpZM4I07W-.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/694/files/da4e40981c40e171858f41de4e85e08af2c7e48d..d8618ec909005b0453f0a3803ac1e6cc5e588f1f#r68357573"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>