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 promotes the integer matrix to float before scaling.
Per-gene mean and standard deviation over all cells. The variance uses the
ddof=1 (sample) convention scanpy enforces: var = (E[x²] - E[x]²)·n/(n-1).
A zero-variance gene’s std collapses to 1 so its centered row stays at 0.
Z-score the matrix per gene and densify into a genes × cells buffer in
column-major (cell-major) order: every gene of cell 0, then cell 1, … This
is the MatrixMarket array layout the writer emits. An implicit zero count
becomes -mean/std, which is why scaling densifies the matrix.
Write the dense scaled matrix in MatrixMarket array real general layout:
banner, n_genes n_cells, then one value per line in column-major order
(matching scipy’s dense MatrixMarket and dense’s memory layout).