Performance optimization (allocation inside a for loop)
James Sherman Jr.
shermanj at umd.edu
Thu Apr 2 11:06:11 CDT 2009
Its redundant as far as I know, but I always use it because I think it looks
more readable.
James
On Thu, Apr 2, 2009 at 11:58 AM, Elias Assmann <
elias.assmann at student.tugraz.at> wrote:
> Rob Mahurin wrote:
> > octave:29> tic; n = 1e5; retval = 1:n; toc
> > Elapsed time is 0.000756025 seconds.
> > octave:30> tic; n = 1e5; retval = (1:n)(1:n); toc
> > Elapsed time is 0.00757694 seconds.
> > octave:31> tic; n = 1e5; retval = [1:n]; toc
> > Elapsed time is 0.0125589 seconds.
>
> Can someone explain the difference between "1:n" and "[1:n]"? I would
> normally write the brackets because I find that way clearer; does this
> mean "1:n" is actually the "preferred" way?
>
> Elias
>
> --
> Wenn weniger mehr ist, ist nichts alles.
>
> _______________________________________________
> Help-octave mailing list
> Help-octave at octave.org
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www-old.cae.wisc.edu/pipermail/help-octave/attachments/20090402/b4a2f21f/attachment-0001.html
More information about the Help-octave
mailing list