<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'>&gt; +  SDP&lt;arma::mat&gt; sdp(g.NumVertices(), g.NumEdges() + 1, 0);
&gt; +  sdp.C().ones();
&gt; +  sdp.C() *= -1.;
&gt; +  sdp.SparseA()[0].eye(g.NumVertices(), g.NumVertices());
&gt; +  for (size_t i = 0; i &lt; g.NumEdges(); i++)
&gt; +  {
&gt; +    sdp.SparseA()[i + 1].zeros(g.NumVertices(), g.NumVertices());
&gt; +    sdp.SparseA()[i + 1](g.Edges()(0, i), g.Edges()(1, i)) = 1.;
&gt; +    sdp.SparseA()[i + 1](g.Edges()(1, i), g.Edges()(0, i)) = 1.;
&gt; +  }
&gt; +  sdp.SparseB().zeros();
&gt; +  sdp.SparseB()[0] = 1.;
&gt; +  return sdp;
&gt; +}
&gt; +
&gt; +// 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;">&mdash;<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>