directly change the background value of a SparseArray?
You can change the background using replacement; here making the background "x"
:
s = SparseArray[{1, 10} -> 1, {1, 10}, a]
s /. (sa : SparseArray)[a_, b_, background_, d_] :> sa[a, b, "x", d]
s = SparseArray[{1, 10} -> 1, {1, 10}, a];
s2 = SparseArray[s["NonzeroPositions"] -> s["NonzeroValues"], Dimensions[s], b];
A slightly slower way using ArrayRules
:
s3 = SparseArray[Most@ArrayRules[s], Dimensions[s], b];
I haven't tested these on later versions.