Browse Source

note about sparse sum

Former-commit-id: 94c43a3564420f1390ca8f8bfd3fc872017ec242
Alec Jacobson 8 years ago
parent
commit
ba342c28b5
1 changed files with 12 additions and 1 deletions
  1. 12 1
      matlab-to-eigen.html

+ 12 - 1
matlab-to-eigen.html

@@ -67,7 +67,12 @@
         <td><pre><code>Acol_sum = sum(A,1)<br>Arow_sum = sum(A,2)<br>Adim_sum = sum(Asparse,dim)</code></pre></td>
         <td><pre><code>Acol_sum = A.colwise().sum()<br>Arow_sum = A.rowwise().sum()<br>igl::sum(Asparse,dim,Adim_sum)</code></pre></td>
         <td>Currently the igl version only supports sparse matrix input (and
-            dim must be 1 or 2)</td>
+            dim must be 1 or 2).<br>
+            For sparse matrices, one could use
+            <code>A*Matrix&lt;Atype,Dynamic,1&gt;::Ones(A.cols(),1);</code> but this
+            will <b>not</b> work as expected for
+            <code>SparseMatrix&lt;bool&gt;</code>.
+        </td>
       </tr>
 
       <tr class=d1>
@@ -285,6 +290,12 @@ bool a = A.array().any();
         <td>Remove the diagonal from a sparse matrix.</td>
       </tr>
 
+      <tr class=d1>
+        <td><pre><code>A = A - diag(diag(A));</code></pre></td>
+        <td><pre><code>A.prune([](const int r, const int c, const Scalar)-&gt;bool{return r!=c;});</code></pre></td>
+        <td>Remove the diagonal from a sparse matrix.</td>
+      </tr>
+
       <!-- Insert rows for each command pair -->
 
       <!-- Leave this here for copy and pasting