Guest User

Untitled

a guest
Jul 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. spA = SparseArray[{{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}]
  2. withOutDiagonalELements =
  3. DeleteCases[ArrayRules[spA], {a_, a_} -> _];
  4. spAwd=
  5. SparseArray@Append[withOutDiagonalELements, {_, _} -> 0.0];
  6.  
  7. spA = SparseArray[{{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}];
  8.  
  9. zeros = 1 - IdentityMatrix[3, SparseArray];
  10.  
  11. spA*zeros // Grid
  12.  
  13. ReplacePart[spA, {i_, i_} :> 0]
  14.  
  15. Diagonal[ReplacePart[spA, {i_, i_} :> 0]] // Normal
  16.  
  17. ReplacePart[spA, {i_, i_} :> {a, b, c}[[i]]]
Add Comment
Please, Sign In to add comment