title: how to copy only upper triangular values into array from numpy.triu()?
body: <p>I have a square matrix A (could be any size) and I want to take the upper triangular part and place those values in an array without the values below the center diagonal (k=0).</p>
  
  <pre><code>A = array([[ 4,  0,  3],
             [ 2,  4, -2],
             [-2, -3,  7]])
  </code></pre>
  
  <p>using numpy.triu(A) gets me to</p>
  
  <pre><code>A = array([[ 4,  0,  3],
             [ 0,  4, -2],
             [ 0,  0,  7]])
  </code></pre>
  
  <p>but from here how would I copy only the upper triangular elements into a simply array? Such as:</p>
  
  <pre><code>[4, 0, 3, 4, -2, 7]
  </code></pre>
  
  <p>I was going to just iterate though and copy all non-zero elements, however zero's in the upper triangular are allowed.</p>