Orthogonal factors and decomposition of squares