Added math fun support in gen.py
Optimization gradientDescent : use matrix calculation