  The completely positive maps, a generalization of the nonnegative matrices,
are a well-studied class of maps from $n\times n$ matrices to $m\times m$
matrices. The existence of the operator analogues of doubly stochastic scalings
of matrices is equivalent to a multitude of problems in computer science and
mathematics, such rational identity testing in non-commuting variables,
noncommutative rank of symbolic matrices, and a basic problem in invariant
theory (Garg, Gurvits, Oliveira and Wigderson, FOCS, 2016).
  We study operator scaling with specified marginals, which is the operator
analogue of scaling matrices to specified row and column sums. We characterize
the operators which can be scaled to given marginals, much in the spirit of the
Gurvits' algorithmic characterization of the operators that can be scaled to
doubly stochastic (Gurvits, Journal of Computer and System Sciences, 2004). Our
algorithm produces approximate scalings in time poly(n,m) whenever scalings
exist. A central ingredient in our analysis is a reduction from the specified
marginals setting to the doubly stochastic setting.
  Operator scaling with specified marginals arises in diverse areas of study
such as the Brascamp-Lieb inequalities, communication complexity, eigenvalues
of sums of Hermitian matrices, and quantum information theory. Some of the
known theorems in these areas, several of which had no effective proof, are
straightforward consequences of our characterization theorem. For instance, we
obtain a simple algorithm to find, when they exist, a tuple of Hermitian
matrices with given spectra whose sum has a given spectrum. We also prove new
theorems such as a generalization of Forster's theorem (Forster, Journal of
Computer and System Sciences, 2002) concerning radial isotropic position.
