Sh provides a variety of useful transcendental math functions. The names of these functions follow those in the C standard math library. However, generally they have been extended to operate componentwise, as with arithmetic instructions.
Supported trigonometric functions are listed in Table 3.9. These functions operate componentwise on tuples. This means that if you take the sine of an n-tuple, you will compute n sines in parallel. A special case is sincos, which computes sine and cosine in one function. It returns a tuple twice as long as the input tuple. Normally you would just apply it to a 1-tuple, but if a larger tuple is given to it multiple invocation will be made and packed together into the output tuple. All trigonometric functions take radians as their arguments. The helper function radians converts from degrees to radians and degrees goes the other way.
Functions for exponentiation and logarithms to the bases of e, 2, and 10 are listed in Table 3.10. The exponential functions also work on complex numbers, and return a complex number.
|
|
Not all functions are supported natively on all compilation targets, but in this case Sh will implement the function using other existing capabilities. For example, trigonometric functions like sin are not available in the OpenGL ARB vertex program assembly language. Sh will evaluate a polynomial or rational approximation for these functions.
Note: This manual is available as a bound book from AK Peters, including better formatting, in-depth examples, and about 200 pages not available on-line.