<p>In <a href="https://github.com/mlpack/mlpack/pull/391#discussion_r23553960">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>Hm, right, it actually has to be more complex than this then...</p>
<pre><code>template<typename FunctionType>
inline double AugLagrangianFunction<FunctionType>::Evaluate(
const arma::mat& coordinates,
const boost::enable_if<IsLRSDPFunctionType<FunctionType>::result>::result* = 0)
{
// no more need for EvaluateImpl()
}
</code></pre>
<p>and then</p>
<pre><code>template<typename FunctionType>
struct IsLRSDPFunctionType
{
static const bool result = false;
};
template<>
struct IsLRSDPFunctionType<LRSDP<SDP<mat>>>
{
static const bool result = true;
};
template<>
struct IsLRSDPFunctionType<LRSDP<SDP<sp_mat>>>
{
static const bool result = true;
};
</code></pre>
<p>but at this point the metaprogramming is getting insane enough that maybe your solution is cleaner and easier to read... :) If there were many more types of <code>SDP<...></code> I'd suggest it more seriously, but that's not the case...</p>
<p>We wouldn't need to change the type signature on <code>AugLagrangianFunction</code>; we'd need to declare the function above as an extra member. Anyway, reconsidering the extra complexity of what I just suggested, I'm now against my own idea. Well, it was fun to think about, at least...</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#r23553960">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFFf6mKEboPsAgYB4vEy5yqsGKP5bks5nloQkgaJpZM4DVljE.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#r23553960"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>