help-octave
[Top][All Lists]
Advanced

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

RE: vectorization help


From: William Krekeler
Subject: RE: vectorization help
Date: Wed, 5 Oct 2011 13:53:56 +0000

 

From: Liam Groener [mailto:address@hidden
Sent: Monday, October 03, 2011 6:27 PM
To: William Krekeler
Cc: Jordi Gutiérrez Hermoso; address@hidden
Subject: Re: vectorization help

 

On Oct 3, 2011, at 12:10 PM, William Krekeler wrote:



Thanks for the useful and very informative response. That definitely works. I'll have to read more on broadcasting to see if I can apply it elsewhere.

My code has to be cross-compatible with ML. As an FYI the bsxfun version will work in matlab 7.8.0.347:
   Cube = bsxfun(@rdivide, permute(RC, [1, 3, 2]), Cube);

 

I'm curious; does this actually save any significant time over your for loop version?

 

Liam,

 

Sorry for the slow response I was out sick yesterday. The bsxfun code using permute was marginally faster than the original loop based code set. Marginally faster starts to add up when you are processing hundreds of datasets. I don't remember the exact numbers so I reran it using the following logic:

 

                load( 'dataset.mat')

                tic; for n=1:10; (RUN BSX VERSION); end; toc

                load( 'dataset.mat')

                tic; for n=1:10; (RUN LOOP VERSION); end; toc

 

BSX Version: 33.916203 seconds

Loop Version: 94.032546 seconds

 

Keep in mind that the performance increase may be a function of my dataset size and/or properties, like shape. Also, more interestingly is that the numbers are actually for matlab, which using JIT to optimize for loops for greater speed. I tried to repeat the numbers for octave but couldn't get octave to load my version 7.3 mat file which is required by the large datasets. I found a reference to an old discussion regarding reading matlab 7.3 mat files into octave but none of the options I provided worked (http://octave.1599824.n4.nabble.com/New-undocumented-mat-file-format-td1645399.html). The closest I got was load( "-hdf5", "file.mat" ) but that crapped out when it found a variable of unknown datatype. Not sure why, it had a datatype when I saved it.

               

                load( "-hdf5", "file.mat" )

                warning: load: can't read `DATA_DATE' (unknown datatype)

                error: octave_base_value::load_binary(): wrong type argument `<unknown type>'

                error: load: error while reading hdf5 item DATA_DATE

                octave-3.2.4.exe:1> version

                ans = 3.2.4

 

 

If anyone knows how to read matlab 7.3 mat files I will calculate and post the performance difference between the bsxfun and loop version for octave. I expect it to be more substantial because octave doesn't have JIT code acceleration.

 

William Krekeler

 


reply via email to

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