Linear Alegebra in C++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RS

    #1

    Linear Alegebra in C++

    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

    #2
    Re: Linear Alegebra in C++

    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

    Comment

    • sonhadorPR@gmail.com

      #3
      Re: Linear Alegebra in C++

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

      Comment

      • matthewlimber@yahoo.com

        #4
        Re: Linear Alegebra in C++

        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

        Comment

        • Gert Van den Eynde

          #5
          Re: Linear Alegebra in C++

          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

          Comment

          • mlimber

            #6
            Re: Linear Alegebra in C++

            matthewlimber@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

            Comment

            • red floyd

              #7
              Re: Linear Alegebra in C++

              mlimber wrote:
              [inadvertent homework response redacted]
              >
              You guys just did his homework -- he asks for it again later.

              Comment

              • Philip Potter

                #8
                Re: Linear Alegebra in C++

                <matthewlimber@ yahoo.comwrote in message
                news:1156735934 .075430.105920@ 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

                Comment

                • Victor Bazarov

                  #9
                  Re: Linear Alegebra in C++

                  Philip Potter wrote:
                  <matthewlimber@ yahoo.comwrote in message
                  news:1156735934 .075430.105920@ 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


                  Comment

                  • Dave Steffen

                    #10
                    Re: Linear Alegebra in C++

                    RS <rsina_no.ssppa amm@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

                    Comment

                    • Bill Shortall

                      #11
                      Re: Linear Alegebra in C++


                      "RS" <rsina_no.ssppa amm@comcast.net wrote in message
                      news:C-idnQsN6_jNJXLZn Z2dnUVZ_radnZ2d @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


                      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


                      Comment

                      • Bill Shortall

                        #12
                        Re: Linear Alegebra in C++


                        "Gert Van den Eynde" <gvdeynde@gmail .comwrote in message
                        news:ecu8bh$bi5 $1@ikaria.belne t.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


                        Comment

                        • Gert Van den Eynde

                          #13
                          Re: Linear Alegebra in C++

                          Bill Shortall wrote:
                          "Gert Van den Eynde" <gvdeynde@gmail .comwrote in message
                          news:ecu8bh$bi5 $1@ikaria.belne t.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:




                          bye,
                          gert

                          Comment

                          • Harmonic Software

                            #14
                            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@i karia.belnet.be >, gvdeynde@gmail. com says...
                            Bill Shortall wrote:
                            "Gert Van den Eynde" <gvdeynde@gmail .comwrote in message
                            news:ecu8bh$bi5 $1@ikaria.belne t.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:
                            >

                            >
                            >
                            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

                            Comment

                            Working...