Mike
Mike

Reputation: 73

assembly armv7 neon power function

I'm new to assembler. I want to implement a power function but i don't have an exp or a log function. I have something like a^b while a is an integer and b is a float.

I could only come up with something if b is a natural number. Like an loop which multiplies a with a for b times.

Is there something like that or has anyone an idea how to implement it.

Upvotes: 1

Views: 2945

Answers (1)

alexander
alexander

Reputation: 2753

As I understand, you asked about how to implement pow function using arm neon.

Most effective pow implementation for integer a and b is multiple a by a in a loop abs(b) times. For negative b divide 1.0 by result of the loop (see here).

If you have exp and log implementations, than you could implement pow using equation pow(x, m) = exp(m * log (x)) (see here).

You mention about you don't have exp and log function.

So, if you find a math library with exp and log functions, than you can implement pow for double a and b.

There are some math libraries for arm, with pow implementation. See math-neon, for example.

Also the is pure log and exp implementations (in C, using neon intrinsics) in the library Simple ARM NEON optimized sin, cos, log and exp. You can take the code from the library and rewrite it into arm assembly. Just ask lawyer how to satisfy library license. You need only two functions from it. Intrinsics code could be simple ported to asm.

Upvotes: 2

Related Questions