  It is well-known for transform coding of multivariate Gaussian sources, that
the Karhunen-Lo\`eve transform (KLT) minimizes the mean square error
distortion. However, finding the optimal transform for general non-Gaussian
sources has been an open problem for decades, despite several important
advances that provide some partial answers regarding KLT optimality. In this
paper, we present a necessary and sufficient condition for optimality of a
transform when high resolution, variable rate quantizers are employed. We hence
present not only a complete characterization of when KLT is optimal, but also a
determining condition for optimality of a general (non-KLT) transform. This
necessary and sufficient condition is shown to have direct connections to the
well studied source separation problem. This observation can impact source
separation itself, as illustrated with a new optimality result. We combine the
transform optimality condition with algorithmic tools from source separation,
to derive a practical numerical method to search for the optimal transform in
source coding. Then, we focus on multiterminal settings, for which {\it
conditional} KLT was shown to possess certain optimality properties for
Gaussian sources. We derive the optimal orthogonal transform for the setting
where side information is only available to the decoder, along with new
specialized results specific to the conditions for optimality of conditional
KLT. Finally, we consider distributed source coding where two correlated
sources are to be transform coded separately but decoded jointly. We derive the
necessary and sufficient condition of optimality of the orthogonal transforms.
We specialize to find the optimal orthogonal transforms, in this setting, for
specific source densities, including jointly Gaussian sources.
