A generalization of the löwdin orthogonalization