Connecting Tech Pros Worldwide Help | Site Map

Linear Alegebra in C++

RS
Guest
 
Posts: n/a
#1: Aug 26 '06
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
mlimber
Guest
 
Posts: n/a
#2: Aug 26 '06

re: Linear Alegebra in C++


RS wrote:
Quote:
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

sonhadorPR@gmail.com
Guest
 
Posts: n/a
#3: Aug 28 '06

re: Linear Alegebra in C++


Do you know how to write the quadratic equation in C++?

matthewlimber@yahoo.com
Guest
 
Posts: n/a
#4: Aug 28 '06

re: Linear Alegebra in C++


sonhado...@gmail.com wrote:
Quote:
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

Gert Van den Eynde
Guest
 
Posts: n/a
#5: Aug 28 '06

re: Linear Alegebra in C++


RS wrote:
Quote:
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
mlimber
Guest
 
Posts: n/a
#6: Aug 28 '06

re: Linear Alegebra in C++


matthewlimber@yahoo.com wrote:
Quote:
cout << "Roots are: " << (-b+discriminant) / denom
<< ", " << (-b-discriminant) / denom
<< endl;
Oops. Make that sqrt(discriminant) on both lines.

Cheers! --M

red floyd
Guest
 
Posts: n/a
#7: Aug 28 '06

re: Linear Alegebra in C++


mlimber wrote:
Quote:
[inadvertent homework response redacted]
>
You guys just did his homework -- he asks for it again later.
Philip Potter
Guest
 
Posts: n/a
#8: Aug 28 '06

re: Linear Alegebra in C++


<matthewlimber@yahoo.comwrote in message
news:1156735934.075430.105920@75g2000cwc.googlegro ups.com...
Quote:
sonhado...@gmail.com wrote:
Quote:
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

Victor Bazarov
Guest
 
Posts: n/a
#9: Aug 28 '06

re: Linear Alegebra in C++


Philip Potter wrote:
Quote:
<matthewlimber@yahoo.comwrote in message
news:1156735934.075430.105920@75g2000cwc.googlegro ups.com...
Quote:
>sonhado...@gmail.com wrote:
Quote:
>>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


Dave Steffen
Guest
 
Posts: n/a
#10: Aug 28 '06

re: Linear Alegebra in C++


RS <rsina_no.ssppaamm@comcast.netwrites:
Quote:
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
Bill Shortall
Guest
 
Posts: n/a
#11: Aug 29 '06

re: Linear Alegebra in C++



"RS" <rsina_no.ssppaamm@comcast.netwrote in message
news:C-idnQsN6_jNJXLZnZ2dnUVZ_radnZ2d@comcast.com...
Quote:
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


Bill Shortall
Guest
 
Posts: n/a
#12: Aug 29 '06

re: Linear Alegebra in C++



"Gert Van den Eynde" <gvdeynde@gmail.comwrote in message
news:ecu8bh$bi5$1@ikaria.belnet.be...
Quote:
RS wrote:
Quote:
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


Gert Van den Eynde
Guest
 
Posts: n/a
#13: Sep 4 '06

re: Linear Alegebra in C++


Bill Shortall wrote:
Quote:
"Gert Van den Eynde" <gvdeynde@gmail.comwrote in message
news:ecu8bh$bi5$1@ikaria.belnet.be...
Quote:
>RS wrote:
Quote:
>>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
Harmonic Software
Guest
 
Posts: n/a
#14: Sep 6 '06

re: Linear Alegebra in C++


[This followup was posted to sci.math.num-analysis and a copy was sent
to the cited author.]

In article <edghgm$svc$1@ikaria.belnet.be>, gvdeynde@gmail.com says...
Quote:
Bill Shortall wrote:
Quote:
"Gert Van den Eynde" <gvdeynde@gmail.comwrote in message
news:ecu8bh$bi5$1@ikaria.belnet.be...
Quote:
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
Closed Thread