Code covered by the BSD License  

Highlights from
inplace_

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 8.66 KB File ID: #12626

inplace_

by Luca Citi

 

13 Oct 2006 (Updated 13 Oct 2006)

Matlab versions of the c/c++ operators +=, *= (plus circshift) working in-place and avoiding unneces

| Watch this File

File Information
Description

To date I implemented a few functions I needed, i.e. some C-like operators and circshift:
  inplace(x, y, '+=');
  inplace(x, y, '.*=');
  inplace(x, ns, 'circshift');
that do not allocate memory and compared to the matlab equivalent
  x = x + y;
  x = x .* y;
  x = circshift(x, ns);
are (when working with arrays above 300-400 MB) much faster (tenths of second instead of a few minutes) because the pc does not start swapping to the disk.
The matlab equivalents are currently optimized (performed in-place) only in M-code, but not at the command line.
See http://blogs.mathworks.com/loren/?p=36 for a discussion about it.
IMPORTANT: this piece of code infringes the recommendation that mex files should not overwrite input data.

MATLAB release MATLAB 7.0.4 (R14SP2)
Other requirements To compile it you need to configure the C compiler in matlab. Otherwise you can try the compiled versions (inplace_.dll and inplace_.mexglx).
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
14 Oct 2006 Joaquim Luis

Luca, the cvlib_mex submission already did dat with further advantages:
1. It works with all data types (except uin32) and not only with doubles.
2. With pentiums it uses the Matlab MKS library to do matrice operations

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
inplace Luca Citi 22 Oct 2008 08:43:39
memory allocation Luca Citi 22 Oct 2008 08:43:39
c operators Luca Citi 22 Oct 2008 08:43:39
circshift Luca Citi 22 Oct 2008 08:43:39

Contact us at files@mathworks.com