Draft: Add integer power functions

Reference issue

#1425 (closed)

What does this implement/fix?

Power function with integer exponent (x^n) where x is a scalar and n is a signed integer known at compile time. Function is relatively simple and is generic with respect to base scalar and packet type. Much faster than general power function.

Interface for array and matrix coefficientwise operations:

const int N = -4;
VectorXf a = x.cwiseIntPow<N>();
ArrayXf b = y.intPow<N>();
VectorXf c = intPow<N>(z.array());

Additional information

Might be useful for the tensor module as well.

Edited by Charles Schlosser

Merge request reports

Loading