<?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: Scalar Expansion and More</title>
	<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/</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>Mon, 23 Nov 2009 01:09:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: StephenLL</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-30271</link>
		<dc:creator>StephenLL</dc:creator>
		<pubDate>Tue, 05 May 2009 15:04:55 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-30271</guid>
		<description>You can also check out my _apply_ function at the FEX.

http://www.mathworks.com/matlabcentral/fileexchange/16467

While it doesn't speed anything up, it makes the code somewhat cleaner.  I wish the mathworks would add something like this to base MATLAB.

Stephen</description>
		<content:encoded><![CDATA[<p>You can also check out my _apply_ function at the FEX.</p>
<p><a href="http://www.mathworks.com/matlabcentral/fileexchange/16467" rel="nofollow">http://www.mathworks.com/matlabcentral/fileexchange/16467</a></p>
<p>While it doesn&#8217;t speed anything up, it makes the code somewhat cleaner.  I wish the mathworks would add something like this to base MATLAB.</p>
<p>Stephen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-30269</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 04 May 2009 11:23:57 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-30269</guid>
		<description>Everett-

Many MATLAB functions already work on columns of an array or can work on a selected dimension (see help for max, for example).  

--Loren</description>
		<content:encoded><![CDATA[<p>Everett-</p>
<p>Many MATLAB functions already work on columns of an array or can work on a selected dimension (see help for max, for example).  </p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Everett</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-30267</link>
		<dc:creator>Everett</dc:creator>
		<pubDate>Sun, 03 May 2009 15:17:29 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-30267</guid>
		<description>Hi, Loren,

How to apply a function to each row of a matrix with out using the for loop?

Thanks,
Everett</description>
		<content:encoded><![CDATA[<p>Hi, Loren,</p>
<p>How to apply a function to each row of a matrix with out using the for loop?</p>
<p>Thanks,<br />
Everett</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-29873</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 18 Nov 2008 18:08:49 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-29873</guid>
		<description>Tom-

See the function &lt;a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bsxfun.html" rel="nofollow"&gt;bsxfun&lt;/a&gt; for other scalar expansion functionality.

--Loren</description>
		<content:encoded><![CDATA[<p>Tom-</p>
<p>See the function <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bsxfun.html" rel="nofollow">bsxfun</a> for other scalar expansion functionality.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Clark</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-29872</link>
		<dc:creator>Tom Clark</dc:creator>
		<pubDate>Tue, 18 Nov 2008 18:04:59 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-29872</guid>
		<description>Loren,

Ah ha! I can't believe I've been using MATLAB in anger, daily, for years now - and hadn't figured out the outer product.

God bless you, this just saved me 586,000 seconds... And then the rest!

Tom</description>
		<content:encoded><![CDATA[<p>Loren,</p>
<p>Ah ha! I can&#8217;t believe I&#8217;ve been using MATLAB in anger, daily, for years now - and hadn&#8217;t figured out the outer product.</p>
<p>God bless you, this just saved me 586,000 seconds&#8230; And then the rest!</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Melchi</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-28225</link>
		<dc:creator>Melchi</dc:creator>
		<pubDate>Wed, 09 Apr 2008 23:36:19 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-28225</guid>
		<description>Regarding "How to Add [or multiply] Constant Values to Each Column of a Matrix." This bothered me for a long time. I used to use what Loren calls "Tony's Method" (both versions) for a while but got frustrated with it because of the performance hit for large matrices. Though I found the repmat method to be faster than looping, I couldn't get over the fact that I was doing so many extra additions (or multiplications). Finally, I  wrote a few mex functions (e.g., rowmult(cVec,Matrix), colmult(rVec,Matrix), etc.) that calculate these directly. These are really basic operations that I use so often that I'm really shocked that they aren't built in to Matlab. While it might be nice to eventually come up with some operators to represent these functions, I think it's more important that efficient functions implementing these operations be included even if only in functional form.</description>
		<content:encoded><![CDATA[<p>Regarding &#8220;How to Add [or multiply] Constant Values to Each Column of a Matrix.&#8221; This bothered me for a long time. I used to use what Loren calls &#8220;Tony&#8217;s Method&#8221; (both versions) for a while but got frustrated with it because of the performance hit for large matrices. Though I found the repmat method to be faster than looping, I couldn&#8217;t get over the fact that I was doing so many extra additions (or multiplications). Finally, I  wrote a few mex functions (e.g., rowmult(cVec,Matrix), colmult(rVec,Matrix), etc.) that calculate these directly. These are really basic operations that I use so often that I&#8217;m really shocked that they aren&#8217;t built in to Matlab. While it might be nice to eventually come up with some operators to represent these functions, I think it&#8217;s more important that efficient functions implementing these operations be included even if only in functional form.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-25295</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 24 Jan 2008 12:22:25 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-25295</guid>
		<description>Peter-

I don't know what you are trying to calculate. Are the columns year, month, and number.  You'd probably be best off reshaping your array into a 3-dimensional array and summing along the correct dimension(s) then.

--Loren</description>
		<content:encoded><![CDATA[<p>Peter-</p>
<p>I don&#8217;t know what you are trying to calculate. Are the columns year, month, and number.  You&#8217;d probably be best off reshaping your array into a 3-dimensional array and summing along the correct dimension(s) then.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Maclean</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-25271</link>
		<dc:creator>Peter Maclean</dc:creator>
		<pubDate>Wed, 23 Jan 2008 22:10:16 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-25271</guid>
		<description>How to calculate a cummulative sum of a matrix over over a given varible. Example, how I calculate year totals from monthly total. The data set look like

Country month Temp
1        1     10
.        .      .
1        12     12
2        1     60
.        .      . 
2        12     72</description>
		<content:encoded><![CDATA[<p>How to calculate a cummulative sum of a matrix over over a given varible. Example, how I calculate year totals from monthly total. The data set look like</p>
<p>Country month Temp<br />
1        1     10<br />
.        .      .<br />
1        12     12<br />
2        1     60<br />
.        .      .<br />
2        12     72</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Newman</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-16444</link>
		<dc:creator>Lee Newman</dc:creator>
		<pubDate>Fri, 31 Aug 2007 04:07:09 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-16444</guid>
		<description>I've recently switched from Mathematica to Matlab as my primary programming tool, primarily because Matlab was orders of magnitude faster for my purposes (self organizing neural networks).  However, I do think that Matlab developers ought to consider the way Mathematica "vectorizes".  Almost every function when given a N-D matrix performs its operations row-wise and via the various "functional programming" functions (Map, MapAt, MapThread, Apply, etc) which allow the coder to control exactly how, and at what level,  functions operate on data structures.  I've found it takes many more lines of code to vectorize in Matlab. Perhaps it's due to my relative lack of familiarity with Matlab, but I do think Matlab might benefit by incorporating some of the vectorization methods from Mathematica.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve recently switched from Mathematica to Matlab as my primary programming tool, primarily because Matlab was orders of magnitude faster for my purposes (self organizing neural networks).  However, I do think that Matlab developers ought to consider the way Mathematica &#8220;vectorizes&#8221;.  Almost every function when given a N-D matrix performs its operations row-wise and via the various &#8220;functional programming&#8221; functions (Map, MapAt, MapThread, Apply, etc) which allow the coder to control exactly how, and at what level,  functions operate on data structures.  I&#8217;ve found it takes many more lines of code to vectorize in Matlab. Perhaps it&#8217;s due to my relative lack of familiarity with Matlab, but I do think Matlab might benefit by incorporating some of the vectorization methods from Mathematica.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-78</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Tue, 14 Mar 2006 15:02:11 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/02/22/scalar-expansion-and-more-take-2/#comment-78</guid>
		<description>I did a quick comparison of Doug's matlab only code vs c code versions of the genops for @plus and I'm seeing the matlab code version take 35 times longer to run then the c code version.

I appreciate having both around, but I'd like to have function handles be passed to the c version. Unfortunately I know making genop have the same flexibility of cellfun, arrayfun, etc... is well beyond what I can handle in mex functions.  If the source code for the ones already in matlab were available maybe we can make it a community project to create a gopfun mex function.

Stephen</description>
		<content:encoded><![CDATA[<p>I did a quick comparison of Doug&#8217;s matlab only code vs c code versions of the genops for @plus and I&#8217;m seeing the matlab code version take 35 times longer to run then the c code version.</p>
<p>I appreciate having both around, but I&#8217;d like to have function handles be passed to the c version. Unfortunately I know making genop have the same flexibility of cellfun, arrayfun, etc&#8230; is well beyond what I can handle in mex functions.  If the source code for the ones already in matlab were available maybe we can make it a community project to create a gopfun mex function.</p>
<p>Stephen</p>
]]></content:encoded>
	</item>
</channel>
</rss>
