Let's say I have a "small" `SparseArray`, in the example $2\times2$ MatrixForm[ m2 = SparseArray[{{i_,i_}->1,{1,2}->a},2] ] [![enter image description here][1]][1] I want to expand it to a "Large", for example, $4\times4$ `SparseArray` without rewriting it. let's say m4test = SparseArray[{{i_,i_}->1,{1,2}->a, {3,4}->b },4] [![enter image description here][2]][2] **How do I efficiently (not expanding and contracting) do I transform `m2` into `m4`?** ## Due diligence I didn't find a similar question on the site, and ChatGPT doesn't seem to understand how to program for general cases. I have tried this, extendSparseArray[sa_, rules_] := SparseArray[ Join[rules, ArrayRules[sa]] , Max[Join[Dimensions[sa],Flatten@rules[[All,1]] ] ] ] MatrixForm[ extendSparseArray[m2, {{3,4}->b}] ] [![enter image description here][3]][3] Which does part of the job, but misses the general rule `{i_,i_}->1` and also seems cumbersome. I'm sure I'm missing something more fundamental. **What are simple and idiomatic ways to achieve this and which one performs the best?** The examples are meant to be minimal to facilitate the discussion, I will use this with larger and more complex `SparseArray` expressions. [1]: https://i.sstatic.net/t4zPT5yf.png [2]: https://i.sstatic.net/Jp4PJbJ2.png [3]: https://i.sstatic.net/Jp3ajUt2.png