# 2011-04-20 22:00:22     How to use ANSI exp(x)

Document created by Aaronwu on Aug 26, 2013
Version 1Show Document

2011-04-20 22:00:22     How to use ANSI exp(x)

Wojtek Skulski (UNITED STATES)

Message: 100050

I want to perform on-board some model calculations using the ANSI exponential "double exp (double x)" as should be defined in math.h. I wrote a simple program which is attached. The calculation is straightforward:

tim = i * CLK_PERIOD;

x = -tim / tau;

voltage = VZERO * exp (x);

lo = (short int) voltage;

I am getting the following link error.

\$ bfin-linux-uclibc-gcc -Wall -o fspy_exponent -mfdpic fspy_exponent.c

fspy_exponent.c: In function 'main':

fspy_exponent.c:65: warning: implicit declaration of function 'exp'

fspy_exponent.c:65: warning: incompatible implicit declaration of built-in function 'exp'

/tmp/ccYJXImA.o: In function `_main':

fspy_exponent.c:(.text+0xda): undefined reference to `_exp'

fspy_exponent.c:(.text+0x14e): undefined reference to `_exp'

collect2: ld returned 1 exit status

I searched Wiki and found some remark that math.h was renamed to math_bf.c (breaking ANSI, I guess). I tried both forms #include <math.h> and #include <math_bf.h>, but I am still getting the same undefined error.

What should I do in order to perform ANSI math calculations?

fspy_exponent.c

2011-04-20 23:50:42     Re: How to use ANSI exp(x)

Simon Brewer (AUSTRALIA)

Message: 100053

You need to link against the math library.

Simon

2011-04-21 10:15:48     Re: How to use ANSI exp(x)

Wojtek Skulski (UNITED STATES)

Message: 100085    Simon:

linked, when I used #include <math.h>. It did not link when I #included

math_bf.h. Apparently, this part of Wiki information must be wrong for

some reason.

Thank you -- Wojtek

2011-04-21 12:09:01     Re: How to use ANSI exp(x)

Mike Frysinger (UNITED STATES)

Message: 100086

not really.  you're asking about standard math code while the wiki documents Blackfin-specific functions.  the latter does not apply to the former.

2011-04-21 12:18:36     Re: How to use ANSI exp(x)

Wojtek Skulski (UNITED STATES)

Message: 100087

Mike:

I am refering to   docs.blackfin.uclinux.org/doku.php?id=toolchain:libbfdsp&s[]=math, which is the only info I found when I searched the wiki for math.h. I read the following statement, which to my mind says that math.h was removed and renamed math_bf.h. I am not sure what else it could mean.

math.h is renamed to math_bf.h -- The original library contains math function overlapping with uClibc math library. To avoid confusion, these functions are removed.

2011-04-21 20:53:29     Re: How to use ANSI exp(x)

Mike Frysinger (UNITED STATES)

Message: 100108

that only documents the Blackfin DSP library.  it has no bearing on the POSIX math library.

the math.h rename is there for people used to VDSP++ where it is named math.h.