Reconcile a non-negative matrix to prescribed row and column sums using the RAS (biproportional / iterative proportional fitting) algorithm: alternately rescale rows then columns until both margins are matched, preserving the matrix's structure (zero pattern and relative magnitudes). The row and column targets must have equal totals.
Works on dense and sparse (Matrix) inputs, staying in the input
representation so it is efficient for both small dense tables and
large sparse input-output systems. (The same core also balances
the bilateral trade matrices.) For matrices with negative entries
the signed GRAS variant is needed and is not implemented here.
