From vague memory there might also be one in QuantLib, which is a freelibrary of functions for quant. work.Check at
http://www.quantlib.org/From memory (I might be wrong) you can download all the source and hencepick out the chunk of code you need.**Company Disclaimer**(Please note that we have not checked any of the QuantLib either for accuracyor stability - you should certainly do this before using it in any production work)