473,903 Members | 3,392 Online

# #include <math.h>

Hi,

I seem to be having trouble with some of my math functions (pow, sqrt,
acos). They're the only ones I use in my code and they prevent the program
from compiling. I get a "undefined reference to 'pow'" error. Here is the
relevant portion of my code.

Your help would be appreciated. Thanks!

* Genetic Algorithm module
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include "string.h"
/* GetSD
*
* This function returns the standard deviation of the feature vectors
* in a dataT * array.
*/
static double GetSD(dataT *dataArr[], int data_size, int features[], double
mean[]) {
int i, j;
double data_vect[GENES_PER_CHROM], data_sum, mean_sum, ang_sum, dotprod,
data_norm, mean_norm, angle;
double sd;

ang_sum = 0;

for(i = 0; i < data_size; i++) {
for(j = 0; j < GENES_PER_CHROM ; j++) {
data_vect[j] = dataArr[i]->val[(features[j])];
}

// get dot product of the two vectors
dotprod = 0;
for(j = 0; j < GENES_PER_CHROM ; j++) {
dotprod += data_vect[j] * mean[j];
}

// get the norms
data_sum = 0;
mean_sum = 0;
for(j = 0; j < GENES_PER_CHROM ; j++) {
data_sum += pow(data_vect[j], 2);
mean_sum += pow(mean[j], 2);
}
data_norm = sqrt(data_sum);
mean_norm = sqrt(mean_sum);

// compute the angle
angle = acos(dotprod/(data_norm * mean_norm));

ang_sum += pow(angle, 2);
}

sd = sqrt(ang_sum / (data_size - 1));

return sd;
}
Nov 13 '05
33 22127
out of me too. Reading the info file on make one day (I'm surprised how
little I do this and how much I should) I read that ';' semicolon is
also a Rule / Command separator.

But is this a make feature or a GNU make feature?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #11
In article <bq***********@ sunnews.cern.ch >, Da*****@cern.ch says...
out of me too. Reading the info file on make one day (I'm surprised how
little I do this and how much I should) I read that ';' semicolon is
also a Rule / Command separator.

But is this a make feature or a GNU make feature?

Dan

Is there an ANSI standard on Make and makefiles? Or, are we free to
assume that GNU make is the "one true make" and proceed thusly?

--
Randy Howard _o
_______________ _______()/ ()_____________ _______________ _______________ ___
SCO Spam-magnet: po********@sco. com
Nov 13 '05 #12
Groovy hepcat Darius Fatakia was jivin' on Mon, 24 Nov 2003 16:52:07
-0800 in comp.lang.c.
#include <math.h>'s a cool scene! Dig it!
I seem to be having trouble with some of my math functions (pow, sqrt,
acos). They're the only ones I use in my code and they prevent the program
from compiling. I get a "undefined reference to 'pow'" error. Here is the
relevant portion of my code.

It is the height of rudeness to post to a newsgroup without doing
both of the following:

1) read all posts in the newsgroup for a month or two, and

Please do these two things before posting again.

--

Dig the even newer still, yet more improved, sig!

"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technicall y correct" English; but since when was rock & roll "technicall y correct"?
Nov 13 '05 #13
On Wed, 26 Nov 2003 13:27:04 -0600, in comp.lang.c , Randy Howard
<ra**********@F OOmegapathdslBA R.net> wrote:

Is there an ANSI standard on Make and makefiles? Or, are we free to
assume that GNU make is the "one true make" and proceed thusly?

Its a great assumption. It will work perfectly.

Right up to the point at which you port your makefile to some other
compiler environment. Heck, ISTR that makefiles from the C compiler
shipped with SunOS 4.1.3 didn't work with the Sparc C++ compiler.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #14
Dan Pop wrote:

out of me too. Reading the info file on make one day (I'm surprised how
little I do this and how much I should) I read that ';' semicolon is
also a Rule / Command separator.

But is this a make feature or a GNU make feature?

Certainly GNU make because I read it there and tried it and it worked. I
cannot know and don't care much about all other make programs. By the
same token I don't know that TAB is the separator other make programs.
To the extent that TAB was chosen by make's original author (Who?) it
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 13 '05 #15
In article <aj************ *************** *****@4ax.com>,
ma**********@sp amcop.net says...
On Wed, 26 Nov 2003 13:27:04 -0600, in comp.lang.c , Randy Howard
<ra**********@F OOmegapathdslBA R.net> wrote:

Is there an ANSI standard on Make and makefiles? Or, are we free to
assume that GNU make is the "one true make" and proceed thusly?

Its a great assumption. It will work perfectly.

Right up to the point at which you port your makefile to some other
compiler environment. Heck, ISTR that makefiles from the C compiler
shipped with SunOS 4.1.3 didn't work with the Sparc C++ compiler.

Seems that would be easy enough to solve. Open Source, shouldn't
be hard to port to just about any modern platform that can support
a make of its own.

--
Randy Howard _o
_______________ _______()/ ()_____________ _______________ _______________ ___
SCO Spam-magnet: po********@sco. com
Nov 13 '05 #16
Kelsey Bjarnason <ke*****@lights peed.bc.ca> wrote in message news:<pa******* *************** ******@lightspe ed.bc.ca>...
On Mon, 24 Nov 2003 16:52:07 -0800, Darius Fatakia wrote:
Hi,

I seem to be having trouble with some of my math functions (pow, sqrt,
acos). They're the only ones I use in my code and they prevent the program
from compiling. I get a "undefined reference to 'pow'" error. Here is the
relevant portion of my code.

Sounds like a linker error - are you linking the math libraries? There's
a certain, popular compiler, especially widely used in the Linux world,
which has the terminally brain-dead habit of not including the math
libraries by default. Assuming you're using this compiler, try something
like this:

gcc -lm file.c

Out of interest and for the benefit of the OP, does the standard have
Nov 13 '05 #17
gs****@mailcity .com (gswork) wrote:
Kelsey Bjarnason <ke*****@lights peed.bc.ca> wrote in message news:<pa******* *************** ******@lightspe ed.bc.ca>...
On Mon, 24 Nov 2003 16:52:07 -0800, Darius Fatakia wrote:
I seem to be having trouble with some of my math functions (pow, sqrt,
acos). They're the only ones I use in my code and they prevent the program
from compiling. I get a "undefined reference to 'pow'" error. Here is the
relevant portion of my code.

Sounds like a linker error - are you linking the math libraries? There's
a certain, popular compiler, especially widely used in the Linux world,
which has the terminally brain-dead habit of not including the math
libraries by default. Assuming you're using this compiler, try something
like this:

gcc -lm file.c

Out of interest and for the benefit of the OP, does the standard have

6.9.2, 6.11.2, ...

HTH
Regards
--
Irrwahn
(ir*******@free net.de)
Nov 13 '05 #18
In <MP************ ************@ne ws.megapathdsl. net> Randy Howard <ra**********@F OOmegapathdslBA R.net> writes:
In article <bq***********@ sunnews.cern.ch >, Da*****@cern.ch says...
>out of me too. Reading the info file on make one day (I'm surprised how
>little I do this and how much I should) I read that ';' semicolon is
>also a Rule / Command separator.

But is this a make feature or a GNU make feature?

Dan

Is there an ANSI standard on Make and makefiles? Or, are we free to
assume that GNU make is the "one true make" and proceed thusly?

Why does it have to be an ANSI standard? C99 is an ANSI standard, yet
C99 code is extremely non-portable, due to lack of implementations .

According to the HP-UX man page:

STANDARDS CONFORMANCE
make: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #19
In <MP************ ************@ne ws.megapathdsl. net> Randy Howard <ra**********@F OOmegapathdslBA R.net> writes:
In article <aj************ *************** *****@4ax.com>,
ma**********@s pamcop.net says...
On Wed, 26 Nov 2003 13:27:04 -0600, in comp.lang.c , Randy Howard
<ra**********@F OOmegapathdslBA R.net> wrote:
>
>Is there an ANSI standard on Make and makefiles? Or, are we free to
>assume that GNU make is the "one true make" and proceed thusly?

Its a great assumption. It will work perfectly.

Right up to the point at which you port your makefile to some other
compiler environment. Heck, ISTR that makefiles from the C compiler
shipped with SunOS 4.1.3 didn't work with the Sparc C++ compiler.

Seems that would be easy enough to solve. Open Source, shouldn't
be hard to port to just about any modern platform that can support
a make of its own.

"Shouldn't be hard to port" and "isn't hard to port" are two completely
different things.

Between merely having to compile and install gnu make and writing portable
makefiles I'll choose the latter without a second's hesitation. I had
no problem using well written Unix makefiles with Microsoft's NMAKE when
I had to port the project to Windows + the VC++ toolchain.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

### Similar topics

 2 3245 by: Eshrath | last post by: Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are writing one object in C# which will take the entire table tag contents and renders. Ie., we need to pass "………… …….
..
" content to 2 10579 by: Donald Firesmith | last post by: I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become < and > and then no longer work. XSL code is:
..