From: Qianqian Fang on 25 Jul 2010 15:23 hi I want to know if matlab support in-place operations for simple calculations. This particular question raised when I run a vector update with a long index: vol(longidx)=vol(longidx)+weight*val(goodidx); Very often, matlab complains that memory is running out. I need something like "vol+=newadd" as in C/C++, where the memory is updated in-place without creating a temporary variable. does any one know if matlab is capable of doing this? Qianqian
From: us on 25 Jul 2010 15:36 Qianqian Fang <fangqq(a)gmail.com> wrote in message <4b984d05-ba1f-4ef7-97ca-fbce6e7c6ea4(a)q35g2000yqn.googlegroups.com>... > hi > > I want to know if matlab support in-place operations for simple > calculations. This particular question raised when I run a vector > update with a long index: > > vol(longidx)=vol(longidx)+weight*val(goodidx); > > Very often, matlab complains that memory is running out. I need > something like "vol+=newadd" as in C/C++, where the memory is updated > in-place without creating a temporary variable. > > does any one know if matlab is capable of doing this? > > Qianqian this 1) has been discussed over and over in this NG (and TMW blogs)... -and- 2) is currently not a ML feature... consider using a MEX-file approach... us
From: Qianqian Fang on 25 Jul 2010 16:24 On Jul 25, 3:36 pm, "us " <u...(a)neurol.unizh.ch> wrote: > Qianqian Fang <fan...(a)gmail.com> wrote in message <4b984d05-ba1f-4ef7-97ca-fbce6e7c6...(a)q35g2000yqn.googlegroups.com>... > > hi > > > I want to know if matlab support in-place operations for simple > > calculations. This particular question raised when I run a vector > > update with a long index: > > > vol(longidx)=vol(longidx)+weight*val(goodidx); > > > Very often, matlab complains that memory is running out. I need > > something like "vol+=newadd" as in C/C++, where the memory is updated > > in-place without creating a temporary variable. > > > does any one know if matlab is capable of doing this? > > > Qianqian > > this > 1) has been discussed over and over in this NG (and TMW blogs)... > -and- > 2) is currently not a ML feature... thanks for the quick response. Before I post my question, I did search this list with some keywords, but nothing came up relevant: http://groups.google.com/group/comp.soft-sys.matlab/search?group=comp.soft-sys.matlab&q=+in-place+operations&qt_g=Search+this+group anyway. I am going to give up now and use loop to reduce memory utility. Qianqian > > consider using a MEX-file approach... > > us
From: Matt J on 25 Jul 2010 18:23 Qianqian Fang <fangqq(a)gmail.com> wrote in message <4b984d05-ba1f-4ef7-97ca-fbce6e7c6ea4(a)q35g2000yqn.googlegroups.com>... > hi > > I want to know if matlab support in-place operations for simple > calculations. This particular question raised when I run a vector > update with a long index: > > vol(longidx)=vol(longidx)+weight*val(goodidx); > > Very often, matlab complains that memory is running out. I need > something like "vol+=newadd" as in C/C++, where the memory is updated > in-place without creating a temporary variable. ============== In-place processing happens for operations that make element-wise changes to an existing array, like the one you've shown. You can verify this with some simple experiments like below: clear V; V=rand(500,500,330); %a big array >> A=V+1; ??? Out of memory. Type HELP MEMORY for your options. >> V=V+1; %No error
From: Jan Simon on 25 Jul 2010 18:45 Dear Qianqian, > I want to know if matlab support in-place operations for simple > calculations. > vol(longidx)=vol(longidx)+weight*val(goodidx); Matlab 2009a, WinXP, 32 bit: format debug x = rand(1000, 1); x(1) >> structure address = a820940 >> pr = bb51b80 (pointer to the real double array) v = rand(1000, 1) < 0.2; x(v) = x(v) + rand(sum(v), 1); x(1) >> structure address = a820940 >> pr = bb51b80 So it looks, like Matlab *does* inplace operations even *without* the += operator. Good luck, Jan
|
Next
|
Last
Pages: 1 2 3 Prev: reading textfile ! Next: Mean of nonzero elements in a 2D Array w/o a loop? |