[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Five other functions that are in Matlab core ported to Octave
From: |
John W. Eaton |
Subject: |
Five other functions that are in Matlab core ported to Octave |
Date: |
Thu, 06 Sep 2007 11:45:31 -0400 |
On 6-Sep-2007, David Bateman wrote:
| The attached patch contains versions of the typecast, swapbytes, gzip,
| celldisp and bsxfun functions for Octave. Most of these functions were
| easy enough to write though typecast needed to be implemented as an
| oct-file and gzip needed to be slightly more complex than it could have
| been as the matlab gzip keeps the original file, and I had to deal with
| path issues under windows.
|
| However, the bsxfun function was a little more complex. Basically it is
| easy to implement the bsxfun using the octave_value::subsassgn method,
| however that is extremely slow. Using data.cc(do_cat_op) was 50 times
| faster, but still slower than an implementation using repmat. I finally
| special cased most types and used the Array<T>::insert method directly.
| So bsxfun has a lot of special casing..
OK. Please check in these changes.
| This however points to one issue, ie the huge difference in speed
| between octave_value::subsassgn and data.cc(do_cat_op). It seems to be
| that a case like
|
| a = zeros(m, n)
| for i = 1: n;
| a(:,i) = ...
| end
|
| could be significantly sped up if the octave_value::subsasgn method
| could special case to do_cat_op early. It is unclear to me why the
| subsassgn method is so slow, and some profiling should be done, but it
| might have something to do this the function dereferencing the the
| function that finally does the work. The above subsassgn has a call tree
| something like
|
| octave_value::subsassgn
| -> octave_matrix::subsassgn
| -> octave_base_value::numeric_assign
| -> op-m-m.cc (assign)
| -> octave_matrix::asssign
| -> ::assign
| -> ::assign2
|
| perhaps that is just too deep and we are paying for it.. When I get some
| time I might profile the above case and try and identify where the slow
| up is..
I agree that there is probably a lot of room for improvementhere, but
any change to subsasgn should wait until the object branch is merged
(after 3.0).
Thanks,
jwe