Klang C++ 0.7.15
Language Reference (draft)
Loading...
Searching...
No Matches
cos

Language Guide / Functions · Generated API signature

cos

klang::fast::cos

Approximate cosine from an angle in radians.

Use fast::cos with a float angle in radians in the range [0, 2π). Wrap other angles to one turn before calling. The phase reduction uses a fixed-point conversion. The implementation folds the phase into a smaller angle range and evaluates a seventh-degree polynomial. In a native test across 65,536 phases over one turn, the largest absolute error was about 0.0000066. For ordinary trigonometry over a wider input range, see cos.

Direct call

const signal wave = fast::cos(phase);

Signal flow

const signal wave = signal(phase) >> fast::cos;