LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-11-2013, 08:58 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
efficiency and basic math functions


Two questions, related:

1) Pretty much all modern desktop processors have some of the basic higher level math approximation functions built-in, right? In particular, square root, and three basic trig functions (sine, cosine, tangent)? (Also, e^x and ln(x) would be good ones.) Are these contained in SSE*, or some other extended instruction set? I read some online material that seemed to indicate that functions were hardwired into the chips now.

2) If you are coding on a typical Gnu/Linux system, is your glibc using the built-in versions of these basic functions? Or do you have to use special calls / libraries to make use of them? I poked around a little in some glibc source code I have (2.14), and I couldn't tell for sure. The README.libm seemed to indicate that for sqrt, glibc uses a "(slow but portable) bit by bit method using integer arithmetic" which sounded kind of scary.
 
Old 04-11-2013, 09:47 PM   #2
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
1) That is the case with x86 processors.

2) That depends on which processor the program is intended to be run on. See glibc/wiki/FAQ for more details. The short answer is, "You only need to say --without-fp, and configure your compiler accordingly, if your machine has no way to execute floating-point instructions."
 
Old 04-12-2013, 12:47 AM   #3
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
I'm not quite clear yet: So, if I am compiling of x86, then glibc is using all the above mentioned functions through hardware?

I wish to clear be on this, especially as far as the trigonometric functions are concerned. README.libm in glibc documentation indicates that glibc uses a 14th degree polynomial to approximate cos(x), which would seem like a rather slow operation if this was not replaced by a call to some hardware function.

Last edited by hydraMax; 04-12-2013 at 01:25 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
math functions like sqrt? davidstvz Linux - Software 7 09-15-2010 02:38 PM
Looking up math functions for C programming on Linux AJones Linux - Software 7 12-15-2009 10:19 PM
c and math functions davidleroux1 Programming 8 09-14-2006 09:47 PM
math program that I can enter math functions ... Four General 5 04-19-2006 08:02 PM
functions in math.h philgar Slackware 3 03-27-2005 05:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration