[mlpack-git] [mlpack] Implementation of primal-dual interior point SDP solver (#391)
Ryan Curtin
notifications at github.com
Mon Jan 26 13:51:16 EST 2015
> @@ -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);
> +}
Hm, right, it actually has to be more complex than this then...
```
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()
}
```
and then
```
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;
};
```
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 `SDP<...>` I'd suggest it more seriously, but that's not the case...
We wouldn't need to change the type signature on `AugLagrangianFunction`; 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...
---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/391/files#r23553960
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20150126/ccdef644/attachment.html>
More information about the mlpack-git
mailing list