473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C versus C++ regarding the time for scientific computation

Hi

I want to write functions for basic matrix calculations. Since I will call these functions several times, the working time of them is important. While searching the internet, I seen that some Fortran77 code may be faster than C++ code. I don't want to use Fortran however I want to decide using C or C++. Which one is suitable?
Jul 11 '08 #1
4 1630
JosAH
11,448 Expert 8TB
Hi

I want to write functions for basic matrix calculations. Since I will call these functions several times, the working time of them is important. While searching the internet, I seen that some Fortran77 code may be faster than C++ code. I don't want to use Fortran however I want to decide using C or C++. Which one is suitable?
If your priority is on speed, google for 'linpack' and 'lapack'; they're a bunch of
highly optimized functions dealing with matrix operations. If you have to deal
with sparse matrixes the world is not so nice anymore but quite a few libraries
exist for sparse matrix manipulations as well and again: google is your friend.

kind regards,

Jos
Jul 11 '08 #2
arnaudk
424 256MB
Well written C++ code will be as fast as the C or FORTRAN equivalent. You will probably find most scientists use C to do serious number crunching (or Fortran, if they have particularly long beards) but that's not because C++ is any slower, it's because they only write relatively small and simple programs and don't need the organisational advantages of objects. That's not to say the algorithms used are simple, but there's no question of writing thousands of lines of reusable code, working in a team, writing a GUI or anything like that - most often their code is written for a very narrow purpose and they are the only ones who will ever need to understand it.

However, I believe there is a lot to be gained in productivity and transparency for yourself if you use objects and adhere to good programming practices. To this end, check out Blitz++ and boost.

Bear in mind that you can also call Fortran routines from C/C++; Lapack (which largely supercedes linpack) is written in Fortran.
Jul 11 '08 #3
arnaudk
424 256MB
I should add that the de facto standard of numerical routines in C is GSL.
Jul 12 '08 #4
I have a good starting point now. Thank you for your help.
Jul 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: threeseas | last post by:
Because the project is done in python and in support of FOSS http://msdn.microsoft.com/architecture/overview/softwarefactories/default.aspx?pull=/library/en-us/dnmaj/html/aj3softfac.asp ...
31
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is...
6
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to...
53
by: Michael Tobis | last post by:
Someone asked me to write a brief essay regarding the value-add proposition for Python in the Fortran community. Slightly modified to remove a few climatology-related specifics, here it is. I...
0
by: Juan R. | last post by:
I have updated some basic requirements for a generic mathematical markup language for scientific requirements at the next link. ...
3
by: Wing | last post by:
Hello eveyone, I am programming some scientific computation based on C++. I would like to set every output/input (e.g. cout, io file stream) to be a high precision. What C++ command should I...
24
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array...
1
by: Morgan Cheng | last post by:
I have one webservice that involves time-costing computation. For each request, it consumes about 2 seconds computation. Since ASP.NET has 25 threads per CPU to handle requests, this delay turns to...
62
by: Generic Usenet Account | last post by:
A lot of research has been done to prove that the contention that C code is more efficient and more compact than equivalent C++ code is a myth. My posting pertains to a slightly different aspect...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.