473,796 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Math programming with C

Hi, I need to learn the necessary and sufficient C programming knowledge
in order to be able to implement number theory and graph theory
algorithms (as RSA or Dijkstra algorithms). No system programming no
network programming nor graphic programming.

Any advice ? Any link to a non verbose reference ?

Thanks in advance,
La Tortue
Nov 14 '05 #1
6 5142
none wrote:
Hi, I need to learn the necessary and sufficient C programming knowledge
in order to be able to implement number theory and graph theory
algorithms (as RSA RSA is cryptography, not graph theory
or Dijkstra algorithms). No system programming no
network programming nor graphic programming.

Any advice ? Any link to a non verbose reference ?

Thanks in advance,
La Tortue


Start with http://nr.com/ or http://directory.fsf.org/libs/GNUsl.html

gtoomey
Nov 14 '05 #2
Gregory Toomey a écrit :
none wrote:

Hi, I need to learn the necessary and sufficient C programming knowledge
in order to be able to implement number theory and graph theory ~~~~~~~~~~~~
algorithms (as RSA
RSA is cryptography, not graph theory


Sure. RSA is basically number theory stuff.

or Dijkstra algorithms). No system programming no
network programming nor graphic programming.

Any advice ? Any link to a non verbose reference ?

Thanks in advance,
La Tortue

Start with http://nr.com/ or http://directory.fsf.org/libs/GNUsl.html


Thanks, interesting links (although not exactly for _learning_ C
programming language for math).

La tortue

Nov 14 '05 #3
@(none) wrote:
Hi, I need to learn the necessary and sufficient C programming
knowledge in order to be able to implement number theory and
graph theory algorithms (as RSA or Dijkstra algorithms). No
system programming no network programming nor graphic
programming.
C is not a precise language, which makes it very hard to do hardcore
mathematics in it. Its possible, but you basically have to compromise
either on portability or speed, unless you are willing to really become
expert on the language.

Just learning how C deals with integers should give you reason to
reconsider using it as a language for this kind of thing. To get some
sort of sanity out of the language you have put letters like "U" or "L"
at the end of all your inline declared numbers. I would recommend
testing on no less than 7 compilers all with maximum warning settings
and using lint if you plan on having any degree of portability.

But, no compiler or lint-like utility that I am aware of can actually
assist programmers with any kind of numerical determinism. You are
basically forced to become an expert at the language which may take
many weeks or months (Python can be learned in a few hours and doesn't
have these problems).

Here are some examples:

int a, b;
unsigned int c, d;
...
if (a < 0) a = -a;
return sqrt (a); /* Undefined result. */

b = a >> 24; /* A completely meaningless operation */

if ((a % c) == (b % c))
/* a and b having the same residue mod c is insufficient
to make this condition true */

d = (a - b) % c;
/* d is zero when a and b are equal mod c, but otherwise
will not necessarily be equal to the correct residue
mod c */

And just to annoy mathematicians, C uses "*" for two different
operations as well as part of the comment brackets (and uses "/" for
comment brackets as well).

C is just a rotten language for doing real mathematics. Most of these
problems go away in other languages -- especially those that support
arbitrary precision integers (like Java, Python, etc.)
Any advice ? Any link to a non verbose reference ?


Yeah, pick a different language.

---
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/

Nov 14 '05 #4
we******@gmail. com wrote:
@(none) wrote:
Hi, I need to learn the necessary and sufficient C programming
knowledge in order to be able to implement number theory and
graph theory algorithms (as RSA or Dijkstra algorithms). No
system programming no network programming nor graphic
programming.
C is not a precise language, which makes it very hard to do
hardcore mathematics in it. Its possible, but you basically
have to compromise either on portability or speed, unless you
are willing to really become expert on the language.


Your trolling has been getting more and more pronounced over
the last few months.
Just learning how C deals with integers should give you
reason to reconsider using it as a language for this kind of
thing. To get some sort of sanity out of the language you
have put letters like "U" or "L" at the end of all your
inline declared numbers. I would recommend testing on no
less than 7 compilers all with maximum warning settings and
using lint if you plan on having any degree of portability.
Ok, it's now clear that you have trouble with C .. that doesn't
mean you should tell everyone else on comp.lang.c to avoid it.
C is just a rotten language for doing real mathematics. Most
of these problems go away in other languages -- especially
those that support arbitrary precision integers (like Java,
Python, etc.)


C supports arbitrary precision integers (for example, the GMP
library).

You could have said something like 'Mathematics takes less coding
time in a higher-level language', instead of that rant.

Nov 14 '05 #5
we******@gmail. com wrote:

<snip>
C is just a rotten language for doing real mathematics. Most of these problems go away in other languages -- especially those that support
arbitrary precision integers (like Java, Python, etc.)
Any advice ? Any link to a non verbose reference ?


Yeah, pick a different language.


These seem like overly strong statements. Googling "arbitrary precision
arithmetic C" produces many hits -- can't one use one of these
packages? I think many Fortran and C compilers support both 8 and 4
byte integers nowadays, whereas Python uses either 4 byte or arbitrary
precision integers (ABI). ABI's are much slower to work with than 8
byte integers, which may be all that is needed for a particular
calculation.

C99 (the latest C standard) has added many features for numerical
computation. One of the few books covering C99 is "C Primer Plus", 4th
Edition, by Stephen Prata.

Nov 14 '05 #6
CBFalconer <cb********@yah oo.com> wrote:
Richard Bos wrote:
we******@gmail. com wrote:
C is not a precise language, which makes it very hard to do
hardcore mathematics in it.


As usual, Paul Hsieh is talking complete bollocks. If you know
your C and take just a little care, it's quite possible to do
maths in C, and number and graph theory are not even the hardest.
Of course, this does require that you are willing to learn the
language properly, which Paul has never been.


Oh my - prepare for a flood of invective.


Feh. I only care about invective if it comes from people I take
seriously.

Richard
Nov 14 '05 #7

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

Similar topics

6
10926
by: Bibby | last post by:
I'm interesting in studying OOP programming languages on my own: C, C++, Java. I haven't studied the big 4 math subjects in my last year of high school, Calculus, Algebra, Geometry, Statistics. Which of these subjects would I need to be able to understand some of more advanced concepts I may encounter in my studies. Do I necessarily need any of them at all? Thanks PA
12
2208
by: xeys_00 | last post by:
I decided I need to understand math more to help me with programming. Not to mention, eventually in my degree plan I will need to do it anyway. How much math have people in this forum taken, and how much has it helped thier programming? Xeys
17
3629
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels deep. In that case you need much more ram than a PC has to store functions calculated in loops so that you do not have to recalculate every time you cycle through the nest of loops. Using a HD for storage to extend ram is much too slow for many...
110
8626
by: Gregory Pietsch | last post by:
I'm writing a portable implementation of the C standard library for http://www.clc-wiki.net and I was wondering if someone could check the functions in math.h for sanity/portability/whatever. I'm almost halfway through writing the over 200 functions needed to implement C99's version of math.h, and I would like to have some feedback and/or expert advice on my implementations. Sincerely, Gregory Pietsch
3
17710
by: Bart Vandewoestyne | last post by:
Simple question: does the Java standard specify what random number generator algorithm should be used for Math.random() ? If 'no', then can anybody tell me what PRNG is behind Sun's version of Math.random()? Thanks, Bart -- "Share what you know. Learn what you don't."
7
3074
by: C.W.Holeman II | last post by:
For info on the context of my question see the end of this posting. From http://www.w3.org/TR/XHTMLplusMathMLplusSVG/: How can I validate the result of client-side XSLT transform which has the following? <xsl:output method="xml"
4
364
by: aguirre.adolfo | last post by:
Hi, I am a very newbie who would very much appreciate some hints. Python 2.52. on Windows XP for now. Soon on Ubuntu 8 I am teaching myself Python following free tutorials. I can solve problems using arithmetic, but when I try to upgrade the programs using math libraries nothing seems to work. I downloaded a 2002 tutorial from Zelle "An Introduction to Computer Science" where he uses a "import math" statement to calculate a square...
17
3928
by: Lenni | last post by:
Hi, I'm currently writing a web application for bicycle wheel builders that calculate the spoke length for all sorts of variations of hubs and rims. I have translated the formula from an Excel spreadsheet and in JavaScript it looks like this: var sll=Math.sqrt(Math.pow(((fdl/2*Math.sin((2*Math.PI*cross)))/
9
5620
by: DaiOz | last post by:
Hi guys im doing a course which includes some JavaScript and I need help with the following question please, The code I have so far is below but I don't think its right please help as I need to complete this part to move onto the next. <HTML> <HEAD> <TITLE>M150 TMA 5 : Programming : Task 1 - Testing Math.random()</TITLE>
0
9685
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
9533
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10461
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
10239
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
7555
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
6796
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
5447
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...
1
4122
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
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.