<?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: Speeding-up builtin Matlab functions – part 3	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/speeding-up-builtin-matlab-functions-part-3/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/speeding-up-builtin-matlab-functions-part-3?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=speeding-up-builtin-matlab-functions-part-3</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Mon, 17 Aug 2020 08:29:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Jan		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-builtin-matlab-functions-part-3#comment-508738</link>

		<dc:creator><![CDATA[Jan]]></dc:creator>
		<pubDate>Thu, 25 Jun 2020 21:55:06 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=11059#comment-508738</guid>

					<description><![CDATA[The sad thing is that only old functions can be delved into like that. Many new functions or classes are hidden in p-code encrypted files which is a bummer. Plus they are sealed (in case of classes), so it&#039;s quite complicated to expand or improve their functionality/performance. 

This is one of the reasons we&#039;re looking for alternatives like python or Julia. 

Don&#039;t get me wrong, it&#039;s not about the price, we&#039;re happy to pay for functionality and documentation. 
But not if the trend is to make things more and more unaccessible]]></description>
			<content:encoded><![CDATA[<p>The sad thing is that only old functions can be delved into like that. Many new functions or classes are hidden in p-code encrypted files which is a bummer. Plus they are sealed (in case of classes), so it&#8217;s quite complicated to expand or improve their functionality/performance. </p>
<p>This is one of the reasons we&#8217;re looking for alternatives like python or Julia. </p>
<p>Don&#8217;t get me wrong, it&#8217;s not about the price, we&#8217;re happy to pay for functionality and documentation.<br />
But not if the trend is to make things more and more unaccessible</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Adam Langer		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-builtin-matlab-functions-part-3#comment-508729</link>

		<dc:creator><![CDATA[Adam Langer]]></dc:creator>
		<pubDate>Tue, 16 Jun 2020 21:41:06 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=11059#comment-508729</guid>

					<description><![CDATA[Hi Yair, 

I had no doubt you would find other ways to keep busy if you were not heading to the States this spring. 

It will only make a small difference since in your example this line of code is not called as often, but in &quot;Main Loop - Bottom Part&quot; you can eliminate the repetitive call to &lt;code&gt;sqrt()&lt;/code&gt; in the inner for loop by precalculating it: 

&lt;pre lang=&quot;matlab&quot;&gt;
TWO_PI = 2*pi;
SQRT_TWO_PI = sqrt(TWO_PI); 
...
                elseif isKernelNormal
                    fk = exp(-0.5 * (z.*z)) ./ SQRT_TWO_PI);
&lt;/pre&gt;

If I understand your final profile viewer screenshot showing the 13 seconds, the non-vectorized branch under if any(nearby) gets called around 300K times, which looks like 300K calls to sqrt(). This speedup won&#039;t show up in your profiler results (that line is even in the top results now), but it&#039;s another easy speedup some folks may overlook. 

In the common case I see that you cleverly avoid using &lt;code&gt;sqrt()&lt;/code&gt; at all by instead dividing by TWO_PI at the end of the snippet. 

Stay healthy and safe.]]></description>
			<content:encoded><![CDATA[<p>Hi Yair, </p>
<p>I had no doubt you would find other ways to keep busy if you were not heading to the States this spring. </p>
<p>It will only make a small difference since in your example this line of code is not called as often, but in &#8220;Main Loop &#8211; Bottom Part&#8221; you can eliminate the repetitive call to <code>sqrt()</code> in the inner for loop by precalculating it: </p>
<pre lang="matlab">
TWO_PI = 2*pi;
SQRT_TWO_PI = sqrt(TWO_PI); 
...
                elseif isKernelNormal
                    fk = exp(-0.5 * (z.*z)) ./ SQRT_TWO_PI);
</pre>
<p>If I understand your final profile viewer screenshot showing the 13 seconds, the non-vectorized branch under if any(nearby) gets called around 300K times, which looks like 300K calls to sqrt(). This speedup won&#8217;t show up in your profiler results (that line is even in the top results now), but it&#8217;s another easy speedup some folks may overlook. </p>
<p>In the common case I see that you cleverly avoid using <code>sqrt()</code> at all by instead dividing by TWO_PI at the end of the snippet. </p>
<p>Stay healthy and safe.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Loren Shure		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-builtin-matlab-functions-part-3#comment-508423</link>

		<dc:creator><![CDATA[Loren Shure]]></dc:creator>
		<pubDate>Fri, 10 Apr 2020 12:48:49 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=11059#comment-508423</guid>

					<description><![CDATA[Hi Yair-

Very nice example showing people how to delve in - plus a nice heads up for us to always go back and look at our shipping code.  Probably feval was the only option for evaluation at the time the functionality was first introduced.  But I&#039;m only guessing.

Hag Sameach and take care!
--loren]]></description>
			<content:encoded><![CDATA[<p>Hi Yair-</p>
<p>Very nice example showing people how to delve in &#8211; plus a nice heads up for us to always go back and look at our shipping code.  Probably feval was the only option for evaluation at the time the functionality was first introduced.  But I&#8217;m only guessing.</p>
<p>Hag Sameach and take care!<br />
&#8211;loren</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michelle Hirsch		</title>
		<link>https://undocumentedmatlab.com/articles/speeding-up-builtin-matlab-functions-part-3#comment-508396</link>

		<dc:creator><![CDATA[Michelle Hirsch]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 19:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=11059#comment-508396</guid>

					<description><![CDATA[Thanks Yair, as always, for the thoughtful post. I&#039;ve forwarded it to the folks from both the Statistics team and the Performance team for their input. Happy Pesach!]]></description>
			<content:encoded><![CDATA[<p>Thanks Yair, as always, for the thoughtful post. I&#8217;ve forwarded it to the folks from both the Statistics team and the Performance team for their input. Happy Pesach!</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
