1

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.

Mike
  • 73
  • 1
  • 9
  • 2
    Here is [Simple ARM NEON optimized sin, cos, log and exp](http://gruntthepeon.free.fr/ssemath/neon_mathfun.html) with zlib license. Haven't used it, but you could test it. Having log and exp it's possible to implement pow. – alexander Jan 24 '15 at 18:28
  • I don't understand any line of this could you explain it for me? – Mike Jan 24 '15 at 19:57

1 Answers1

2

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.

Community
  • 1
  • 1
alexander
  • 2,703
  • 18
  • 16