<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Comparing repmat and bsxfun Performance</title>
	<atom:link href="http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Jason</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32411</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Thu, 04 Aug 2011 18:15:52 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32411</guid>
		<description>As far as readability goes, what about a new operator?

In MATLAB we are used to the difference between * and .*, why not something like that for bsx?  I can&#039;t think of what would be a good symbol to use...  Maybe the question mark?  Lexically, it might suggest &quot;hopefully my dims will expand&quot;...

a +? b

Of course it won&#039;t work in all cases, but at least it makes the simple arithmetic (and maybe logical?) ones more readable.</description>
		<content:encoded><![CDATA[<p>As far as readability goes, what about a new operator?</p>
<p>In MATLAB we are used to the difference between * and .*, why not something like that for bsx?  I can&#8217;t think of what would be a good symbol to use&#8230;  Maybe the question mark?  Lexically, it might suggest &#8220;hopefully my dims will expand&#8221;&#8230;</p>
<p>a +? b</p>
<p>Of course it won&#8217;t work in all cases, but at least it makes the simple arithmetic (and maybe logical?) ones more readable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32382</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Tue, 12 Jul 2011 21:48:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32382</guid>
		<description>Loren,

I further tried

&lt;pre&gt;
    x = 1:10;
    y = 1:20;
    z = bsxfun(@mytimes, x, y&#039;);
&lt;/pre&gt;

This time, there is no error message and I got to my breakpoint in the mytimes function.

Thank you,
Ben</description>
		<content:encoded><![CDATA[<p>Loren,</p>
<p>I further tried</p>
<pre>
    x = 1:10;
    y = 1:20;
    z = bsxfun(@mytimes, x, y');
</pre>
<p>This time, there is no error message and I got to my breakpoint in the mytimes function.</p>
<p>Thank you,<br />
Ben</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32381</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Tue, 12 Jul 2011 21:36:29 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32381</guid>
		<description>Hi Loren,

I also tried using a self-defined function called mytimes.

&lt;pre&gt;
Q = bsxfun(@mtimes, V, MM);
&lt;/pre&gt;

where the mytimes function is

Hi Loren,

I also tried using a self-defined function called mytimes.

&lt;pre&gt;
function out = mytimes(v,m)

out = v * m;
&lt;/pre&gt;

I set breakpoint in mytimes function, but again got error message without call mytimes function.

Could you provide a example of using cells?

Thank you very much!
Ben</description>
		<content:encoded><![CDATA[<p>Hi Loren,</p>
<p>I also tried using a self-defined function called mytimes.</p>
<pre>
Q = bsxfun(@mtimes, V, MM);
</pre>
<p>where the mytimes function is</p>
<p>Hi Loren,</p>
<p>I also tried using a self-defined function called mytimes.</p>
<pre>
function out = mytimes(v,m)

out = v * m;
</pre>
<p>I set breakpoint in mytimes function, but again got error message without call mytimes function.</p>
<p>Could you provide a example of using cells?</p>
<p>Thank you very much!<br />
Ben</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32380</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 12 Jul 2011 20:33:37 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32380</guid>
		<description>Ben-

bsxfun does support cells, but the operator mtimes does not.   The function being called by bsxfun would have to know how to work with cell arrays.

--Loren</description>
		<content:encoded><![CDATA[<p>Ben-</p>
<p>bsxfun does support cells, but the operator mtimes does not.   The function being called by bsxfun would have to know how to work with cell arrays.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32379</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Tue, 12 Jul 2011 20:30:42 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32379</guid>
		<description>Hi Loren,

I am trying to run the following code where V and MM are two cells.

&lt;pre&gt;
Q = bsxfun(@mtimes, V, MM);
&lt;/pre&gt;

In Matlab document, it is said &quot;The inputs must be of the following types: numeric, logical, char, struct, cell.&quot;  But I got error message:

Error using bsxfun
Operands must be numeric arrays.

Does bsxfun not support cell or I made something wrong?  Thanks a lot for your help in advance.

Best,
Ben</description>
		<content:encoded><![CDATA[<p>Hi Loren,</p>
<p>I am trying to run the following code where V and MM are two cells.</p>
<pre>
Q = bsxfun(@mtimes, V, MM);
</pre>
<p>In Matlab document, it is said &#8220;The inputs must be of the following types: numeric, logical, char, struct, cell.&#8221;  But I got error message:</p>
<p>Error using bsxfun<br />
Operands must be numeric arrays.</p>
<p>Does bsxfun not support cell or I made something wrong?  Thanks a lot for your help in advance.</p>
<p>Best,<br />
Ben</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cris Luengo</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32343</link>
		<dc:creator>Cris Luengo</dc:creator>
		<pubDate>Thu, 23 Jun 2011 09:03:52 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32343</guid>
		<description>Loren,

I see what you mean, with bad code producing answers instead of error messages. Adding a long Nx1 array with a 1xN array would give a huge NxN matrix, instead of a simple &quot;what are you doing?&quot; message. Changing something as basic as this should definitely not be taken lightly! But at least it wouldn&#039;t change the meaning of existing code.

I was pointed at a language called Yorick some days ago. It has some very crazy, but interesting, ideas on indexing: http://yorick.sourceforge.net/manual/yorick_37.php#SEC37
Note especially the &quot;*&quot; and &quot;..&quot; rubber indexing. Again something I would have used extensively if it had been available in MATLAB! :)

Best,
Cris.</description>
		<content:encoded><![CDATA[<p>Loren,</p>
<p>I see what you mean, with bad code producing answers instead of error messages. Adding a long Nx1 array with a 1xN array would give a huge NxN matrix, instead of a simple &#8220;what are you doing?&#8221; message. Changing something as basic as this should definitely not be taken lightly! But at least it wouldn&#8217;t change the meaning of existing code.</p>
<p>I was pointed at a language called Yorick some days ago. It has some very crazy, but interesting, ideas on indexing: <a href="http://yorick.sourceforge.net/manual/yorick_37.php#SEC37" rel="nofollow">http://yorick.sourceforge.net/manual/yorick_37.php#SEC37</a><br />
Note especially the &#8220;*&#8221; and &#8220;..&#8221; rubber indexing. Again something I would have used extensively if it had been available in MATLAB! :)</p>
<p>Best,<br />
Cris.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32337</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 20 Jun 2011 15:00:29 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32337</guid>
		<description>Cris-

I want to echo Steve&#039;s comments.  I am all for it as well.  Just need to find the right path through.

--Loren</description>
		<content:encoded><![CDATA[<p>Cris-</p>
<p>I want to echo Steve&#8217;s comments.  I am all for it as well.  Just need to find the right path through.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Eddins</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32335</link>
		<dc:creator>Steve Eddins</dc:creator>
		<pubDate>Mon, 20 Jun 2011 12:52:43 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32335</guid>
		<description>Cris&#8212;Personally, I would like to see us make the change you recommend.</description>
		<content:encoded><![CDATA[<p>Cris&mdash;Personally, I would like to see us make the change you recommend.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32333</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 20 Jun 2011 12:12:04 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32333</guid>
		<description>Cris-

We are worried about compatibility and making debugging very difficult for users since more expressions will get answers when users didn&#039;t mean to write what they wrote.

--Loren</description>
		<content:encoded><![CDATA[<p>Cris-</p>
<p>We are worried about compatibility and making debugging very difficult for users since more expressions will get answers when users didn&#8217;t mean to write what they wrote.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cris Luengo</title>
		<link>http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32329</link>
		<dc:creator>Cris Luengo</dc:creator>
		<pubDate>Mon, 20 Jun 2011 09:16:27 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/08/04/comparing-repmat-and-bsxfun-performance/#comment-32329</guid>
		<description>Hi Loren,

I was thinking, what is the reason for implementing the &#124;bsxfun&#124; function, and not making the singleton expansion the default behavior for all operators? MATLAB has always done singleton expansion in the case of a scalar value (i.e. all dimensions are singleton): &#124;A+4&#124; is the same as &#124;A+repmat(4,size(A))&#124;. Is there any conceivable problem that could arise if MATLAB were to always expand any singleton dimensions? I would love to be able to do &#124;A-mean(A)&#124;! I&#039;ve been thinking about this for a while now, and I can&#039;t come up with a scenario where this would backfire.

Cheers,
Cris.</description>
		<content:encoded><![CDATA[<p>Hi Loren,</p>
<p>I was thinking, what is the reason for implementing the |bsxfun| function, and not making the singleton expansion the default behavior for all operators? MATLAB has always done singleton expansion in the case of a scalar value (i.e. all dimensions are singleton): |A+4| is the same as |A+repmat(4,size(A))|. Is there any conceivable problem that could arise if MATLAB were to always expand any singleton dimensions? I would love to be able to do |A-mean(A)|! I&#8217;ve been thinking about this for a while now, and I can&#8217;t come up with a scenario where this would backfire.</p>
<p>Cheers,<br />
Cris.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

