Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: optimize th...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 45809 of 47017
Post > Topic >>

Re: optimize this ****fting code ?

by Jerry Coffin <jcoffin@[EMAIL PROTECTED] > May 9, 2008 at 07:54 AM

In article <e8d13a91-0b3b-4949-88b9-00f6088bdfa1
@[EMAIL PROTECTED]
>, stevenj@[EMAIL PROTECTED]
 says...

[ ... ]

> PS. For even N, the fastest way to ****ft by N/2 is almost certainly
> just a loop of N/2 swaps in-place as another poster pointed out.

As you'd guess, that's what swap_ranges does (25.2.2/3):

Effects: For each non-negative integer n < (last1 - first1) performs: 
swap(*(first1 + n), *(first2 + n))

I see little likelihood that writing the loop yourself will gain 
anything.

> For
> odd N, or for an arbitrary cyclic ****ft of the array, in the past
> we've found that the fastest scheme is to do two in-place p***** over
> the array: one to reverse the order, and one to un-reverse the two
> segments before and after the ****ft.

Until or unless profiling indicated a necessity to use something else, 
I'd use std::rotate. For that matter, I'm not quite sure why your 
algorithm would be faster than std::rotate, though I certainly haven't 
profiled it to figure out for sure. 

-- 
    Later,
    Jerry.

The universe is a figment of its own imagination.
 




 6 Posts in Topic:
optimize this Shifting code ?
Matthias Pospiech <mat  2008-05-08 14:23:56 
Re: optimize this Shifting code ?
lunar_lty <penglu96@[E  2008-05-08 05:56:56 
Re: optimize this Shifting code ?
"Victor Bazarov"  2008-05-08 20:53:03 
Re: optimize this Shifting code ?
Jerry Coffin <jcoffin@  2008-05-08 19:07:22 
Re: optimize this Shifting code ?
"Steven G. Johnson&q  2008-05-08 21:45:11 
Re: optimize this Shifting code ?
Jerry Coffin <jcoffin@  2008-05-09 07:54:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 16:02:52 CDT 2008.