transform(), iterators and pointers while computing Fibonacci numbers

A

Alex Vinokur

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/[email protected]


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 |
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top