This code is a direct port of the sample code provided in Simplex noise demystified by Stefan Gustavson.
This implementation is free and unencumbered software released into the public domain but be aware that the original algorithm and code that this was derived from may be subject to restrictions.