using ndarray instead of malloc for adagrad and adadelta