473,387 Members | 1,892 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,387 software developers and data experts.

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 3195
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...@gmail.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***********@yahoo.com wrote:
cout << "Roots are: " << (-b+discriminant) / denom
<< ", " << (-b-discriminant) / denom
<< endl;
Oops. Make that sqrt(discriminant) 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.googlegro ups.com...
sonhado...@gmail.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(discriminant)) or
(-b-sqrt(discriminant)) 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.googlegro ups.com...
>sonhado...@gmail.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(discriminant)) or (-b-sqrt(discriminant)) 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.netwrites:
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

"RS" <rs***************@comcast.netwrote in message
news:C-******************************@comcast.com...
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
Try ppLinear
www.pecos-place.com

This is a C++ class library for linear algebra somewhat similiar to the TNT
but
making extensive use of the STL for code compaction. The library ( now in
beta) is fairly complete
i.e. it has the "meat and potatoes " functions of linear algebra - equation
solving, decompositions like SVD, QR, and LU also eigenvectors both
symmetric and non.
The library is designed for electrical engineering problems so the
functions all work for complex variables.
The library is distributed as header files and a static library. There
are versions for Microsoft VC6 and GNU GCC. Souce code is private. Update
coming in a few weeks.
It's very easy to use and quite fast. a 500*500 single precision multiply
takes 125 milliseconds (equates to 2 Gigaflops) timing results are on my
website.
The source code is only 6000 lines of C++ quite a bit smaller than
LAPACK's 100,000 lines. This makes it easy to work with. The algorithms used
are designed for the smaller problems i.e. matrices less than 5000 by 5000
eigenvectors less than 1000.

Bill Shortall
Aug 29 '06 #11

"Gert Van den Eynde" <gv******@gmail.comwrote in message
news:ec**********@ikaria.belnet.be...
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
Gert, is this available only to INSA ?
I don't see any way to download it.
Bill
Aug 29 '06 #12
Bill Shortall wrote:
"Gert Van den Eynde" <gv******@gmail.comwrote in message
news:ec**********@ikaria.belnet.be...
>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

Gert, is this available only to INSA ?
I don't see any way to download it.
Bill
No, this is the link:

http://www-gmm.insa-toulouse.fr/getf...gmm-2.0.tar.gz
bye,
gert
Sep 4 '06 #13
[This followup was posted to sci.math.num-analysis and a copy was sent
to the cited author.]

In article <ed**********@ikaria.belnet.be>, gv******@gmail.com says...
Bill Shortall wrote:
"Gert Van den Eynde" <gv******@gmail.comwrote in message
news:ec**********@ikaria.belnet.be...
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
Gert, is this available only to INSA ?
I don't see any way to download it.
Bill

No, this is the link:

http://www-gmm.insa-toulouse.fr/getf...gmm-2.0.tar.gz
bye,
gert
If you don't need source code you might look at the Intel Math Kernel,
and signal processing primitives libraries. We found both to be very
robust and efficient.

Beau Paisley
www.omatrix.com
Sep 6 '06 #14

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

Similar topics

8
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...
3
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,...
0
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...
2
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
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
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...
6
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...
3
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,...
8
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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.