A single-cell count matrix in 10x MatrixMarket layout: rows are genes,
columns are cells, stored as coordinate triplets. Counts are held as f64
because scanpy normalizes after promoting the integer matrix to float.
Normalize each cell to target_sum (or the median of totals) then optionally
apply ln(1+x). Mirrors scanpy: a zero-count cell’s scaling factor collapses
to 1, leaving its (empty) row untouched, and the sparsity pattern is exact
because log1p(0) = 0. A NaN count flows through untouched — its cell’s
scale is NaN (never mistaken for the zero case, since NaN != 0), so the
affected values normalize to NaN just as scanpy propagates them.
Write the matrix back in genes×cells MatrixMarket real coordinate layout,
preserving the input entry order. A big buffer plus ryu float formatting
keeps the matrix-sized write I/O-bound rather than format-bound.