[mlpack-git] [mlpack] add a wrapper for the matrix completion SDP (#374)

Ryan Curtin notifications at github.com
Fri Jan 9 16:29:45 EST 2015


> +                                     const size_t n,
> +                                     const size_t p)
> +{
> +  const size_t mpn = m + n;
> +  float r = 0.5 + sqrt(0.25 + 2 * p);
> +  if (ceil(r) > mpn)
> +    r = mpn; // An upper bound on the dimension.
> +  return ceil(r);
> +}
> +
> +arma::mat MatrixCompletion::CreateInitialPoint(const size_t m,
> +                                               const size_t n,
> +                                               const size_t r)
> +{
> +  const size_t mpn = m + n;
> +  return arma::randu<arma::mat>(mpn, r);

I think it'd be shorter (in terms of code length) and faster (in terms of code execution time) to just inline this call to `randu` in place of the call to `CreateInitialPoint`.  One of the things that some other classes do is templatize the initial point strategy (`AMF` does this, for instance); that might be a good solution for the flexibility I'm guessing you're shooting for here, and if the templatized initial point strategy is inlined, then it should easily avoid any unnecessary copies.  (I'm not sure whether or not gcc plus optimizations will strip out the copy of the returned matrix here, but I don't think that it will.)

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


More information about the mlpack-git mailing list