Let's say I want to compute a raised cosine. I could have a macro that does #define cos_raised(x) (0.5f + 0.5f * cos(x))
, but for the sake of my problem I want to make it a function, like this:
float cos_raised(float x)
{
return 0.5f + 0.5f * cos(x);
}
This works fine but only with a single float input, when it could be easily vectorised. How do I properly vectorise it and make it accept float2/3/4/8/16 as input and output without duplicating the body of the function (this is a trivial example but I need to know this for much more complex functions)?
Edit: I guess I'm asking how to make a gentype function? Just typing gentype
doesn't work though.