Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spA = SparseArray[{{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}]
- withOutDiagonalELements =
- DeleteCases[ArrayRules[spA], {a_, a_} -> _];
- spAwd=
- SparseArray@Append[withOutDiagonalELements, {_, _} -> 0.0];
- spA = SparseArray[{{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}];
- zeros = 1 - IdentityMatrix[3, SparseArray];
- spA*zeros // Grid
- ReplacePart[spA, {i_, i_} :> 0]
- Diagonal[ReplacePart[spA, {i_, i_} :> 0]] // Normal
- ReplacePart[spA, {i_, i_} :> {a, b, c}[[i]]]
Add Comment
Please, Sign In to add comment