transform(), iterators and pointers while computing Fibonacci numbers



 DEVELOP > c-Plus-Plus > transform(), iterators and pointers while computing Fibonacci numbers

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1
Topic: DEVELOP > c-Plus-Plus
User: "Alex Vinokur"
Date: 26 Jul 2004 10:29:29 AM
Object: transform(), iterators and pointers while computing Fibonacci numbers
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=2mk62rFo1mv0U1%40uni-berlin.de
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
.

 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER