I have a very large matrix (tensor) in Mathematica with some zero and non-zero elements. I am interested in replacing the non-zero elements with some symbol or a 1 so that it is easier to view the entire object.
I would include my code but there is a lot of preamble so here is an analogue of what I would like to work on:
{{{{0, -a Sqrt[a^2 + c^2], -c Sqrt[a^2 + c^2]}, {-a Sqrt[a^2 + c^2],
0, 0}, {-c Sqrt[a^2 + c^2], 0, 0}}}, {{{0, 0,
0}, {0, -2 a^2, -2 a c}, {0, -2 a c, -2 c^2}}}, {{{0, 0, 0}, {0,
0, 0}, {0, 0, 0}}}}
and I would like to output something like:
{{{{0, 1, 1}, {1, 0, 0}, {1, 0, 0}}}, {{{0, 0, 0}, {0, 1, 1}, {0, 1,
1}}}, {{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}}}
SparseArray[array]["PatternArray"] // Normal
. $\endgroup$Verbatim[_] -> 1
if need be. :) $\endgroup$Map[Boole@*PossibleZeroQ, array, {4}]
$\endgroup$