fixed functional lib
added some cuda code