transform(), iterators and pointers while computing Fibonacci numbers

Discussion in 'C++' started by Alex Vinokur, Jul 26, 2004.

  1. Alex Vinokur

    Alex Vinokur Guest

    One more improvement has been done in
    the "Computing very large Fibonacci numbers" algorithm.

    Its new version can be seen
    at http://groups.google.com/groups?selm=


    Iterators in the transform() algorithm have been replaced by pointers.

    --------------------------------------
    vector<unsigned long> vin1, vin2, vout;
    // Stuff

    Previous version:
    transform (vin1.begin(), vin1.end(), vin2.begin(), vout.begin(), functor());

    Current version:
    transform (&vin1[0], &vin1[0] + vin1.size(), &vin2[0], &vout[0], functor());
    --------------------------------------



    Measuring the comparative performance.
    =====================================
    -------------------------------------
    Windows 2000
    Intel (R) Celeron (R) CPU 1.70 GHz
    GNU g++ 3.3.1 (cygming special), MinGW


    ------------ Compilation ------------------
    $ g++ [Optimize option] -mno-cygwin foo.cpp
    -------------------------------------------


    Computing Fibonacci[50000].
    Comparative performance.
    |-------------------------------------------
    | | transform | transform |
    | Optimization | with | with |
    | | iterators | pointers |
    |-----------------|------------------------|
    | No optimization | 4.846 | 3.044 |
    | Optimization O1 | 2.573 | 2.133 |
    | Optimization O2 | 2.223 | 2.323 |
    | Optimization O2 | 2.233 | 2.223 |
    --------------------------------------------


    --
    Alex Vinokur
    http://mathforum.org/library/view/10978.html
    http://sourceforge.net/users/alexvn
    Alex Vinokur, Jul 26, 2004
    #1
    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. Alex Vinokur
    Replies:
    0
    Views:
    469
    Alex Vinokur
    Oct 29, 2003
  2. Andrew Tatum

    Fibonacci Numbers and Lucas Numbers

    Andrew Tatum, May 26, 2007, in forum: C++
    Replies:
    6
    Views:
    559
    Howard
    May 27, 2007
  3. optical supercomputing

    Optical Computing: special issue - Natural Computing, Springer

    optical supercomputing, Dec 19, 2008, in forum: C Programming
    Replies:
    0
    Views:
    414
    optical supercomputing
    Dec 19, 2008
  4. optical supercomputing

    Optical Computing: special issue - Natural Computing, Springer

    optical supercomputing, Jan 16, 2009, in forum: C Programming
    Replies:
    0
    Views:
    445
    optical supercomputing
    Jan 16, 2009
  5. tphyahoo
    Replies:
    6
    Views:
    344
    Maciej Tomaka
    Aug 8, 2008
Loading...

Share This Page