<p>Thanks for your detailed guidance.<br>
I agree that my optimization for kernel which uses squared distance is unnecessary. <br>
A smart compiler should do it.<br>
But I have a question about the general formulation.<br>
I think it should be<br>
∇f(x) = ∑ K'(∥ x - x_i ∥) d/dx(∥ x - x_i ∥).<br>
= ∑ K'(∥ x - x_i ∥) d/dx((∥ x - x_i ∥^2)^1/2)<br>
= ∑ K'(∥ x - x_i ∥) (1/2 (∥ x - x_i ∥^2)^(-1/2)) 2 * (x - x_i)<br>
= ∑ K'(∥ x - x_i ∥) (1 / (∥ x - x_i ∥)) (x - x_i)<br>
My implementation for general case accords with this formulation. <br>
I am going to remove the unnecessary kernel traits UsesSquaredDistance.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/388#issuecomment-76111686">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFKl78t6yu7sV8ao3bMYpGvknm2D2ks5nvn2MgaJpZM4DTzb1.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/388#issuecomment-76111686"></link>
    <meta itemprop="name" content="View Pull Request"></meta>
  </div>
  <meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>