<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: In-place Operations on Data</title>
	<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Sun, 22 Nov 2009 23:46:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30555</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 27 Aug 2009 11:56:21 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30555</guid>
		<description>Tamas-

I believe the API to do that is not documented or supported so could change in the future.  But it is certainly something you could try.

--Loren</description>
		<content:encoded><![CDATA[<p>Tamas-</p>
<p>I believe the API to do that is not documented or supported so could change in the future.  But it is certainly something you could try.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tamas</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30554</link>
		<dc:creator>Tamas</dc:creator>
		<pubDate>Thu, 27 Aug 2009 09:58:30 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30554</guid>
		<description>I tought about to pass the matrix A and array b to a MEX-function, which contains a call to the corresponding ZGESV LAPACK routine to solve my complex lin.eq. system. ZGESV solves the system in-place. I don't know, if passing arrays to MEX-functions needs a duplicate of the array in the memory or not ...</description>
		<content:encoded><![CDATA[<p>I tought about to pass the matrix A and array b to a MEX-function, which contains a call to the corresponding ZGESV LAPACK routine to solve my complex lin.eq. system. ZGESV solves the system in-place. I don&#8217;t know, if passing arrays to MEX-functions needs a duplicate of the array in the memory or not &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30553</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 26 Aug 2009 20:08:31 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30553</guid>
		<description>Tamas-

If appropriate, sparse arrays MIGHT help.  Parallel computing should help, if you have access to it.

--Loren</description>
		<content:encoded><![CDATA[<p>Tamas-</p>
<p>If appropriate, sparse arrays MIGHT help.  Parallel computing should help, if you have access to it.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tamas</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30552</link>
		<dc:creator>Tamas</dc:creator>
		<pubDate>Wed, 26 Aug 2009 15:02:09 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30552</guid>
		<description>Thanks for reply Loren,

actually I have to solve _very_ large linear systems (matrix sizes of 6-8 Gb), and it seems, when the code comes to the point of the A\b operation, MATLAB allocates approx. two times more as the system size. I wanted to know, if there is a way to avoid this, as it really matters if one has to have a computer with 16 or only 8 Gigs of memory. I know that iterative solvers use much less memory, but they converge very badly in my case.</description>
		<content:encoded><![CDATA[<p>Thanks for reply Loren,</p>
<p>actually I have to solve _very_ large linear systems (matrix sizes of 6-8 Gb), and it seems, when the code comes to the point of the A\b operation, MATLAB allocates approx. two times more as the system size. I wanted to know, if there is a way to avoid this, as it really matters if one has to have a computer with 16 or only 8 Gigs of memory. I know that iterative solvers use much less memory, but they converge very badly in my case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30551</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 26 Aug 2009 14:53:49 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30551</guid>
		<description>Tamas-

LU doesn't have in-place optimization.  But in general, you should only code that way when it's natural or you are desperate regarding memory.  Otherwise code ends up too hard to understand later.

--Loren</description>
		<content:encoded><![CDATA[<p>Tamas-</p>
<p>LU doesn&#8217;t have in-place optimization.  But in general, you should only code that way when it&#8217;s natural or you are desperate regarding memory.  Otherwise code ends up too hard to understand later.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tamas</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30548</link>
		<dc:creator>Tamas</dc:creator>
		<pubDate>Wed, 26 Aug 2009 11:57:46 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-30548</guid>
		<description>Hello,
I would like to know how much memory I could conserve by using [L A P]=lu(A); (inplace LU).
Actually I have an equation system, which runs out of memory when using x=A\b ... If I used [L A P]=lu(A); x=A\(L\b); could I conserve some memory with this approach ?
Is anyhow real inplace x=A\b solution achievable in MATLAB ?
Thanks for reply.</description>
		<content:encoded><![CDATA[<p>Hello,<br />
I would like to know how much memory I could conserve by using [L A P]=lu(A); (inplace LU).<br />
Actually I have an equation system, which runs out of memory when using x=A\b &#8230; If I used [L A P]=lu(A); x=A\(L\b); could I conserve some memory with this approach ?<br />
Is anyhow real inplace x=A\b solution achievable in MATLAB ?<br />
Thanks for reply.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Felipe G Nievinski</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-29514</link>
		<dc:creator>Felipe G Nievinski</dc:creator>
		<pubDate>Tue, 17 Jun 2008 17:25:00 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-29514</guid>
		<description>Sure -- I've just submitted it, as an enhancement request.
Felipe.</description>
		<content:encoded><![CDATA[<p>Sure &#8212; I&#8217;ve just submitted it, as an enhancement request.<br />
Felipe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-29511</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 17 Jun 2008 11:36:48 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-29511</guid>
		<description>Felipe-

Thanks for the suggestion.  This feedback will help us out.  I am hoping you'd be willing to enter it here: http://www.mathworks.com/support/service_requests/contact_support.do

--Loren</description>
		<content:encoded><![CDATA[<p>Felipe-</p>
<p>Thanks for the suggestion.  This feedback will help us out.  I am hoping you&#8217;d be willing to enter it here: <a href="http://www.mathworks.com/support/service_requests/contact_support.do" rel="nofollow">http://www.mathworks.com/support/service_requests/contact_support.do</a></p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Felipe Nievinski</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-29508</link>
		<dc:creator>Felipe Nievinski</dc:creator>
		<pubDate>Tue, 17 Jun 2008 05:11:17 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-29508</guid>
		<description>Loren,

any prospects for cellfun supporting in-place operations, please?

For example, given your demo

    function inplaceTest(x)
    % Call functions with either regular or in-place semantics.
    %% Call a Regular Function with the Same Left-Hand Side
    x = myfunc(x);
    %% Call an In-place Function with the Same Left-Hand Side
    x = myfuncIP(x);
    %% Call a Regular Function with a Different Left-Hand Side
    y = myfunc(x);

if I modify the functions as follows

    function y = myfunc(x)
    y = cellfun(@uminus, x, 'UniformOutput',false);
    function x = myfuncIP(x)
    x = cellfun(@uminus, x, 'UniformOutput',false);

then memory profile it:

    n = 7*2^20;
    x = randn(n,1);
    x = {x};
    profile -memory on
    inplaceTest(x)
    profile viewer

looking under inplaceTest, you can notice Allocated Memory has the same large value (57358.45 Kb) for myfunc and myfuncIP.

In contrast, if I don't use cellfun in the functions,

    function y = myfunc(x)
    y = -x;
    function x = myfuncIP(x)
    x = -x;

then after memory profiling it

    n = 7*2^20;
    x = randn(n,1);
    profile -memory on
    inplaceTest(x)
    profile viewer

then you'll see negligible Allocated Memory for the in-place call, as expected.

I have a class that uses cell arrays to store its data, and its operators are all implemented using cellfun; it'd be nice to be able to do in-place operations for that class.

Thanks,
Felipe.

PS: I looked at Allocated Memory because running times don't seem to change much unless we hit the virtual memory wall.</description>
		<content:encoded><![CDATA[<p>Loren,</p>
<p>any prospects for cellfun supporting in-place operations, please?</p>
<p>For example, given your demo</p>
<p>    function inplaceTest(x)<br />
    % Call functions with either regular or in-place semantics.<br />
    %% Call a Regular Function with the Same Left-Hand Side<br />
    x = myfunc(x);<br />
    %% Call an In-place Function with the Same Left-Hand Side<br />
    x = myfuncIP(x);<br />
    %% Call a Regular Function with a Different Left-Hand Side<br />
    y = myfunc(x);</p>
<p>if I modify the functions as follows</p>
<p>    function y = myfunc(x)<br />
    y = cellfun(@uminus, x, &#8216;UniformOutput&#8217;,false);<br />
    function x = myfuncIP(x)<br />
    x = cellfun(@uminus, x, &#8216;UniformOutput&#8217;,false);</p>
<p>then memory profile it:</p>
<p>    n = 7*2^20;<br />
    x = randn(n,1);<br />
    x = {x};<br />
    profile -memory on<br />
    inplaceTest(x)<br />
    profile viewer</p>
<p>looking under inplaceTest, you can notice Allocated Memory has the same large value (57358.45 Kb) for myfunc and myfuncIP.</p>
<p>In contrast, if I don&#8217;t use cellfun in the functions,</p>
<p>    function y = myfunc(x)<br />
    y = -x;<br />
    function x = myfuncIP(x)<br />
    x = -x;</p>
<p>then after memory profiling it</p>
<p>    n = 7*2^20;<br />
    x = randn(n,1);<br />
    profile -memory on<br />
    inplaceTest(x)<br />
    profile viewer</p>
<p>then you&#8217;ll see negligible Allocated Memory for the in-place call, as expected.</p>
<p>I have a class that uses cell arrays to store its data, and its operators are all implemented using cellfun; it&#8217;d be nice to be able to do in-place operations for that class.</p>
<p>Thanks,<br />
Felipe.</p>
<p>PS: I looked at Allocated Memory because running times don&#8217;t seem to change much unless we hit the virtual memory wall.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-28809</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 05 May 2008 17:56:10 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/#comment-28809</guid>
		<description>Jonathan-

The behavior you see is because the variable x has to come into inplaceTest and then a copy is made so nothing bad happens to the copy in the base workspace.  Instead, create the initial x inside inplacedTest so the variable creation is locked down as well.  I urge you to run my example from the initial post exactly as I wrote it.  If you are on Windows, use the task manager and you will convince yourself there is no extra copying being done, even when you update it and use myfuncIP2.

--Loren</description>
		<content:encoded><![CDATA[<p>Jonathan-</p>
<p>The behavior you see is because the variable x has to come into inplaceTest and then a copy is made so nothing bad happens to the copy in the base workspace.  Instead, create the initial x inside inplacedTest so the variable creation is locked down as well.  I urge you to run my example from the initial post exactly as I wrote it.  If you are on Windows, use the task manager and you will convince yourself there is no extra copying being done, even when you update it and use myfuncIP2.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
</channel>
</rss>
