A(1:n) vs A(1:end)

[Old posts from the commercial version of ArrayFire] Discussion of ArrayFire using CUDA or OpenCL.

Moderator: pavanky

A(1:n) vs A(1:end)

Postby melonakos » Sun Mar 07, 2010 5:52 pm

Which of these is faster?

Code: Select all
A(1:n) or A(1:end)

The latter.

Whenever possible, use "1:end" when sub-referencing.

"1:n" will get expanded out in memory by MATLAB, then Jacket must process that sequence to determine that it could be "compressed" to some linear sequence.

If you use "1:end", "1:end-1", or something like that involving the "end" keywords, then Jacket already gets notified that this is a linear sequence -- no need to scan through all the elements.

Just a tip that might help you out!

-John (posting on behalf of "malcolm" who is working hard on Jacket 1.3 right now :))
John Melonakos (john@arrayfire.com)
User avatar
Posts: 503
Joined: Tue Jun 10, 2008 9:49 am

Return to [archive-commercial] Programming & Development with ArrayFire