Given a double x, it is known that it is more efficient to use x*x instead of pow(x,2). Imagine for simplicity that we have to calculate the square root of x: as it is a unary operation, for this purpose we have sqrt(x). Now, also raising x to the second power is a unary operation, but we have nothing like (as far as I know) pow2(x).
I implemented my own pow2 as:
inline double pow2(double a){return a*a;}
which should be still better than pow(a,2), but it is based on the * operator that is not unary.
How to implement a genuine unary implementation of pow2? Would it be the most efficient way to obtain the second power of a double?
NOTE: I am aware of the fact that every real power of a positive real is an unary operation and that it is nonsense to define an infinite number of pow2, pow3, pow3.14... from the practical point of view I'm very happy with pow(double, double).