Generalized Wielandt and Cauchy-Schwarz inequalities