<p>In <a href="https://github.com/mlpack/mlpack/pull/391#discussion_r23540093">src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp</a>:</p>
<pre style='color:#555'>> @@ -189,5 +187,40 @@ void AugLagrangianFunction<LRSDPFunction>::Gradient(
> gradient = 2 * s * coordinates;
> }
>
> +// Template specializations for function and gradient evaluation.
> +// Note that C++ does not allow partial specialization of class members,
> +// so we have to go about this in a somewhat round-about way.
> +template <>
> +inline double AugLagrangianFunction<LRSDPFunction<SDP<arma::sp_mat>>>::Evaluate(
> + const arma::mat& coordinates) const
> +{
> + return EvaluateImpl(function, coordinates, lambda, sigma);
> +}
</pre>
<p>I'm thinking SFINAE may be a better approach here... (I haven't tested the code below. I think it will look something like this.)</p>
<pre><code>template<typename MatType>
inline double AugLagrangianFunction<LRSDPFunction<SDP<MatType>>>::Evaluate(
const arma::mat& coordinates,
const boost::enable_if<IsMatType<MatType>::result>::result* = 0)
{
// no more need for EvaluateImpl().
}
</code></pre>
<p><code>IsMatType<T></code> can be defined to be some struct where <code>result</code> is true if <code>T = mat</code> or <code>T = sp_mat</code>. Take a look at Armadillo's <code>traits.hpp</code> file. What do you think?</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/391/files#r23540093">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFByv00tNWtNvBe35r7MVDKVpudMKks5nllvagaJpZM4DVljE.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/391/files#r23540093"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>