473,903 Members | 3,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

#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
In <3F*********@ea rthlink.net> Joe Wright <jo********@ear thlink.net> writes:
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...
In <3F*********@ea rthlink.net> Joe Wright <jo********@ear thlink.net> writes:
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
2reply remove FOOBAR \<,
_______________ _______()/ ()_____________ _______________ _______________ ___
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
2) read the newsgroup's FAQ.

Please do these two things before posting again.

--

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

http://alphalink.com.au/~phaywood/
"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>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. 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:

In <3F*********@ea rthlink.net> Joe Wright <jo********@ear thlink.net> writes:
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
seems arbitrary and badly chosen.
--
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
2reply remove FOOBAR \<,
_______________ _______()/ ()_____________ _______________ _______________ ___
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
anything to say about linkage?
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
anything to say about linkage?


About /linking/ refer to ISO/IEC 9899:1999 5.1.1.2#8.

About /linkage/ refer to 6.2.2., 6.7, 6.7.4, 6.7.5.2, 6.9,
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...
In <3F*********@ea rthlink.net> Joe Wright <jo********@ear thlink.net> writes:
>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 "<table>………… <thead>……</thead>. <tr>.<td> <td>..<tr>.<td> <td> </table>" 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 &lt; and &gt; and then no longer work. XSL code is: <script type="text/javascript"> <!]> </script> <script type="text/javascript"
18
2645
by: Tuckers | last post by:
My question is, if I have created my own library which lives in its own install directory, to refer to its header file is it better to use #include "MyLibrary.h" or #include <MyLibrary.h> Assume that this library will be used by other groups. I think the answer
4
13385
by: John B. | last post by:
I'm self teaching myself C on a Linux box but I can't get a simple program to recognize math functions. I start the program with: #include <stdio.h> #include <math.h> but when I compile the program, it does not recognize sin(x); or pow(x,y) etc, in any equation. /usr/include does have a math.h file. Any help or things to try would be greatly appreciated!!!!. (I do alot of graphic things with trig.) thanks ...
9
13131
by: bill | last post by:
Forget the exact definition of difference between, #include <foo.h> and #include "bar.h" Normally foo.h is a standard header file, so it's path is not defined in compiler option, but I am curious how compiler find it.
2
4304
by: Jofio | last post by:
I have 3 files, namely: dArray.h dArray.cp TestdArray.cpp Problem is when I compile the 'main' program - TestdArray.cpp - , it (the compiller) produces the following error: 'Unable to open include file 'dArray.h' 'Unable to open include file'dArray.cp'
3
3402
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above functionality without having to use &gt,&lt and such stuff???
13
1917
by: Sebastian Faust | last post by:
Hi, I hava a somehow strange problem. I hope I am not wrong in this group; if this is the case please let me know. I am trying to compile a rather simple C program. As long as I use: #include <extp.h> gcc tells me that he cannot find extp.h. As soon as I write #include "extp.h"
14
3177
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the PHP interpreter works like any other, that is, it first expands all the include files, and then parses the resulting text. Can anyone help with an explanation? Thanks, M. McDonnell
0
9997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11279
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7205
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5893
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4725
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4307
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.