help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vectorizing a summation


From: Jordi Gutiérrez Hermoso
Subject: Re: Vectorizing a summation
Date: Tue, 29 Jan 2013 14:55:48 -0500

On 29 January 2013 14:31, Bård Skaflestad <address@hidden> wrote:
> Sorry about the top post.  I don't have physical access to my normal e-mail 
> client right now.
>
> I won't try to defend my use of RESHAPE over the
>
>     d = (X-Y)(:)
>
> statement. Indexing into intermediate results certainly is useful. I
> originally started using RESHAPE because the '(:)' method, at least
> at one point, would generate an entirely new vector (including data
> copying) while RESHAPE would "just" reset some internal size
> variable on the already existing object. Maybe I'm just
> misremembering...

I believe you are. Octave's COW semantics do not incur in greater
memory usage with (:) vs reshape.

> Finally, I'd like to add one word of caution with respect to the
> original question. Unless the images are very small (e.g., smaller
> than about 100x100 pixels), the size of the intermediate matrix may
> reduce the utility of the fully vectorised approach. Images of size
> 100x100 obviously contain 10,000 points whence the (dense)
> difference matrix 'E' becomes size 10,000-by-10,000 (i.e. 100
> million entries). Using type DOUBLE then means that we need 800 MB
> of memory just to store the matrix. This may be a case for which a
> partially vectorised loop might be advantageous due to reduced
> memory pressure.

This is a good point. I find it rather strange to compare images by
doing a complete pairwise difference of all pixels, however. This
would mean that images would not be at distance zero with themselves,
for example, unless they were a single solid colour.

- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]