[mlpack-git] [mlpack] Implementation of primal-dual interior point SDP solver (#391)

Ryan Curtin notifications at github.com
Mon Jan 26 10:59:22 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);
> +}

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.)

```
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().
}
```

`IsMatType<T>` can be defined to be some struct where `result` is true if `T = mat` or `T = sp_mat`.  Take a look at Armadillo's `traits.hpp` file.  What do you think?

---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/391/files#r23540093
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20150126/c7e643e8/attachment.html>


More information about the mlpack-git mailing list