Re: C++ for combinatorial optimization problems

Discussion in 'C++' started by Dietmar Kuehl, Sep 16, 2004.

  1. wrote:
    > I think C and C++ are not well suited to problems involving
    > multidimensional arrays, which are most of the problems I deal with.


    Why not? I haven't done any stuff relating to matrix stuff myself
    but my understanding is that libraries like Blitz++ are quite
    effective.

    > IMSL and NAG have Fortran 77, Fortran 90, and C libraries, but not

    C++
    > libraries AFAIK.


    There can be many reasons for this. For example, it is quite likely
    that these people program in Fortran since ages and are essentially
    ignorant of C++. ...and I would guess that their C library is actually
    just a header providing access to their Fortran library.

    > They expect C++ programmers to call their C
    > libraries. Do IMSL and NAG only implement "trivial" algorithms?


    This is not what I claimed. Actually, you can probably implement
    arbitrary algorithms in all Turing-complete programming languages. The
    question is how much support you get and how easy the algorithms are
    to use. I claim that the support you get from C++ is better suited for
    non-trivial algorithms than the support you get from languages like
    Fortrand and/or C (for trivial algorithms like searching an entry in
    an array, support in most languages is sufficient).

    > The Numerical Recipes C++ library is not that different from the C
    > version.


    Which would be an indication that the author of "Numerical Recipes C++"
    is also ignorant of C++. I can't tell for this specific book but I can
    tell for Sedgewick's "Algorithms in C++" (at least earlier editions: I
    buoght this book around 1992 and was happy to get rid of it...) that a
    better suited name would have been "Algorithms originally written in
    Pascal than converted to compile with C and then converted to use C++
    classes". That is, just because someone claims to use C++ doesn't mean
    he indeed uses C++. There is the old saying "Real programmers program
    Fortran in any language".
    --
    <mailto:> <http://www.dietmar-kuehl.de/>
    <http://www.contendix.com> - Software Development & Consulting
    Dietmar Kuehl, Sep 16, 2004
    #1
    1. Advertising

  2. Dietmar Kuehl

    Guest

    "Dietmar Kuehl" <> wrote in message news:<cic72o$>...
    > wrote:
    > > I think C and C++ are not well suited to problems involving
    > > multidimensional arrays, which are most of the problems I deal with.

    >
    > Why not? I haven't done any stuff relating to matrix stuff myself
    > but my understanding is that libraries like Blitz++ are quite
    > effective.


    Let me quote a recent message from someone who surely has more C++
    experience than I do. The message header is

    From: Dr Chaos ()
    Subject: Re: Newbie Question about Fortran speed
    Newsgroups: comp.lang.fortran
    Date: 2004-09-14 16:32:27 PST

    "The primary practical reasons to use a Fortran, as in a Fortran 95,
    compiler
    to write your new software is that

    a) it is easier to write matrix and array-based numerical programs,
    without the
    chance of being entangled in very difficult template and other similar
    language
    constructions. Yes, I am aware of the various matrix libraries for
    C++ and how pretty their statements can look when everything is
    written perfectly. The issue here is interpreting error messages if
    there is a
    mistake, or debugging programs using them. My experience is that they
    are
    almost useless (or require so much thought and digging) that they say
    little
    more than "there's a chance an error happened around here, or maybe in
    the declaration. good luck."

    b) almost all Fortran compilers have bounds checking and pointer
    checking
    modes built-in. This will help you locate bugs precisely at run-time.
    Such products may not always be standard, free or well integrated with
    the C++
    matrix libraries. This is a big deal.

    c) you are more likely to find a working 'legacy' piece of library
    software
    for free, with source code, in Fortran, usually F77, and it is easier
    to call it
    from the rest of your Fortran codes without error. Existing library
    software,
    especially in C++, may depend on intimate detail with the particular
    array or
    matrix package it was originally designed for. Often they become
    obsolete
    or infrequently used after only a few years, so that the library may
    depend
    on ancient versions of undesirable libraries. By contrast, you can
    download literal Fortran source files from the early 1970's and they
    almost
    always work with trivial adaptation."

    Regarding point (a), it is worrisome that people need to Perl programs
    to understand some STL error messages, as evidenced by projects like
    STLFilt at http://www.bdsoft.com/tools/stlfilt.html . I never have
    trouble understanding the error messages of my Fortran 95 compilers,
    which means that I rarely get stuck.
    , Sep 17, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RZ
    Replies:
    2
    Views:
    502
  2. N4M
    Replies:
    4
    Views:
    958
    Merrill & Michele
    Sep 18, 2004
  3. Dietmar Kuehl
    Replies:
    1
    Views:
    592
  4. sdf
    Replies:
    0
    Views:
    393
  5. Ravikiran

    Zero Optimization and Sign Optimization???

    Ravikiran, Nov 17, 2008, in forum: C Programming
    Replies:
    22
    Views:
    839
    Thad Smith
    Nov 24, 2008
Loading...

Share This Page