473,698 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linear Alegebra in C++

RS
Hi all,

I am looking for a fast, efficient (tuned for speed, not size) and
mature C++ code to do some numerical work with. I have looked at the
Template Numerical Toolkit, which the oonumerics.org web page claims is
a successor to lapack++. But on the surface it doesn't seem to have all
the functionalities of lapack++, let alone being its successor. On the
other hand, it may be faster. I haven't checked that yet. Lapack++ is
supposed to be a wrapper for ublas. TNT doesn't seem to have anything to
do with ublas. It hasn't been updated that often. There is also a
cpplapack that is being developed independently of lapack++.

My question is how fast is TNT. Is it faster than the other packages? If
you were to chose one package, which one would you chose?

Thanks,
RS
Aug 26 '06 #1
13 3223
RS wrote:
I am looking for a fast, efficient (tuned for speed, not size) and
mature C++ code to do some numerical work with. I have looked at the
Template Numerical Toolkit, which the oonumerics.org web page claims is
a successor to lapack++. But on the surface it doesn't seem to have all
the functionalities of lapack++, let alone being its successor. On the
other hand, it may be faster. I haven't checked that yet. Lapack++ is
supposed to be a wrapper for ublas. TNT doesn't seem to have anything to
do with ublas. It hasn't been updated that often. There is also a
cpplapack that is being developed independently of lapack++.

My question is how fast is TNT. Is it faster than the other packages? If
you were to chose one package, which one would you chose?
I'm no help here, and you'll likely get better answers elsewhere. This
group focuses on the C++ language proper, not third-party libraries
(see http://www.parashift.com/c++-faq-lit....html#faq-5.9).
Sorry.

Cheers! --M

Aug 26 '06 #2
Do you know how to write the quadratic equation in C++?

Aug 28 '06 #3
sonhado...@gmai l.com wrote:
Do you know how to write the quadratic equation in C++?
Yes. One way would be:

float qe( const float a, const float b, const float c )
{
const float discriminant = b*b - 4.0*a*c;
if( discriminant < 0 )
{
cout << "Roots are imaginary." << endl;
}
else
{
const float denom = 2*a;
cout << "Roots are: " << (-b+discriminant) / denom
<< ", " << (-b-discriminant) / denom
<< endl;
}
}

Cheers! --M

Aug 28 '06 #4
RS wrote:
Hi all,

I am looking for a fast, efficient (tuned for speed, not size) and
mature C++ code to do some numerical work with. I have looked at the
Template Numerical Toolkit, which the oonumerics.org web page claims is
a successor to lapack++. But on the surface it doesn't seem to have all
the functionalities of lapack++, let alone being its successor. On the
other hand, it may be faster. I haven't checked that yet. Lapack++ is
supposed to be a wrapper for ublas. TNT doesn't seem to have anything to
do with ublas. It hasn't been updated that often. There is also a
cpplapack that is being developed independently of lapack++.

My question is how fast is TNT. Is it faster than the other packages? If
you were to chose one package, which one would you chose?

Thanks,
RS
I'm using the gmm++ library that is part of GetFem++
http://www-gmm.insa-toulouse.fr/getfem/ It can interface a fortran
Blas/Lapack library like ATLAS and LAPACK. Quite happy with it.

bye,
gert
Aug 28 '06 #5
ma***********@y ahoo.com wrote:
cout << "Roots are: " << (-b+discriminant) / denom
<< ", " << (-b-discriminant) / denom
<< endl;
Oops. Make that sqrt(discrimina nt) on both lines.

Cheers! --M

Aug 28 '06 #6
mlimber wrote:
[inadvertent homework response redacted]
You guys just did his homework -- he asks for it again later.
Aug 28 '06 #7
<ma***********@ yahoo.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
sonhado...@gmai l.com wrote:
Do you know how to write the quadratic equation in C++?

Yes. One way would be:

float qe( const float a, const float b, const float c )
{
const float discriminant = b*b - 4.0*a*c;
if( discriminant < 0 )
{
cout << "Roots are imaginary." << endl;
}
else
{
const float denom = 2*a;
cout << "Roots are: " << (-b+discriminant) / denom
<< ", " << (-b-discriminant) / denom
<< endl;
}
}
This method is unnecessarily unstable. If either (-b+sqrt(discrimi nant)) or
(-b-sqrt(discrimina nt)) are close to 0 [if b is large compared to a*c], you
will lose a number of significant bits. Consult your favourite numerical
textbook for a better solution, or detect for yourself whether you will lose
significance and calculate the root another way in that case.

Philip

Aug 28 '06 #8
Philip Potter wrote:
<ma***********@ yahoo.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
>sonhado...@gma il.com wrote:
>>Do you know how to write the quadratic equation in C++?

Yes. One way would be:

float qe( const float a, const float b, const float c )
{
[..]
}

This method is unnecessarily unstable. If either
(-b+sqrt(discrimi nant)) or (-b-sqrt(discrimina nt)) are close to 0 [if
b is large compared to a*c], you will lose a number of significant
bits. Consult your favourite numerical textbook for a better
solution, or detect for yourself whether you will lose significance
and calculate the root another way in that case.
Not to mention that if 'a' is 0, it's not quadratic any more...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 28 '06 #9
RS <rs************ ***@comcast.net writes:
Hi all,

I am looking for a fast, efficient (tuned for speed, not size) and
mature C++ code to do some numerical work with. I have looked at the
Template Numerical Toolkit, which the oonumerics.org web page claims
is a successor to lapack++. But on the surface it doesn't seem to have
all the functionalities of lapack++, let alone being its successor. On
the other hand, it may be faster. I haven't checked that yet. Lapack++
is supposed to be a wrapper for ublas. TNT doesn't seem to have
anything to do with ublas. It hasn't been updated that often. There is
also a cpplapack that is being developed independently of lapack++.

My question is how fast is TNT. Is it faster than the other packages?
If you were to chose one package, which one would you chose?
I've done a bit of research in this area recently. The first thing
I'd tell you to do is look around a lot more. There are a load of
linear algebra libraries out there; or rather there are a few _good_
and _complete_ ones, and a load of others. Linear Algebra is one of
those areas that looks stright-forward enough for everyone and their
grandmother to start developing one, but is actually hard enough that
few get anywhere.

I've used TNT in the past, and have to say it's an easy library to
understand, and to hack if you need to. I don't know how fast it is,
but I wouldn't guess it's one of the fastest. (I could be wrong,
though. See below.)

If your problems have compile-time sizes (e.g. you know the vector and
matrix dimensions at compile time), run (don't walk) to 'tvmet'. It's
not a large library, but it's complete, and it's _extremely fast_.

Other libs you might look at are IT++, Boost:uBlas, Blitz++, and
GNUSSL. Although GNUSSL is stricly C, not C++, it's just about the
only such library out there that's thread safe, and its performance
isn't half bad last I looked.

** All that having been said, there's no substitute for profiling.
For example, a library that uses BLAS and LAPACK for the heavy lifting
will be far superior for large matrices, since that's what LAPACK was
really built for. For small matrices, BLAS and LAPACK are typically
slower, sometimes _much_ slower, than other solutions. All of these
libraries make trade-offs, and which one is fastest really depends
rather heavily on your application.
----------------------------------------------------------------------
Dave Steffen, Ph.D.
Software Engineer IV Disobey this command!
Numerica Corporation - Douglas Hofstadter
dgsteffen at numerica dot us
Aug 28 '06 #10

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

Similar topics

8
6053
by: Scott David Daniels | last post by:
I am sorry, but in the Python 2.4 description of "heapify", I find the description of "Transform list x into a heap, in-place, in linear time," unbelievable. I understand the hand-wave that makes dictionary building linear (though I have a hard time with even that). Could somebody tell me what twist of logic makes "heapify" linear, except in the sense that linear is coming to mean "very fast?" Skeptically, -Scott David Daniels...
3
5480
by: venkat | last post by:
Hi, I want to solve linear least sqaure problem( min||c-Ax||2 subject to Bx=d ). How do I do it in python. lapack has a routine for doing this (DGGLSE). Can I access this from python? TIA, venkat.
0
2151
by: Bernard Xhumga | last post by:
hello, I present my work : a freeware, (Language C, GnuPlot). Linear algebra : (fractions, 30 packages). http://www.geocities.com/xhungab/package.html The purpose of this work is to verify with numeric applications, some properties of the linear algebra. addm, subm, multm, powm, smultm, transpose, det, minor, mminor, cofactor, mcofactor, adjoint, inverse, gauss, gaussjordan, LU,
2
7181
by: leo | last post by:
I am looking for a source code for solving linear programming using simplex method. if any one of you have any code related to it in C,C++ or JAVA then please send it to me immediately.
3
11041
by: sql guy123 | last post by:
This is a real challenge. I hope someone is smart enough to know how to do this. I have a table TABLE1
3
2631
by: elvira_wang | last post by:
heya, what sort of address is displayed when this instruction for instance is executed printf("myvar location is 0x%lx\n", (long) &myvar); is it logical address or linear address, i.e. with logical address i mean segment number | relative address within the segment, whereas with linear address i mean
6
8714
by: omesh | last post by:
hi guys.. i got a problem.. could anyone help me write a program.. the program is as follows:- 2. Solving systems of Linear equations using Iteration: You are required to write a C++ program which will solve system of linear equations with 3 or 4 unknowns (to be entered by the user). Your program should display a menu which will allow the user to choose whether he wants to (1) enter the number of unknowns, coefficients details, ......
3
6001
by: jivelasquezt | last post by:
Hi all, I'm new to this group so I don't know if this question has been posted before, but does anyone knows about linear/integer programming routines in Python that are available on the web, more specifically of the branch and bound method. Thanks, Jorge Velasquez
8
3269
by: Fett | last post by:
I am trying to find a wrapper to do linear programming within python. I am using an ubuntu machine and I have apt-get'd lp_solve, which works just fine. If someone knows of a wrapper that will work with that that'd be great. I also heard that scipy has a wrapper, however, I can't find any documentation on it, nor can I seem to find it with dir(). If anyone knows where there is good documentation on this I would love to use that (the...
0
9031
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
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
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
5862
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
4371
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
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2336
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.