protected void randomInitialization(double[] out,Random rnd){
  double l2=0.;
  while (!(l2 > 0)) {
    for (int d=0; d < out.length; d++) {
      final double val=rnd.nextDouble();
      out[d]=val;
      l2+=val * val;
    }
  }
  if (!(l2 > 0)) {
    randomInitialization(out,rnd);
    return;
  }
  final double s=1. / Math.sqrt(l2);
  for (int d=0; d < out.length; d++) {
    out[d]*=s;
  }
}

protected void randomInitialization ( double [ ] out , Random rnd ) { double l2 = 0. ; while ( ! ( l2 > 0 ) ) { for ( int d = 0 ; d < out . length ; d ++ ) { final double val = rnd . nextDouble ( ) ; out [ d ] = val ; l2 += val * val ; } } if ( ! ( l2 > 0 ) ) { randomInitialization ( out , rnd ) ; return ; } final double s = 1. / Math . sqrt ( l2 ) ; for ( int d = 0 ; d < out . length ; d ++ ) { out [ d ] *= s ; } }
choose a random vector of unit norm for power iterations .
