replaced eigen setRandom with loops and CMath