<p>In <a href="https://github.com/mlpack/mlpack/pull/391#discussion_r23540867">src/mlpack/tests/sdp_primal_dual_test.cpp</a>:</p>
<pre style='color:#555'>> + SDP<arma::mat> sdp(g.NumVertices(), g.NumEdges() + 1, 0);
> + sdp.C().ones();
> + sdp.C() *= -1.;
> + sdp.SparseA()[0].eye(g.NumVertices(), g.NumVertices());
> + for (size_t i = 0; i < g.NumEdges(); i++)
> + {
> + sdp.SparseA()[i + 1].zeros(g.NumVertices(), g.NumVertices());
> + sdp.SparseA()[i + 1](g.Edges()(0, i), g.Edges()(1, i)) = 1.;
> + sdp.SparseA()[i + 1](g.Edges()(1, i), g.Edges()(0, i)) = 1.;
> + }
> + sdp.SparseB().zeros();
> + sdp.SparseB()[0] = 1.;
> + return sdp;
> +}
> +
> +// TODO(stephentu): does arma have a builtin way to do this?
</pre>
<p>Try <code>diagmat()</code>. I think that's what you're looking for.</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#r23540867">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFFV4SzvEY2e2GonCpq8RVOYPPFDsks5nll4TgaJpZM4DVljE.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#r23540867"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>