<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The ILNumerics Blog &#187; Usage</title>
	<atom:link href="https://ilnumerics.net/blog/category/usage/feed/" rel="self" type="application/rss+xml" />
	<link>https://ilnumerics.net/blog</link>
	<description>The Productivity Machine  &#124;  A fresh attempt for scientific computing  &#124;  http://ilnumerics.net</description>
	<lastBuildDate>Thu, 05 Dec 2024 09:09:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Release Notes ILNumerics 4.13 (detailed)</title>
		<link>https://ilnumerics.net/blog/release-notes-ilnumerics-4-13-detailed/</link>
		<comments>https://ilnumerics.net/blog/release-notes-ilnumerics-4-13-detailed/#comments</comments>
		<pubDate>Wed, 03 May 2017 10:27:07 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[4.13]]></category>
		<category><![CDATA[changelog]]></category>
		<category><![CDATA[release notes]]></category>
		<category><![CDATA[usage]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=985</guid>
		<description><![CDATA[<p>See this changelog for a quick list of all changes in version 4.13. Here we dive into some details about specific topics. Visualization Engine Improvements The main goal of the GDI renderer is still to provide a fully compatible alternative to the OpenGL renderer. It automatically replaces the OpenGL default renderer if a problem / &#8230; <a href="https://ilnumerics.net/blog/release-notes-ilnumerics-4-13-detailed/" class="more-link">Continue reading <span class="screen-reader-text">Release Notes ILNumerics 4.13 (detailed)</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/release-notes-ilnumerics-4-13-detailed/">Release Notes ILNumerics 4.13 (detailed)</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>See this <a title="Changelog &amp; Release Notes" href="https://ilnumerics.net/changelog.html">changelog</a> for a quick list of all changes in version 4.13. Here we dive into some details about specific topics.</p>
<h2>Visualization Engine Improvements</h2>
<p>The main goal of the <strong>GDI renderer</strong> is still to provide a fully compatible alternative to the OpenGL renderer. It automatically replaces the OpenGL default renderer if a problem / incompatible hardware etc. was detected at runtime. The focus lays on feature completeness and precision of the rendering result. The quality of the GDI renderer has been further improved to these regards in 4.13. Changes affect the following low level rendering features.</p>
<h3>Antialiasing</h3>
<p>Lines now recognize the <span class="il_inlinecode">ILLines.Antialiasing</span> property for thick lines (Width &gt; 2). The antialised rendering works in all situations: transparent lines, lines with stipple patterns, inside /outside of plot cubes and for logartithmic / linear axis scales. The quality of the antialiasing implementation is now on par with common OpenGL implementations.</p>
<p><em>The new default value for </em><span class="il_inlinecode">ILLines.Antialiasing</span><em> is now </em><strong><span class="il_inlinecode">true</span></strong><em>.</em> However, thin lines would not profit from antialiasing, hence thin lines will continue to ignore the value of the <span class="il_inlinecode">ILLines.Antialiasing</span> property.</p>
<p>Note, that some OpenGL drivers actually refuse to render certain combinations of line properties. We experienced such behavior for stippled, thick line <em>strips</em> having antialiased rendering configured. In such situations you should make sure to have the most recent OpenGL / graphics card drivers installed. Alternatively you may chose either stippled pattern &#8211; / <em>or </em>antialiased rendering by explicitly configuring your lines for either one setting. Or use the GDI renderer instead.</p>
<p>Following is a screenshot of some lines examples. The left side shows the OpenGL renderer result. On the right side the GDI version is shown. Use your browser to show the full, unscaled image (right click on the image):</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2017/04/LinesAntialiasingGDIversOpenGL413.png"><img class="aligncenter size-full wp-image-991" src="http://ilnumerics.net/blog/wp-content/uploads/2017/04/LinesAntialiasingGDIversOpenGL413.png" alt="LinesAntialiasingGDIversOpenGL413" width="880" height="454" /></a>&#8230; and with dotted lines:<a href="http://ilnumerics.net/blog/wp-content/uploads/2017/04/DottedLinesAntialiasingGDIversOpenGL413.png"><img class="aligncenter size-full wp-image-992" src="http://ilnumerics.net/blog/wp-content/uploads/2017/04/DottedLinesAntialiasingGDIversOpenGL413.png" alt="DottedLinesAntialiasingGDIversOpenGL413" width="882" height="453" /></a></p>
<p>&nbsp;</p>
<h3>Default Color for ILLines &amp; ILLineStrip</h3>
<p>Basic, low level line shapes are now created with a default color: black. Higher level objects (as ILLinePlot, ILSplinePlot, Markers, ILSurface etc.) should always provide a color for low-level objects or use vertex based coloring explicitly. If you are assembling your scene with the low level line objects make sure to check that you have done this. This is not a breaking change.</p>
<p>Note that the setting for the shapes <span class="il_inlinecode">Color</span> property overrides the vertex colors buffer (<span class="il_inlinecode">Color<strong>s</strong></span> property). In order to use vertex based coloring one must set the <span class="il_inlinecode">Color</span> property to null, enabling the colors information from the Colors buffer.</p>
<h3>Auto Color for Spline Plots</h3>
<p>ILSplinePlot (derived from ILLinePlot) now adopts the auto-coloring feature from the ILLinePlot class. When no line color was given at the time the plot was created the color gets assigned which comes next in the <span class="il_inlinecode">ILLinePlot.NextColor</span> color enumeration. Use the <span class="il_inlinecode">linecolor</span> constructor argument of <span class="il_inlinecode">ILSplinePlot</span> or the <span class="il_inlinecode">Line.Color</span> property in order to control the color of the spline line explicitly.</p>
<h3>Camera Default Depth: 100</h3>
<p>In earlier versions the default <span class="il_inlinecode">ILCamera.ZFar</span> value was 1000 which led to depth buffer precision issues in some situations. The new default value of 100 increases the depth buffer precision significantly. However, the new value (just like the old one) does not take into account the actual depth of your scene! If you encounter unwanted clipping in the far clippping area now, set the value for scene.Camera.ZFar explicitly. At best you know the depth of your scene and use this value. Or &#8211; more simple &#8211; use the old default of 1000:</p>
<pre class="brush: csharp; title: ; notranslate"> scene.Camera.ZFar = 1000; </pre>
<h2>Visual Studio 2017 Compatibility</h2>
<p>With the new version ILNumerics installs into the great, fresh new Visual Studio 2017 (released March 2017). &#8230; well, at least &#8216;kind of&#8217;&#8230;  What is true is that with 4.13 you can again use ILNumerics in all recent Visual Studio editions supporting extensions at all (which is all editions except Express Edition &#8211; I wonder if anyone is using this, still??), including Visual Studio 2017 Community Edition. This is great and all &#8230; <strong><em>but</em></strong>:</p>
<p>As you noticed there was a great deal of changes coming with VS2017. This includes the installer system which is &#8211; great attempt! &#8211; much more slim now by omitting unneeded stuff from the installation. But VS2017 also requires changes to the manifest files facilitating every Visual Studio Extensibility project. A new version has been introduced: version3. This is the first version which is not compatible with Visual Studio 2010 anymore. As a consequence, by supporting the new extension packaging system we would be required to drop support for Visual Studio 2010. This is not too dramatic since the 6 years VS2010 is out now feel kind of an eternity in our dev-world. However, we wanted to give the remaining VS2010 customers at least one version iteration of deprecating VS2010 in order to jump to a more recent version smoothly.</p>
<p>Additionally, the way the new VS installer works seems to reflect not the last word spoken on that topic (at least this is what we hope). The bottom line: we use an MSI installer, wrapped in an exe bootstrapper. The MSI installs all GAC binaries, registers the development dlls in Visual Studio, maintains the singleton installation directory and triggers the VSIX installer which installs the extension into all supported Visual Studio installations located on the system. This may sound complicated but worked quite reliably over the years.</p>
<p>Now, with the new Visual Studio package system things become odd. Out of subtle reasons, the MSI cannot (reliably) trigger the VSIX package automatically (and quietly). The <a href="http://stackoverflow.com/a/42278790/1215993">reason </a>becomes obvious when considering that the new extension potentially needs to trigger the installation of new components which it depends on. This install would not be possible while the hosting MSI is being installed itself still. So, as a consequence, currently, MSI installs of VSIX extensions into VS2017 are simply not working. When you start the ILNumerics installation from the delivered *.exe you will find the extension being installed into VS2010 and upwards &#8211; with the exception of Visual Studio 2017 <img src="https://ilnumerics.net/blog/wp-includes/images/smilies/icon_sad.gif" alt=":(" class="wp-smiley" /></p>
<p>Currently, some smart (WIX) people are attempting a solution to this. But we are not aware of a clean solution released already. Therefore, we will wait for it and/or eventually consider a new deployment scheme for our extensions.</p>
<p>However, luckily there is a simple workaround for now! After the ILNumerics installation was finished, you can easily install our extension into VS2017 manually. Just go to the installation folder (by default: C:\Program Files (x86)\ILNumerics\ILNumerics Ultimate VS\bin) and find the &#8216;ILNumerics.VSExtension.vsix&#8217; file. Double click on it to start the installation into the remaining Visual Studio instances manually. This should work without problems. Be sure to accept the warning dialog during the install. It originates from the fact that our extension must still support older Visual Studio extension techniques.</p>
<p>Keep in mind that this is a workaround, though! Once installed the extension will work as expected. But some things will not work consistentyl. Deinstallation, for example must be done manually from the &#8220;Extensions and Tools&#8221; dialog within Visual Studio 2017:</p>
<figure id="attachment_986" style="width: 954px;" class="wp-caption aligncenter"><a href="http://ilnumerics.net/blog/wp-content/uploads/2017/04/Deinstall-2017-Extensions-and-Updates.png"><img class="size-full wp-image-986" src="http://ilnumerics.net/blog/wp-content/uploads/2017/04/Deinstall-2017-Extensions-and-Updates.png" alt="A manually installed extension requires a manual uninstall." width="954" height="659" /></a><figcaption class="wp-caption-text">A manually installed extension requires a manual uninstall.</figcaption></figure>
<p>Also, in difference to the machine wide installation done by the (administrative) MSI install the manual VSIX installation changes the local user account only. You may have to repeat the VSIX install for other user accounts. Besides these lowered installation experience we know of no other incompatibilities in Visual Studio 2017. </p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/release-notes-ilnumerics-4-13-detailed/">Release Notes ILNumerics 4.13 (detailed)</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/release-notes-ilnumerics-4-13-detailed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>N-dim Array Broadcasting Efficiency in ILNumerics 4.10</title>
		<link>https://ilnumerics.net/blog/n-dim-array-broadcasting-efficiency-in-ilnumerics-4-10/</link>
		<comments>https://ilnumerics.net/blog/n-dim-array-broadcasting-efficiency-in-ilnumerics-4-10/#comments</comments>
		<pubDate>Sun, 01 May 2016 09:47:13 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Scientific Computing]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[Broadcasting]]></category>
		<category><![CDATA[computing]]></category>
		<category><![CDATA[vectorization]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=915</guid>
		<description><![CDATA[<p>Next to other great improvements in version 4.10 of ILNumerics Ultimate VS, it is especially one new feature which requires some attention: general broadcasting for n-dimensional ILArrays. Broadcasting as a concept today is found in many popular mathematical prototyping systems. The most direct correspondence probably exists in the numpy package. Matlab and Octave offer similar &#8230; <a href="https://ilnumerics.net/blog/n-dim-array-broadcasting-efficiency-in-ilnumerics-4-10/" class="more-link">Continue reading <span class="screen-reader-text">N-dim Array Broadcasting Efficiency in ILNumerics 4.10</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/n-dim-array-broadcasting-efficiency-in-ilnumerics-4-10/">N-dim Array Broadcasting Efficiency in ILNumerics 4.10</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Next to other great improvements in version 4.10 of ILNumerics Ultimate VS, it is especially one new feature which requires some attention: general broadcasting for n-dimensional ILArrays.</p>
<p>Broadcasting as a concept today is found in many popular mathematical prototyping systems. The most direct correspondence probably exists in the <a href="http://docs.scipy.org/doc/numpy-1.10.1/user/basics.broadcasting.html">numpy </a>package. Matlab and Octave offer similar functionality by means of the <a href="http://de.mathworks.com/help/matlab/ref/bsxfun.html">bsxfun function</a>.</p>
<p>The term &#8216;broadcasting&#8217; refers to a binary operator which is able to apply an elementwise operation to the elements of two n-dimensional arrays. The &#8216;operation&#8217; is often as simple as a straight addition (ILMath.add, ILMath.divide, a.s.o.). However, what is special about broadcasting is that it allows the operation even for the case where both arrays involved do not have the same number of elements.</p>
<h2>Broadcasting in ILNumerics prior Version 4.10</h2>
<p>In ILNumerics, broadcasting is available for long already. But prior version 4.10 it was limited to scalars operating on n-dim arrays and vectors operating on matrices. Therefore, we had used the term &#8216;vector expansion&#8217; instead of broadcasting. Obviously, broadcasting can be seen as a generalization of vector expansion.</p>
<p>Let&#8217;s visualize the concept by considering the following matrix A:</p>
<pre class="brush: csharp; title: ; notranslate">
A

1  5   9  13  17
2  6  10  14  18
3  7  11  15  19
4  8  12  16  20
</pre>
<p>Matrix A might represent 5 data points of a 4 dimensional dataset as columns. One common requirement is to apply a certain operation to all datapoints in a similar way. In order to, let&#8217;s say, scale/weight the components of each dimension by a certain factor, one would multiply each datapoint with a vector of length 4.</p>
<pre class="brush: csharp; title: ; notranslate">

ILArray&lt;double&gt; V = new[] { 0.5, 3.0, 0.5, 1.0 };

0.5
3.0
0.5
1.0
</pre>
<p>The traditional way of implementing this operation would be to expand the scaling vector by replicating it from a single column to a matrix matching the size of A.</p>
<pre class="brush: csharp; title: ; notranslate">
VExp = repmat(V, 1, 5); 

0.5  0.5  0.5  0.5  0.5
3.0  3.0  3.0  3.0  3.0
0.5  0.5  0.5  0.5  0.5
1.0  1.0  1.0  1.0  1.0
</pre>
<p>Afterwards, the result can be operated with A elementwise in the common way.</p>
<pre class="brush: csharp; title: ; notranslate">
ILArray&lt;double&gt; Result = VExp * A;

0.5   2.5   4.5   6.5   8.5
6.0  18.0  30.0  42.0  54.0
1.5   3.5   5.5   7.5   9.5
4.0   8.0  12.0  16.0  20.0
</pre>
<p>The problem with the above approach is that the vector data need to be expanded first. There is little advantage in doing so: a lot of new memory is being used up in order to store completely redundant data. We all know that memory is the biggest bottleneck today. We should prevent from lots of memory allocations whenever possible. This is where vector expansion comes into play. In ILNumerics, for long, one can prevent from the additional replication step and operate the vector on the matrix directly. Internally, the operation is implemented in a very efficient way, without replicating any data, without allocating new memory.</p>
<pre class="brush: csharp; title: ; notranslate">
ILArray&lt;double&gt; Result = V * A;

0.5   2.5   4.5   6.5   8.5
6.0  18.0  30.0  42.0  54.0
1.5   3.5   5.5   7.5   9.5
4.0   8.0  12.0  16.0  20.0</pre>
<h2>Generalizing for n-Dimensions</h2>
<p>Representing data as matrices is very popular in scientific computing. However, if the data are stored into arrays of other shapes, having more than two dimensions, one had to fall back to repmatting in order for the binary operation to succeed. This nuissance has been removed in version 4.10.</p>
<p>Now it is possible to apply broadcasting to two arrays of <em>any matching</em> shape &#8211; without the need for using repmat. In order for two arrays to &#8216;<em>match</em>&#8216; in the binary operation, the following rules must be fullfilled:</p>
<ol>
<li>All corresponding dimensions of both arrays must match.</li>
<li>In order for two  corresponding dimensions to match,
<ul>
<li>both dimensions must be of the same length, or</li>
<li>one of the dimensions must be of length 1.</li>
</ul>
</li>
</ol>
<p>An example of two matching arrays would be a vector running along the 3rd dimension and a 3 dimensional array:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2016/12/3D-Cubes-4-Broadcasting2.png"><img class="aligncenter size-full wp-image-929" src="http://ilnumerics.net/blog/wp-content/uploads/2016/12/3D-Cubes-4-Broadcasting2.png" alt="3D Cubes 4 Broadcasting2" width="655" height="485" /></a>In the above image the vector (green) has the same length as the corresponding dimension of the 3D array (gray). The size of the vector is [1 x 1 x 6]. The size of the 3D array is [4 x 5 x 6]. Hence, any dimension of both, the vector and the 3D array &#8216;match&#8217; in terms of broadcasting. A broadcasting operation for both, the vector and the array would give the same result as if the vector would be replicated along the 1st and the 2nd dimensions. The first element will serve all elements in the first 4 x 5 slice in the 1-2 plane. This slice is marked red in the next image: <a href="http://ilnumerics.net/blog/wp-content/uploads/2016/12/3D-Cubes-4-Broadcasting_slice1.png"><img class="aligncenter size-full wp-image-931" src="http://ilnumerics.net/blog/wp-content/uploads/2016/12/3D-Cubes-4-Broadcasting_slice1.png" alt="3D Cubes 4 Broadcasting_slice" width="812" height="633" /></a>Note that all red elements here derive from the same value &#8211; from the first element of the green vector.  The same is true for all other vector elements: they fill corresponding slices on the 3D array along the 3rd dimension.</p>
<p>Slowly, a huge performance advantage of broadcasting becomes clear: the amount of memory saved explodes when more, longer dimensions are involved.</p>
<h2> Special Case: Broadcasting on Vectors</h2>
<p>In the most general case and if broadcasting is blindly applied, the following special case potentially causes issues. Consider two vectors, one row vector and one column vector being provided as input parameters to a binary operation. In ILNumerics, every array carries at least two dimensions. A column vector of length 4 is considered an array of size [4 x 1]. A row vector of length 5 is considered an array of size [1 x 5]. In fact, <em>any</em> two vectors match according to the general  broadcasting rules.</p>
<p>As a consequence operating a row vector [1 x 5] with a column vector [4 x 1] results in a matrix [4 x 5]. The row vector is getting &#8216;replicated&#8217; (again, without really executing the replication) four times along the 1st dimension, and the column vector 5 times along the rows.</p>
<pre class="brush: csharp; title: ; notranslate">
array(new[] {1.0,2.0,3.0,4.0,5.0}, 1, 5) +array(new[] {1.0,2.0,3.0,4.0}, 4, 1)

&lt;Double&gt; [4,5]
[0]:          2          3          4          5          6
[1]:          3          4          5          6          7
[2]:          4          5          6          7          8
[3]:          5          6          7          8          9
</pre>
<p>Note, in order for the above code example to work, one needs to apply a certain switch:</p>
<pre class="brush: csharp; title: ; notranslate">
Settings.BroadcastCompatibilityMode = false;
</pre>
<p>The reason is that in the traditional version of ILNumerics (just like in Matlab and Octave) the above code would simply not execute but throw an exception instead. Originally, binary operations on vectors would ignore the fact that vectors are matrices and only take the length of the vectors into account, operating on the corresponding elements if the length of both vectors do match. Now, in order to keep compatibility for existing applications, we kept the former behavior.</p>
<p>The new switch &#8216;Settings.BroadcastCompatibilityMode&#8217; by default is set to &#8216;true&#8217;. This will cause the Computing Engine to throw an exception when two vectors of inequal length are provided to binary operators. Applying vectors of the same length (regardless of their orientation) will result in a vector of the same length.</p>
<p>If the &#8216;Settings.BroadcastCompatibilityMode&#8217; switch is set to &#8216;false&#8217; then general broadcasting is applied in all cases according to the above rules &#8211; even on vectors. For the earlier vector example this leads to the resulting matrix as shown above: operating a row on a column vector expands both vectors and gives a matrix of corresponding size.</p>
<p>Further reading: <a href="http://ilnumerics.net/Opoverload.html">binary operators, online documentation</a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/n-dim-array-broadcasting-efficiency-in-ilnumerics-4-10/">N-dim Array Broadcasting Efficiency in ILNumerics 4.10</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/n-dim-array-broadcasting-efficiency-in-ilnumerics-4-10/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing ILNumerics &#8211; Unexpected behavior</title>
		<link>https://ilnumerics.net/blog/installing-ilnumerics-unexpected-behavior/</link>
		<comments>https://ilnumerics.net/blog/installing-ilnumerics-unexpected-behavior/#comments</comments>
		<pubDate>Tue, 24 Mar 2015 10:45:44 +0000</pubDate>
		<dc:creator><![CDATA[Balázs]]></dc:creator>
				<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[installing ilnumerics]]></category>
		<category><![CDATA[unexpected behavior]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=814</guid>
		<description><![CDATA[<p>At ILNumerics we get a lot of support requests every day. During the last couple of months some questions were related to installing ILNumerics. In some cases an unexpected error message appears. The easy solution is to manually uninstall our extension from all Visual Studio instances and then reinstall ILNumerics. This issue will be resolved &#8230; <a href="https://ilnumerics.net/blog/installing-ilnumerics-unexpected-behavior/" class="more-link">Continue reading <span class="screen-reader-text">Installing ILNumerics &#8211; Unexpected behavior</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/installing-ilnumerics-unexpected-behavior/">Installing ILNumerics &#8211; Unexpected behavior</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p style="text-align: justify;">At ILNumerics we get a lot of support requests every day. During the last couple of months some questions were related to installing ILNumerics. In some cases an unexpected error message appears. The easy solution is to manually uninstall our extension from all Visual Studio instances and then reinstall ILNumerics. This issue will be resolved once we release our new installer.</p>
<p style="text-align: justify;"><span id="more-814"></span></p>
<h3>Problem during installing ILNumerics</h3>
<p style="text-align: justify;">Since the error is mostly related to the software upgrades, I was able to realize it on my computer. I have been playing with the installer and the build for quite some time now. I had an intermediate build being installed on my computer. I downloaded the official trial to use it for demonstration purpose. The following thing happened to me.</p>
<p style="text-align: justify;">Without even changing a string, next, next&#8230; install, the progress bar is running. Suddenly the following message pops up:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/11.png"><img class="alignnone wp-image-815 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/11.png" alt="Installing ILNumerics" width="509" height="399" /></a></p>
<h3>Reasons why it might happen</h3>
<p style="text-align: justify;">Visual Studio potentially gets confused when trying to install / uninstall multiple installer versions. Especially when such installers have the same major and minor version number. If one receives a software upgrade, it usually means the major and minor version is not changed. Therefore it is not a considered as major or minor upgrade.</p>
<h3 style="text-align: justify;">Locating the error</h3>
<p style="text-align: justify;">The easiest way to detect it, is after uninstalling ILNumerics. Check the VS Extensions (Tools -&gt; Extensions and Updates). If you still see &#8216;ILNumerics Ultimate VS&#8230;&#8217; installed that means you manually have to remove it. Unfortunately we have made some mistakes, and somehow it is not being removed correctly. This is something which happens occasionally.</p>
<h3 style="text-align: justify;">Resolution</h3>
<p style="text-align: justify;">A suggestion is to remove the VS extension manually. It is not a normal, nor an intended way of handling (un)installing ILNumerics. It is a workaround. I did the following: from VS 2010 to 2013, I manually uninstalled the VS Extensions (note: VS 2010 needs to be started with admin rights to be able to remove the extension).</p>
<p style="text-align: justify;">For me, after the removal of the extensions, the installer went smoothly <img src="https://ilnumerics.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /> Hope this helps in some unexpected cases! We would like to make the installation process smoother, feedback and ideas are welcome.</p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/installing-ilnumerics-unexpected-behavior/">Installing ILNumerics &#8211; Unexpected behavior</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/installing-ilnumerics-unexpected-behavior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Directions to the ILNumerics Optimization Toolbox</title>
		<link>https://ilnumerics.net/blog/directions-to-the-ilnumerics-optimization-toolbox/</link>
		<comments>https://ilnumerics.net/blog/directions-to-the-ilnumerics-optimization-toolbox/#comments</comments>
		<pubDate>Wed, 14 Jan 2015 16:27:44 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Scientific Computing]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[Getting Started]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[Toolbox]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=738</guid>
		<description><![CDATA[<p>As of yesterday the ILNumerics Optimization Toolbox is out and online! It&#8217;s been quite a challenge to bring everything together: some of the best algorithms, the convenience you as a user of ILNumerics expect and deserve, and the high performance requirements ILNumerics sets the scale on for. We believe that all these goals could be &#8230; <a href="https://ilnumerics.net/blog/directions-to-the-ilnumerics-optimization-toolbox/" class="more-link">Continue reading <span class="screen-reader-text">Directions to the ILNumerics Optimization Toolbox</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/directions-to-the-ilnumerics-optimization-toolbox/">Directions to the ILNumerics Optimization Toolbox</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>As of yesterday the ILNumerics Optimization Toolbox is out and online! It&#8217;s been quite a challenge to bring everything together: some of the best algorithms, the convenience you as a user of ILNumerics expect and deserve, and the high performance requirements ILNumerics sets the scale on for. We believe that all these goals could be achieved quite greatly.</p>
<p><span id="more-738"></span></p>
<p>During a lengthy beta phase we received a whole bunch of precise and enormous helpful feedback from you. We really appreciate that and again would like to say thanks!</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/01/Optim_Camel_LBFGS.png"><img class="aligncenter size-full wp-image-747" src="http://ilnumerics.net/blog/wp-content/uploads/2015/01/Optim_Camel_LBFGS.png" alt="Optim_Camel_LBFGS" width="1026" height="868" /></a>ILNumerics Optimization Toolbox adds a number of functions to ILNumerics, useful to find solutions of common optimization problems. Since everything is nicely integrated into ILNumerics it helps you solve the problem easily and very efficiently. Optimization applications like the one shown as screenshot above can now get realized in a couple of minutes!</p>
<p>This blog post sheds some light on the very first steps for using the new Optimization Toolbox. It helps you to start quickly and lists some common documentation sources.</p>
<h2>Obtaining the Optimization Toolbox</h2>
<p>The optimization toolbox is available as a dedicated package and so must be individually purchased and installed. ILNumerics 4.6 or above is needed for that to work. Existing customers can evaluate the new toolbox by installing an extended trial on top of your existing ILNumerics Ultimate VS installation. Just <a href="mailto:sales@ilnumerics.net">let us know</a> and we will lead you the way to the download. Another option is the trial: it includes all toolboxes, hence you can start right away by <a href="http://ilnumerics.net/download.html">downloading</a> and installing a trial of ILNumerics Ultimate VS and get familiar with all optimization methods easily.</p>
<h2>Optimization Toolbox Setup</h2>
<p>The optimization toolbox obviously depends on the ILNumerics Computation Engine. It installs the managed assemblies ILNumerics.Optimization.dll into the GAC and also makes them available inside Visual Studio as reference to your application projects:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/01/2015-01-14-16_26_48-Reference-Manager-ConsoleApplication18.png"><img class="aligncenter size-full wp-image-740" src="http://ilnumerics.net/blog/wp-content/uploads/2015/01/2015-01-14-16_26_48-Reference-Manager-ConsoleApplication18.png" alt="2015-01-14 16_26_48-Reference Manager - ConsoleApplication18" width="700" height="351" /></a>Afterwards, the ILNumerics.Optimization class is found in the ILNumerics namespace which commonly is included in your source files anyway. A super-mini but complete starting example in a fresh new C# console application could look as follows:</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using ILNumerics; 

namespace ConsoleApplication1 {
    class Program : ILMath {

        static ILRetArray&lt;double&gt; myObjFunc(ILInArray&lt;double&gt; A) {
            using (ILScope.Enter(A)) {
                return sum((A - 1) * A);
            }
        }
        static void Main(string[] args) {
            ILArray&lt;double&gt; M = Optimization.fmin(myObjFunc, ones(1,4));
            Console.WriteLine(M);
        }
    }
}

</pre>
<p>Note how we derived our console class from ILNumerics.ILMath! This allows us to omit the namespace.class identifier and &#8216;ILMath.sum&#8217; and &#8216;ILMath.ones&#8217; become just: &#8216;sum&#8217; and &#8216;ones&#8217;.</p>
<p>If you are lucky enough to use Visual Studio 2015, it will allow you the inclusion of the static ILNumerics.Optimization class into your &#8216;using&#8217; directives on top of your source code files also. This will inject all public functions of the Optimization class into your scope also which gives an even shorter syntax. &#8216;fmin&#8217; and all other optimization functions are now readily available right next to the common ILMath functions:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/01/2015-01-14-16_44_19-ConsoleApplication1-Debugging-Microsoft-Visual-Studio.png"><img class="aligncenter size-full wp-image-743" src="http://ilnumerics.net/blog/wp-content/uploads/2015/01/2015-01-14-16_44_19-ConsoleApplication1-Debugging-Microsoft-Visual-Studio.png" alt="2015-01-14 16_44_19-ConsoleApplication1 (Debugging) - Microsoft Visual Studio" width="661" height="373" /></a>That&#8217;s it already! Happy optimizing!</p>
<h2>Optimization Examples</h2>
<p>A number of example applications have been added to the <a href="http://ilnumerics.net/examples.php">examples section</a>. Basically, they accompany the corresponding <a href="/ilnumerics-optimization-toolbox.html">online documentation</a> and let you follow the tutorials step by step on your own machine.</p>
<p>In order to start with an example application, you download the example as a zip package and extract it into a new folder on your local machine. Open the &#8216;*.csproj&#8217; contained in the example package with Visual Studio. You will notice missing references in the References node of your project in the Solution Explorer:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/01/2015-01-14-17_03_38-.png"><img class="aligncenter size-full wp-image-744" src="http://ilnumerics.net/blog/wp-content/uploads/2015/01/2015-01-14-17_03_38-.png" alt="2015-01-14 17_03_38-" width="386" height="523" /></a>Just remove these old references and replace them with references to the files actually installed on your system – using the common method described above.</p>
<p>Hit F5 and run the example!</p>
<h2>Documentation</h2>
<p>The ILNumerics Optimization Toolbox online documentation is available here:</p>
<p><a href="http://ilnumerics.net/ilnumerics-optimization-toolbox.html">http://ilnumerics.net/ilnumerics-optimization-toolbox.html</a></p>
<p>The API /class documentation for all functions of ILNumerics.Optimization is available here:</p>
<p><a href="http://ilnumerics.net/apidoc/?topic=html/T_ILNumerics_Optimization.htm">http://ilnumerics.net/apidoc/?topic=html/T_ILNumerics_Optimization.htm</a></p>
<h2>Wrap up</h2>
<p>We gave a short introduction in how to obtain and install ILNumerics Optimization Toolbox for ILNumerics Computing Engine. We pointed you to the common places of examples and documentation.</p>
<p>If you run into trouble or have useful suggestions and feedback, <a href="/direct-support.html">let us know</a>! Contact <a href="mailto:sales@ilnumerics.net">sales@ilnumerics.net</a> for any licensing questions.</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/01/2014-12-19-17_06_40-Iterations-BFGS_-8-L-BFGS_-22.png"><img class="aligncenter size-full wp-image-739" src="http://ilnumerics.net/blog/wp-content/uploads/2015/01/2014-12-19-17_06_40-Iterations-BFGS_-8-L-BFGS_-22.png" alt="2014-12-19 17_06_40-Iterations BFGS_ 8 L-BFGS_ 22" width="1026" height="805" /></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/directions-to-the-ilnumerics-optimization-toolbox/">Directions to the ILNumerics Optimization Toolbox</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/directions-to-the-ilnumerics-optimization-toolbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting to know your Scene Graph</title>
		<link>https://ilnumerics.net/blog/getting-to-know-your-scene-graph/</link>
		<comments>https://ilnumerics.net/blog/getting-to-know-your-scene-graph/#comments</comments>
		<pubDate>Mon, 29 Dec 2014 12:21:09 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[scene graph]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=703</guid>
		<description><![CDATA[<p>Did you ever miss a certain feature in your ILNumerics scene graph? You probably did. But did you know, that most of the missing &#8220;features&#8221; mean nothing more than a missing &#8220;property&#8221;? Often enough, there is only a convenient access to a certain scene graph object needed in order to finalize a required configuration. Recently, &#8230; <a href="https://ilnumerics.net/blog/getting-to-know-your-scene-graph/" class="more-link">Continue reading <span class="screen-reader-text">Getting to know your Scene Graph</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/getting-to-know-your-scene-graph/">Getting to know your Scene Graph</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Did you ever miss a certain feature in your <a href="/Visualization-API.html">ILNumerics scene graph</a>? You probably did. But did you know, that most of the missing &#8220;features&#8221; mean nothing more than a missing &#8220;property&#8221;? Often enough, there is only a convenient access to a certain scene graph object needed in order to finalize a required configuration.</p>
<p>Recently, a user asked how to turn the background of a legend object in ILNumerics plots transparent. There doesn&#8217;t seem to be a straight forward way to that. One might expect code like the following to work:</p>
<pre class="brush: csharp; title: ; notranslate">
var legend = new ILLegend(&quot;Line 1&quot;, &quot;Line 2&quot;);
legend.Background.Color = Color.FromArgb(200, Color.White);
</pre>
<p><span id="more-703"></span>Unfortunately, it does not. Legend objects do not implement a &#8216;Background&#8217; property which would give convenient access to the background object. However, the background object obviously exists. And ILLegend &#8211; likewise most of the more complex scene graph / plotting objects in ILNumerics &#8211; is derived from ILGroup! <a href="http://ilnumerics.net/group-nodes.html">Group nodes</a> represent the common way to store and manage any number of child objects. At the same time, group nodes gives the user flexible access to their children.<br />
In case of ILLegend we can utilize one of the access methods of ILGroup in order to access the scene graph node which implements the background of the legend. Once we have the background object, we can go out and manipulate it freely. In order to do that, let&#8217;s first investigate, which nodes exist inside a legend object!</p>
<h2>Stepping into living Scene Graphs</h2>
<p>ILNumerics and Visual Studio make it very easy to investigate even complex scenes. Let&#8217;s create a simple line plot application first! We start with a fresh new C# Windows Forms Application and add a Plotting Form Template to it. A detailed instruction is given on the getting started page, at &#8220;<a href="/Getting-Started-with-ILNumerics.html">Creating Visualizations with ILNumerics</a>&#8220;.<br />
Double click on the auto-generated Program.cs file and change the last line to read:</p>
<pre class="brush: csharp; title: ; notranslate">
    Application.Run(new Plotting_Form1());
</pre>
<p>Starting the project via F5 brings up the newly generated example plot. We make one more addition. Double click the Plotting_Form1.cs to show the form in the designer. Now, double click on the white panel1 background to go to the code implementing the scene setup. At the end of the code creating the new plot cube and adding the line plot we add another line which adds a new legend object:</p>
<pre class="brush: csharp; title: ; notranslate">
// Initial plot setup, modify this as needed
private void ilPanel1_Load(object sender, EventArgs e) {

    // create some test data, using our private computation module as inner class
    ILArray&lt;float&gt; Pos = Computation.CreateData(4, 300);

    // setup the plot (modify as needed)
    ilPanel1.Scene.Add(new ILPlotCube(twoDMode: false) {
        new ILLinePlot(Pos, tag: &quot;mylineplot&quot;) {
            Line = {
                Width = 2,
                Color = Color.Red,
                Antialiasing = true,
                DashStyle = DashStyle.Dotted
            }
        }, new ILLegend(&quot;MyLineItem&quot;)
    });
    // register event handler for allowing updates on right mouse click:
    ilPanel1.Scene.First&lt;ILLinePlot&gt;().MouseClick += (_s, _a) =&gt; {
        if (_a.Button == MouseButtons.Right)
            Update(ILMath.rand(3, 30));
    };
}
</pre>
<p>Starting via F5 should give a form similar like this:<br />
<a href="http://ilnumerics.net/blog/wp-content/uploads/2014/12/PlotFormPlain.png"><img class="aligncenter size-full wp-image-704" src="http://ilnumerics.net/blog/wp-content/uploads/2014/12/PlotFormPlain.png" alt="PlotFormPlain" width="675" height="562" /></a>Now, let&#8217;s start the fun! Investigating living objects works best when the objects are alive, right? So let&#8217;s set a breakpoint in Visual Studio right after the legend has been created:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-12_51_22-WindowsFormsApplication4-Debugging-Microsoft-Visual-Studio.png"><img class="aligncenter size-full wp-image-705" src="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-12_51_22-WindowsFormsApplication4-Debugging-Microsoft-Visual-Studio.png" alt="2014-12-29 12_51_22-WindowsFormsApplication4 (Debugging) - Microsoft Visual Studio" width="655" height="292" /></a>As you know, Visual Studio allows for a nice feature &#8216;Edit and Continue&#8217;. Let&#8217;s add a variable as reference to our legend right in Debug mode! This is not really necessary, but eases the inspection. Note, it does not matter, where to add the code line, as long as we step over it in the debugger:</p>
<pre class="brush: csharp; title: ; notranslate">
    var leg = ilPanel1.Scene.First&lt;ILLegend&gt;();
</pre>
<p>Scene graph nodes are clever enough to give reasonable insights into their state and content at runtime. Just hover over the newly created variable &#8216;leg&#8217; with the mouse and Visual Studio will display helpful debugger visualizers. Expand any node to show its content:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-12_57_16-WindowsFormsApplication4-Debugging-Microsoft-Visual-Studio.png"><img class="aligncenter size-full wp-image-706" src="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-12_57_16-WindowsFormsApplication4-Debugging-Microsoft-Visual-Studio.png" alt="2014-12-29 12_57_16-WindowsFormsApplication4 (Debugging) - Microsoft Visual Studio" width="616" height="306" /></a>Inspecting the legend object that way makes it immediately clear, which object legends are made out of: a triangle shape realizes the background, a line strip shape the border. A common group holds the individual legend items and will be filled dynamically at rendering time.</p>
<h2>Configuration Flexibility at its Extreme</h2>
<p>Having access to every single child item in the scene graph obviously brings an extreme flexibility for configurations. Now it is easy to change the color of the background object to make the legend transparent:</p>
<pre class="brush: csharp; title: ; notranslate">
var leg = ilPanel1.Scene.First&lt;ILLegend&gt;();
leg.First&lt;ILTriangles&gt;(&quot;ScreenObjectBackground&quot;).Color = Color.FromArgb(200, Color.White);
</pre>
<p>Which gives us our transparent legend:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-13_10_50-Form1.png"><img class="aligncenter size-full wp-image-707" src="http://ilnumerics.net/blog/wp-content/uploads/2014/12/2014-12-29-13_10_50-Form1.png" alt="2014-12-29 13_10_50-Form1" width="520" height="253" /></a></p>
<h2>Do not stop here!</h2>
<p>This is the message to take away: any object in any visualization and any plot in ILNumerics is composed out of individual smaller objects. You can access them and manipulate them freely without limits! Most &#8216;convenience&#8217; properties like &#8220;colorbar.Background&#8221; barely do more than we have done here: they give easy access to inner children (and add Intellisense support, of course). But if you need access &#8211; you can easily gain it yourself by inspecting the scene graph and its objects by the methods described here.</p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/getting-to-know-your-scene-graph/">Getting to know your Scene Graph</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/getting-to-know-your-scene-graph/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with HDF5, ILNumerics and Excel</title>
		<link>https://ilnumerics.net/blog/fun-with-hdf5-ilnumerics-and-excel/</link>
		<comments>https://ilnumerics.net/blog/fun-with-hdf5-ilnumerics-and-excel/#comments</comments>
		<pubDate>Sat, 29 Nov 2014 16:19:45 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Features]]></category>
		<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Extension]]></category>
		<category><![CDATA[HDF5]]></category>
		<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=663</guid>
		<description><![CDATA[<p>It is amazing how many complex business processes in major industries today are supported by a tool that shines by its simplicity: Microsoft Excel. &#8216;Recently&#8217; (with Visual Studio 2010) Microsoft managed to polish the development tools for all Office applications significantly. The whole Office product line is now ready to serve as a convenient, flexible &#8230; <a href="https://ilnumerics.net/blog/fun-with-hdf5-ilnumerics-and-excel/" class="more-link">Continue reading <span class="screen-reader-text">Fun with HDF5, ILNumerics and Excel</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/fun-with-hdf5-ilnumerics-and-excel/">Fun with HDF5, ILNumerics and Excel</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>It is amazing how many complex business processes in major industries today are supported by a tool that shines by its simplicity: Microsoft Excel. &#8216;Recently&#8217; (with Visual Studio 2010) Microsoft managed to polish the development tools for all Office applications significantly. The whole Office product line is now ready to serve as a convenient, flexible base framework for stunning custom business logic, custom computations and visualizations &#8211; with just a little help of tools like <a href="http://ilnumerics.net">ILNumerics</a>.</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/11/ExcelWorkbook1.png"><img class="aligncenter size-full wp-image-664" src="http://ilnumerics.net/blog/wp-content/uploads/2014/11/ExcelWorkbook1.png" alt="ExcelWorkbook1" width="1118" height="594" /></a>In this blog post I am going to show how easy it is to extend the common functionality of Excel. We will enable an Excel Workbook to load arbitrary <a href="http://www.hdfgroup.org/">HDF5</a> data files, inspect the content of such files and show the data as interactive 2D or 3D plots. <span id="more-663"></span>HDF5 is an industry standard for the structured storage of technical data and is maintained by the <a href="http://www.hdfgroup.org/">HDF Group</a>. With version 4.0 <a href="http://ilnumerics.net">ILNumerics </a>supports the HDF5 file format with a very convenient, object oriented API. Visualizations have always been a popular feature since the early days of ILNumerics. And Excel can be another convenient GUI tool to marry both.</p>
<h2>Prerequisites</h2>
<p>Customizations like the one we are going to show are done in Visual Studio and utilize <a href="http://msdn.microsoft.com/en-us/library/jj620922.aspx">Visual Studio Tools for Office (VSTO)</a>. If you don&#8217;t own a copy of Visual Studio, you may find it useful that Microsoft gives away their <a href="http://www.visualstudio.com/en-us/products/free-developer-offers-vs.aspx">flagship for free</a> under certain conditions. Another prerequisite we will need: Office 2010 or 2013. I use Office 2010 on my computer. For some reason, Visual Studio 2013 did not allow me to create a new Workbook project for the 2010 version of Office and rather requested Office 2013. Therefore, I used Visual Studio 2012 instead. Just make sure to use the version of Office which is supported by your Visual Studio installation.</p>
<p>The last ingredient needed is ILNumerics. <a href="http://ilnumerics.net/download.html">Download the free trial</a> &#8211; it contains all features and tools you may possibly want and makes them available systemwide.</p>
<h2>Setup</h2>
<p>Let&#8217;s start with a fresh new Workbook project in Visual Studio:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/11/NewProject.png"><img class="aligncenter size-full wp-image-666" src="http://ilnumerics.net/blog/wp-content/uploads/2014/11/NewProject.png" alt="NewProject" width="955" height="660" /></a>We take all defaults here. This will create a new Visual Studio project with three worksheets, ready for your customizations. Double click on Sheet1.cs to open the designer view.  In the Visual Studio Toolbox find the ILNumerics section and drag a new instance of ILPanel onto your sheet:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/11/Workbook1_VisualStudioDesigner.png"><img class="aligncenter size-full wp-image-667" src="http://ilnumerics.net/blog/wp-content/uploads/2014/11/Workbook1_VisualStudioDesigner.png" alt="Workbook1_VisualStudioDesigner" width="1334" height="885" /></a>This will add the reference of ILNumerics to your project and places the ILPanel control on your sheet. You may want to resize and reposition the control. It will be available from now on as &#8216;iLNumerics_Drawing_ILPanel1&#8242; in your code-behind classes. Feel free to adjust the name &#8211; for this demonstration we will leave it as it is.</p>
<p>&nbsp;</p>
<h2>Loading HDF5 Files in Excel</h2>
<p>Excel does not support HDF5 file imports directly (yet?). Luckily, ILNumerics bridges the gap very efficiently and conveniently. First, we add a reference to the HDF5 assembly which comes with ILNumerics. In the last step the reference to ILNumerics was added automagically. For HDF5 we have to do this manually. Right click on the References tab in the solution explorer and chose: Add Reference. Now search for &#8220;HDF5&#8243; on your system, select the item found and hit &#8220;OK&#8221;:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/11/AddHDF5Reference.png"><img class="aligncenter size-full wp-image-668" src="http://ilnumerics.net/blog/wp-content/uploads/2014/11/AddHDF5Reference.png" alt="AddHDF5Reference" width="776" height="350" /></a>If no item was found, make sure you have installed the latest ILNumerics package using our installer and that you selected the Assemblies tab in the Reference Manager window.</p>
<p>Once we have the HDF5 assembly available, we can start coding. The idea is, that the user should be able to load an HDF5 file from disk, inspect the datasets contained and get the option to load and/or visualize their data. So, let&#8217;s add some more controls from the toolbox to the workbook sheet: OpenFileDialog and a button to trigger the opening. Drag the button (Common Controls in the Toolbox) and the OpenFileDialog (Dialogs tab in the Toolbox) to the designer surface:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/11/DragButtonOFDDesigner.png"><img class="aligncenter size-full wp-image-669" src="http://ilnumerics.net/blog/wp-content/uploads/2014/11/DragButtonOFDDesigner.png" alt="DragButtonOFDDesigner" width="906" height="560" /></a><br />
Now, rename the new button and double click it to open the auto-generated event handler method. This is where we are going to implement the code to open and inspect the HDF5 file:</p>
<pre class="brush: csharp; title: ; notranslate">
private void button1_Click(object sender, EventArgs e) {
    var fod = new OpenFileDialog();
    if (fod.ShowDialog() == DialogResult.OK) {

        var filename = fod.FileName;
        // access the HDF5 file for reading
        using (var file = new H5File(filename, accessMode: FileAccess.Read)) {
            int row = 4; // start listing at row 4
            // list all datasets in the file
            foreach (var ds in file.Find&lt;H5Dataset&gt;()) {
                Cells[row,   3].Value = ds.Path;
                Cells[row++, 4].Value = ds.Size.ToString();
            }
            while (row &lt; 100) {
                Cells[row, 3].Value = &quot;&quot;;
                Cells[row++, 4].Value = &quot;&quot;;
            }
            // display filename
            Cells[2, 4].Value = filename;
        }
    }
}
</pre>
<p>First, we ask for the filename to open. If the user provided a valid filename we open the file for reading. HDF5 files in ILNumerics are used in &#8216;using&#8217; blocks. No matter how you leave the block, ILNumerics ensures that the file is not left open. Read <a href="http://ilnumerics.net/hdf5-interface.html">here for more details</a>.<br />
Once we have the HDF5 file we start iterating over its datasets. C# foreach constructs make that really easy. Other languages have similar constructs. Inside the foreach loop we simply write out the path of the current dataset and its size to columns of the worksheet.<br />
The while loop afterwards is only needed to clear entries potentially left over from earlier loadings. This expects no more than 100 datasets in a file. In a production code, you will do better&#8230;<br />
Finally, the name of the HDF5 file is written into cell[2,4] for user information.</p>
<p>If we now run the workbook (hit F5) and click on our &#8220;Load HDF5 Dataset&#8221; button a file dialog opens up. Once we select an existing HDF5 file from our disk the file&#8217;s datasets are listed on the worksheet:<br />
<a href="http://ilnumerics.net/blog/wp-content/uploads/2014/11/FirstRun.png"><img class="aligncenter size-full wp-image-671" src="http://ilnumerics.net/blog/wp-content/uploads/2014/11/FirstRun.png" alt="FirstRun" width="464" height="478" /></a></p>
<h2>Loading HDF5 Dataset Content</h2>
<p>Next, register a new event handler for the double click event in the worksheet. The worksheet template offers a good place to do so: the Sheet1_Startup event handler is auto generated by Visual Studio. Add the following line in order to allow to react to double click events on the sheet:</p>
<pre class="brush: csharp; title: ; notranslate">
this.BeforeDoubleClick += Sheet1_BeforeDoubleClick;
</pre>
<p>The implementation of the Sheet1_BeforeDoubleClick method does all the work:</p>
<pre class="brush: csharp; title: ; notranslate">
void Sheet1_BeforeDoubleClick(Excel.Range Target, ref bool Cancel) {
    // only take cells we are interested in
    if (Target.Value == null || Cells[2, 4].Value == null) return;
    // grab the hdf5 filename from the cell
    var curFilename = Cells[2, 4].Value.ToString();
    // check if this points to an existing file
    if (File.Exists(curFilename)) {
        // grab the dataset name (if the user clicked on it)
        var dsName = ((object)Target.Value).ToString();
        // reasonable?
        if (Target.Count == 1 &amp;&amp; !String.IsNullOrEmpty(dsName)) {
            // open the file
            using (var file = new H5File(curFilename, accessMode: FileAccess.Read)) {
                // find the dataset in the file, we provide the full abs. path so we
                // are sure that there is only one such dataset
                var ds = file.First&lt;H5Dataset&gt;(dsName);
                if (ds != null) {
                    // add a new sheet with the name of the dataset
                    var sheet = (Excel.Worksheet)Globals.ThisWorkbook.Sheets.Add();
                    sheet.Name = checkName(dsName);
                    // ... and make it active
                    Globals.ThisWorkbook.Sheets[sheet.Name].Activate();
                    // load data using our extension method (see text)
                    sheet.Set(ds.Get&lt;double&gt;());
                } else {
                    // user has clicked on the size column -&gt; plot the data
                    var size = ParseSize(dsName);
                    if (size != null &amp;&amp; Target.Previous.Value != null) {
                        dsName = ((object)Target.Previous.Value).ToString();
                        // read data and render into panel
                        renderDS(file, dsName);
                    }
                }
            }
        }
    }
}
</pre>
<p>This is all straight forward: we do some very simple error checking here, just to make sure we only react to clicks on interesting columns. In your production code you will do much better error checking! However, here we decide if the user has clicked on a cell with a valid dataset name. If so, the file is opened (fetching the name from the HDF5 filename cell written to earlier), the dataset is located and its content loaded.<br />
The content is written to a new workbook sheet. Attention must be drawn to the naming of the sheet. If a sheet with a similar name exists already, Excel will throw an exception. One easy solution is to add the timestamp to the name, which is left as an exercise. Here, we only do very simple name checking to make sure, no invalid characters enter the name of the sheeet:</p>
<pre class="brush: csharp; title: ; notranslate">
string checkName(string name) {
    var ret = name.Replace('/','_');
    if (ret.Length &gt; 31) {
        ret = ret.Substring(-31);
    }
    return ret;
}
</pre>
<p>The method to actually load the data from an ILArray to the new sheet is found in the following extension method. This is one rather efficient attempt to load large data:</p>
<pre class="brush: csharp; title: ; notranslate">
public static void Set(this Worksheet worksheet, ILInArray&lt;double&gt; A, int fromColumn = 1, int fromRow = 1) {
    using (ILScope.Enter(A)) {

        var luCell = worksheet.Cells[fromRow, fromColumn];
        var rbCell = worksheet.Cells[fromRow + A.S[0] - 1, fromColumn + A.S[1] - 1];
        Range range = worksheet.Range[luCell, rbCell];
        range.Value = A.T.ToSystemMatrix();
    }
}

private static System.Array ToSystemMatrix&lt;T&gt;(this ILDenseArray&lt;T&gt; A) {
    using (ILScope.Enter(A)) {
        // some error checking (to be improved...)
        if (object.Equals(A, null)) throw new ArgumentException(&quot;A may not be null&quot;);
        if (!A.IsMatrix) throw new ArgumentException(&quot;Matrix expected&quot;);

        // create return array
        System.Array ret = Array.CreateInstance(typeof(T), A.S.ToIntArray().Reverse().ToArray());
        // fetch underlying system array
        T[] workArr = A.GetArrayForRead();
        // copy memory block
        Buffer.BlockCopy(workArr, 0, ret, 0, Marshal.SizeOf(typeof(T)) * A.S.NumberOfElements);
        return ret;
    }
}
</pre>
<p>Set() creates the range in the sheet to load the data into. The size is computed by the size of the incoming ILArray&lt;T&gt;. In order to load the data, we do not want to iterate over each<br />
individual cell for performance reasons. One option is to set the Value property of the range to a two dimensional System.Array. ToSystemArray() does exactly that conversion. However, you have to<br />
be careful not to get transposed data unexpectedly. The reason is that .NET multidimensional arrays are stored in row major order. ILNumerics on the other hand stores arrays in the same order as Matlab, FORTRAN and other technical tools do. Hence, we need to transpose our data before we assign them to the range. Read more details <a href="http://stackoverflow.com/a/19636778 /1215993">here</a>.</p>
<p>Now, when we run the application and load a HDF5 file, we can double click on the cell holding a dataset name and have Excel load the dataset contents into a new worksheet &#8211; fast. This can be easily adopted by defining ranges (hyperslabs) and only load partial datasets. Also you can adopt the method described here for writing worksheet contents to HDF5 datasets.</p>
<h2>Visualizing HDF5 Dataset Contents</h2>
<p>Now let&#8217;s add another nice feature to our workbook: instead of simply loading the data from a dataset to the worksheet, we add the option of creating interactive, fully configurable and fast visualizations and plots of the data. We&#8217;ll use the predefined plot classes of ILNumerics Visualization Engine here.</p>
<p>Back to the double click event handler created earlier, we left out the path which is executed once the user clicked on the size displayed next to each dataset. What happens here is also straightforward.</p>
<p>First we parse the size to see, if it gives something reasonable (again, you&#8217;ll add better error checking for a production release). If so, we give the HDF5 file together with the dataset name to the renderDS() method which does the rendering:</p>
<pre class="brush: csharp; title: ; notranslate">
private void renderDS(H5File file, string dsName) {
    var ds = file.First&lt;H5Dataset&gt;(dsName);
    if (ds != null) {
        using (ILScope.Enter()) {
            ILArray&lt;float&gt; A = ds.Get&lt;float&gt;();
            if (A.IsVector) {
                iLNumerics_Drawing_ILPanel1.Scene = new ILScene() {
                    new ILPlotCube(twoDMode: true) {
                        new ILLinePlot(A, markerStyle: MarkerStyle.Diamond, lineWidth: 2)
                    }
                };
            } else if (A.IsMatrix) {
                iLNumerics_Drawing_ILPanel1.Scene = new ILScene() {
                    new ILPlotCube(twoDMode: false) {
                        new ILSurface(A, colormap: Colormaps.Hot) {
                            UseLighting = true
                        }
                    }
                };
            }
            iLNumerics_Drawing_ILPanel1.Refresh();
        }
    }
}
</pre>
<p>This code does not need commenting. It fetches the dataset and loads its content into an ILArray&lt;float&gt;. A new scene replaces the existing one in the worksheet ILPanel. The new scene contains a <a href="http://ilnumerics.net/plot-cube-properties.html">plot cube</a> and a line plot or a <a href="http://ilnumerics.net/surface-plots.html">surface plot</a>. Which one is created depends on the shape of the data. Vector sized data create a lineplot, matrices are rendered as a surface plot. In order to have the new scene show up, we must trigger a refresh on the panel.<br />
<a href="http://ilnumerics.net/blog/wp-content/uploads/2014/11/WorkbooksLines.png"><img class="aligncenter size-full wp-image-673" src="http://ilnumerics.net/blog/wp-content/uploads/2014/11/WorkbooksLines.png" alt="WorkbooksLines" width="877" height="602" /></a>Now, run the workbook, load a HDF5 file having some vector and/or matrix sized datasets, select a dataset by double clicking on its <em>size</em> cell. The plot is created according to the data. Like all visualizations in ILNumerics we can interact with the data: rotation/ zoom /pan is done with the left/right mouse buttons. And of course, you are free to apply any of the very flexible configuration options in order to <a href="http://ilnumerics.net/visualization-engine.html">customize your plots</a> further. For line plots this includes: <a href="http://ilnumerics.net/line-plots.html#markers">markers</a>, <a href="http://ilnumerics.net/line-plots.html#customizing-line-properties">dash styles</a>, <a href="http://ilnumerics.net/labels.html">tex labeling</a>, advanced coloring, <a href="http://ilnumerics.net/axis-configuration.html#logarithmic-scales">logarithmic axes </a>and much <a href="http://ilnumerics.net/plotting-api.html">more</a> &#8230;</p>
<h2>Deploying ILNumerics Excel Workbooks</h2>
<p>Once the workbook is ready for distribution, we build a Release version from Visual Studio and from now on – do not need Visual Studio anymore! In order to make any machine ready for handling HDF5 data and create Excel worksheets with nice visualizations on it, one only needs to run the <a href="http://ilnumerics.net/download.html">ILNumerics installer</a> and transfer the workbook to that machine. It will run on any platform, regardsless if 32 or 64 bit!</p>
<p>You can find the full example for downloading on our <a href="http://ilnumerics.net/examples.php">examples page</a>.</p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/fun-with-hdf5-ilnumerics-and-excel/">Fun with HDF5, ILNumerics and Excel</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/fun-with-hdf5-ilnumerics-and-excel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Performance on ILArray</title>
		<link>https://ilnumerics.net/blog/performance-on-ilarray/</link>
		<comments>https://ilnumerics.net/blog/performance-on-ilarray/#comments</comments>
		<pubDate>Tue, 25 Nov 2014 16:59:13 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[scalar]]></category>
		<category><![CDATA[system types]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=650</guid>
		<description><![CDATA[<p>Having a convenient data structure like ILArray&#60;T&#62; brings many advantages when handling numerical data in your algorithms. On the convenience side, there are flexible options for creating subarrays, altering existing data (i.e. lengthening or shortening individual dimensions on the run), keeping dimensionality information together with the data, and last but not least: being able to &#8230; <a href="https://ilnumerics.net/blog/performance-on-ilarray/" class="more-link">Continue reading <span class="screen-reader-text">Performance on ILArray</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/performance-on-ilarray/">Performance on ILArray</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Having a convenient data structure like ILArray&lt;T&gt; brings many advantages when handling numerical data in your algorithms. On the convenience side, there are flexible options for creating subarrays, altering existing data (i.e. lengthening or shortening individual dimensions on the run), keeping dimensionality information together with the data, and last but not least: being able to formulate an algorithm by concentrating on the math rather than on loops and the like.</p>
<h2>Convenience <em>and</em> Speed</h2>
<p>Another advantage is performance: by writing C = A + B, with A and B being large arrays, the inner implementation is able to choose the most efficient way of evaluating this expression. Here is, what ILNumerics internally does:<span id="more-650"></span></p>
<ul>
<li>Pointer artithmetics &#8211; we remove the obligatory bound checks on array accesses by using C# pointers.</li>
<li>Cache aware implementations &#8211; the biggest bottleneck in modern processors is memory, as your know. ILNumerics implements all basic math functions in a way which allows to very efficiently profit from cache hierarchies in your processor. You will notice, if you time ILMath.sum over the rows of an array against a naive implementation.</li>
<li>Loops over large arrays are unrolled, saving a great amount of bookkeeping overhead.</li>
<li>Multithreading support &#8211; iterations over large arrays are split and distributed to multiple cores.</li>
</ul>
<h2>ILNumerics Accelerator</h2>
<p>Here is, what we are planning to add to this list:</p>
<ul>
<li>Utilizing SIMD vector extensions (SSE, AVX). Today, this parallel potential is accessed via the (native) MKL in ILNumerics. There has been a recent update to MKL 11.2 in ILNumerics Ultimate VS 4.4 which brings AVX2 support on corresponding Intel processors. For the future, we are planning to bring in extendend support for all managed evaluations as well. This will be introduced with the release of our ILNumerics Accelerator. Stay tuned &#8211; this will be a very exciting release&#8230; !</li>
<li>The Accelerator will also do onother highly efficient feature: removal of intermediate arrays. Expressions like C = A + 2 * B will no longer create an intermediate result for<br />
2 * B, but reformulate the expression before evaluation. Again: memory is the bottleneck and this will save a lot of memory transfer to the CPU.</li>
<li>Having a vast amount of GPUs available in basically every desktop computer today makes one wanting to <em>use</em> that – especially when waiting for your results. ILNumerics Accelerator will do it! It will decide on its own during runtime, which part of your algorithms are best executed on which available hardware and do it in the most efficient way possible. Need a further speedup? Just buy a better graphics card!</li>
</ul>
<h2>Limitations of n-dim arrays</h2>
<p>Nothing comes for free, right? All the above is great for large data on vectorized algorithms. But what if we have a tight loop over small ILArrays or an algorithm which basically does a vast amount of scalar computations?</p>
<p>The flexibility of ILArray certainly comes at a price here. It becomes clear if you imagine the difference between a single double value and its corresponding representation in terms of a scalar ILArray&lt;double&gt;. The former – while being a value type lives on the stack rather than on the managed heap. It is not involved in garbage collection and there is basically no cost involved for its construction, access and destruction &#8211; at least when compared to the full featured implementation of ILArray.</p>
<p>ILArray, on the other hand, is a class instance. It lives on the heap instead of the stack storage. Creating an instance corresponds to the creation with &#8216;new&#8217;. For the destruction ILNumerics is able to completely prevent the GC having to handle ILArray instances. But even this memory management comes with a cost, naturally.</p>
<p>So there are two sides of the medal: flexibility and better performance for &#8216;large&#8217; data. Flexibility and slower speed for tiny &#8230; to scalar data. For most algorithms, having a reasonable amount of management of small data does not hurt performance. But if such operations are to be done in tight loops, one starts looking for alternatives.</p>
<h2>Alternatives</h2>
<p>Especially for small data the flexible subarray features of ILArray are often not needed anyways.  Such scalar algorithm parts are much more efficiently implemented by using data structures that are especially designed for it: System.ValueType and System.Array. The good news: ILNumerics makes it very easy to resort to such system types instead. Here comes a comprehensive list of options:</p>
<p>Scalar operations on an ILArray&lt;T&gt;</p>
<table>
<tbody>
<tr>
<th>Scalar access</th>
<th>Returns</th>
<th>Efficiency</th>
<th>Documentation</th>
</tr>
<tr>
<td>A[0,1]</td>
<td>ILArray&lt;T&gt;</td>
<td>Improved since 4.3, but will not be fastest on scalars (ILNumerics Accelerator might change this!)</td>
<td><a href="/Subarray0.html">Subarrays</a></td>
</tr>
<tr>
<td>A.GetValue()<br />
A.SetValue()</td>
<td>T</td>
<td>faster and efficient if you only need a single element occasionally</td>
<td><a href="http://ilnumerics.net/ArrayAlter.html">Writing to Arrays</a></td>
</tr>
<tr>
<td>foreach (var a in A) { &#8230; }</td>
<td>T</td>
<td>very efficient iteration over all elements of A, gives copies as system types</td>
<td><a title="ILNumerics and LINQ" href="http://ilnumerics.net/blog/ilnumerics-and-linq/">ILArray and LINQ</a></td>
</tr>
<tr>
<td>A.GetArrayForRead()<br />
A.GetArrayForWrite()</td>
<td>T[]</td>
<td>direct access to the underlying system array of A. Use this for hand tuned inner kernels or if you need access to native libraries.</td>
<td><a title="Import/ Export" href="http://ilnumerics.net/ArrayImExport.html">Array Import / Export</a></td>
</tr>
</tbody>
</table>
<p>You may also consider the following references:<br />
Stackoverflow posts dealing with the scalar access issue:<br />
<a href="http://stackoverflow.com/questions/19224626/performance-of-ilnumerics-of-simple-math-operations-over-vectors-vs-system-array">http://stackoverflow.com/questions/20944672/iteration-through-ilarraydouble-is-very-slow</p>
<p>http://stackoverflow.com/questions/19224626/performance-of-ilnumerics-of-simple-math-operations-over-vectors-vs-system-array</a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/performance-on-ilarray/">Performance on ILArray</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/performance-on-ilarray/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uncommon data conversion with ILArray</title>
		<link>https://ilnumerics.net/blog/uncommon-data-conversion-with-ilarray/</link>
		<comments>https://ilnumerics.net/blog/uncommon-data-conversion-with-ilarray/#comments</comments>
		<pubDate>Tue, 07 Oct 2014 08:42:14 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[ILArray]]></category>
		<category><![CDATA[pointer arithmetic]]></category>
		<category><![CDATA[unsafe]]></category>
		<category><![CDATA[ushort]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=635</guid>
		<description><![CDATA[<p>ILNumerics Computing Engine supports the most common numeric data types out of the box: double, float, complex, fcomplex, byte, short, int, long, ulong If you need to convert from, let&#8217;s say ushort to float, you will not find any prepared conversion function in ILMath. Luckily, it is very easy to write your own: Here comes &#8230; <a href="https://ilnumerics.net/blog/uncommon-data-conversion-with-ilarray/" class="more-link">Continue reading <span class="screen-reader-text">Uncommon data conversion with ILArray</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/uncommon-data-conversion-with-ilarray/">Uncommon data conversion with ILArray</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>ILNumerics Computing Engine supports the most common numeric data types out of the box: double, float, complex, fcomplex, byte, short, int, long, ulong</p>
<p>If you need to convert from, let&#8217;s say ushort to float, you will not find any prepared conversion function in ILMath. Luckily, it is very easy to write your own:</p>
<p>Here comes a method which implements the conversion from ushort -&gt; float. A straight forward version first:</p>
<pre class="brush: csharp; title: ; notranslate">
        /// &lt;summary&gt;
        /// Convert ushort data to ILArray&amp;lt;float&gt;
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;A&quot;&gt;Input Array&lt;/param&gt;
        /// &lt;returns&gt;Array of the same size as A, single precision float elements&lt;/returns&gt;
        public static ILRetArray&lt;float&gt; UShort2Single(ILInArray&lt;ushort&gt; A) {
            using (ILScope.Enter(A)) {
                ILArray&lt;float&gt; ret = ILMath.zeros&lt;float&gt;(A.S);
                var retArr = ret.GetArrayForWrite();
                var AArr = A.GetArrayForRead();
                int c = 0;
                foreach (ushort a in A) {
                    retArr[c++] = a;
                }
                return ret;
            }
        }</pre>
<p><span id="more-635"></span>This method is used like that:</p>
<pre class="brush: csharp; title: ; notranslate">
            ushort[,] rawSensorData = new ushort[,] {{0,1,2},{3,4,5}};
            ILArray&lt;float&gt; converted = UShort2Single(rawSensorData);
            /*
             * &lt;Single&gt; [3,2]
             * [0]:          0          3
             * [1]:          1          4
             * [2]:          2          5
             */

            // continue working with 'converted' here...
</pre>
<p>The following method does the same but utilizes pointer arithmetic, hence it needs the /unsafe flag. Use this, if performance is critical and your data are sufficiently large:</p>
<pre class="brush: csharp; title: ; notranslate">
        /// &lt;summary&gt;
        /// Convert ushort data to ILArray&amp;lt;float&gt; (unsafe version)
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;A&quot;&gt;Input Array&lt;/param&gt;
        /// &lt;returns&gt;Array of the same size as A, single precision float elements&lt;/returns&gt;
        public unsafe static ILRetArray&lt;float&gt; UShort2SingleUnsafe(ILInArray&lt;ushort&gt; A) {
            using (ILScope.Enter(A)) {
                ILArray&lt;float&gt; ret = ILMath.zeros&lt;float&gt;(A.S);
                var retArr = ret.GetArrayForWrite();
                var AArr = A.GetArrayForRead();

                fixed (ushort* pAArr = AArr)
                fixed (float* pRetArr = retArr) {
                    ushort* pInWalk = pAArr;
                    ushort* pInEnd = pAArr + A.S.NumberOfElements;
                    float* pRetWalk = pRetArr;
                    while (pInWalk &lt; pInEnd) {
                        *(pRetWalk++) = /*implicit: (float)*/ (*(pInWalk++));
                    }
                }
                return ret;
            }
        }</pre>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/uncommon-data-conversion-with-ilarray/">Uncommon data conversion with ILArray</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/uncommon-data-conversion-with-ilarray/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Plotting Fun with ILNumerics and IronPython</title>
		<link>https://ilnumerics.net/blog/plotting-fun-with-ilnumerics-and-ironpython/</link>
		<comments>https://ilnumerics.net/blog/plotting-fun-with-ilnumerics-and-ironpython/#comments</comments>
		<pubDate>Mon, 15 Sep 2014 10:31:45 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[IronPython]]></category>
		<category><![CDATA[numerical algorithms]]></category>
		<category><![CDATA[plots]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=599</guid>
		<description><![CDATA[<p>Since the early days of IronPython, I keep shifting one bullet point down on my ToDo list: * Evaluate options to use ILNumerics from IronPython Several years ago there has been some attempts from ILNumerics users who successfully utilized ILNumerics from within IronPython. But despite our fascination for these attempts, we were not able to &#8230; <a href="https://ilnumerics.net/blog/plotting-fun-with-ilnumerics-and-ironpython/" class="more-link">Continue reading <span class="screen-reader-text">Plotting Fun with ILNumerics and IronPython</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/plotting-fun-with-ilnumerics-and-ironpython/">Plotting Fun with ILNumerics and IronPython</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Since the early days of IronPython, I keep shifting one bullet point down on my ToDo list:</p>
<p>* Evaluate options to use <a href="http://ilnumerics.net">ILNumerics</a> from IronPython</p>
<p>Several years ago there has been some attempts from<a href="https://code.google.com/p/ironlab/"> ILNumerics users</a> who successfully utilized ILNumerics from within IronPython. But despite our fascination for these attempts, we were not able to catch up and deeply evaluate all options for joining both projects. Years went by and Microsoft has dropped support for IronPython in the meantime. Nevertheless, a considerably large community seems to be active on IronPython. Finally, today is the day I am going to give this a first quick shot.</p>
<p><span id="more-599"></span></p>
<p><em>Disclaimer: I am not a python developer. My experience with IronPython range from 0 &#8230; zero (unfortunatley, since the project deserves <strong>much</strong> more attention). For CPython it is only slighly better. So please bare with me if I went into some stupid direction or if I have completely missed better options in this article! Corrections and suggestions are always warmly welcome.</em></p>
<h1>Setup</h1>
<p>I downloaded and installed <a href="https://ironpython.codeplex.com/releases/view/90087">IronPython from CodePlex</a>. Also, in Visual Studio 2013 there exists a link in the NEW PROJECT dialog advertising the download of IronPython Tools for Visual Studio. I used that to setup Visual Studio for IronPython projects. All setup went smooth and easy. Nice!</p>
<h1>Creating Plots with IronPython</h1>
<p>The challenge I was interested in the most was how it is possible to utilize the great plotting capabilities of <a href="http://ilnumerics.net/Visualization-API.html">ILNumerics Visualization Engine</a> from IronPython projects. Since matplotlib seems not to be available for IronPython and other alternatives are also pretty rare (if any at all?) having our visualization engine available to IronPython projects seem to be a big improvement.</p>
<p>The good news first: it works and it does so very easily. The following plot is done purely in IronPython:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/09/Plotting-Fun-with-ILNumerics-in-IronPython1.png"><img class="aligncenter size-full wp-image-613" src="http://ilnumerics.net/blog/wp-content/uploads/2014/09/Plotting-Fun-with-ILNumerics-in-IronPython1.png" alt="" width="661" height="470" /></a>I started with a fresh new Iron Python Windows Forms Application from the &#8216;New Project&#8217; dialog in Visual Studio 2013.</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/09/IronPython_ILPanel_NewProjectVS2013.png"><img src="http://ilnumerics.net/blog/wp-content/uploads/2014/09/IronPython_ILPanel_NewProjectVS2013.png" alt="" width="662" height="384" /></a></p>
<p>This gives a template python file &#8216;IronPython_ILPanel.py&#8217; with the following content:</p>
<pre class="brush: python; title: ; notranslate">
import clr
clr.AddReference('System.Drawing')
clr.AddReference('System.Windows.Forms')

from System.Drawing import *
from System.Windows.Forms import *

class MyForm(Form):
    def __init__(self):
        # Create child controls and initialize form
        pass

Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)

form = MyForm()
Application.Run(form)</pre>
<p>If you are familiar with the common setup of Windows Forms you may notice some similarities with the stub provided by a new C# Windows Forms Application project. What is otherwise spread over multiple files, now is done all within the global scope of the one and only *.py file: the form class is defined, the static Application class is configured and the event loop is started with an instance of the formerly defined MyForm class. Straight. This corresponds to the common setup for Windows.Forms from any language, where no Designer support exists for. The same could be done in PowerShell, to name just another example.</p>
<p>In order to integrate support for ILNumerics Visualization Engine, I did the following simple steps:</p>
<p>1) If not done so far, go and install <a href="http://ilnumerics.net">ILNumerics Ultimate VS</a>. We offer <a href="http://ilnumerics.net/download.html">30 days trials</a> which contain all features without limitation.<br />
2) Once installed, ILNumerics is available in the &#8220;Add Reference&#8221; dialog (right click on References in the Solution Explorer). ILNumerics.dll is added from the .NET tab:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/09/IronPython_ILPanel_Select_Component.png"><img class="aligncenter size-full wp-image-606" src="http://ilnumerics.net/blog/wp-content/uploads/2014/09/IronPython_ILPanel_Select_Component.png" alt="" width="592" height="476" /></a>3) Make the ILNumerics namespaces available: I added the following lines to the import section at the very top of IronPython_ILPanel.py:</p>
<pre class="brush: python; title: ; notranslate">
import clr
clr.AddReference('System.Drawing')
clr.AddReference('System.Windows.Forms')
clr.AddReference('ILNumerics')

from System.Drawing import *
from System.Windows.Forms import *
from ILNumerics import *
from ILNumerics.Drawing import *
from ILNumerics.Drawing.Plotting import *
</pre>
<p>4) Now we are ready to add a plot to the form. In C# we would simply use the <code>ilPanel1_Load</code> event handler which is easily added by help of the forms designer. Since we do not have designer support here, we simply add the setup to the constructor of MyForm:</p>
<pre class="brush: python; title: ; notranslate">
class MyForm(Form):
   def __init__(self):
     # Create child controls and initialize form
     ilpanel = ILPanel()
     ilpanel.Dock = DockStyle.Fill
     self.Controls.Add(ilpanel)
     # show some demo: first create a plotcube
     pc = ILPlotCube(&quot;pc&quot;, 0)
     # it will hold a surface with some sinc data in 3D
     # You can use ILRetArray returned from any ILNumerics Computing
     # Module as input argument here directly. Type conversions seem to happen automatically.
     sf = ILSurface(ILSpecialData.sincf(40,50))
     pc.Add(sf)
     # add the plotcube to the scene
     ilpanel.Scene.Add(pc)
     self.Text = &quot;Plotting Fun with ILNumerics in IronPython&quot;
</pre>
<p>This is all straightforward. The configuration of the panel and the plots is exactly as it would have been done in C# or Visual Basic. However, we have to add the ILPanel to the self.Controls collection manually. The result, of course is exactly the same: a nice interactive form, utilizing OpenGL, with all manipulation options like rotation, pan and zoom. The full spectrum of the Visualization Engine should work out of the box. This includes several, flexible <a href="http://ilnumerics.net/plotting-api.html">3D and 2D plotting types</a> as well as the whole <a href="http://ilnumerics.net/scene-graph-shapes-and-buffers.html">scene graph functionality</a> for building your own interactive visualizations.</p>
<p>This is all what needs to be done in order to create nice professional plots directly within IronPython. Press F5 and start your application, rotate the plot with the mouse and learn about all the <a href="http://ilnumerics.net/visualization-engine.html">options you have</a>.</p>
<p><iframe width="474" height="267" src="https://www.youtube.com/embed/G9WWy_u-vvI?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<h1>Computing Fun with IronPython and ILNumerics</h1>
<p>ILNumerics not only rely on its own flexible n-dimensional array implementation, it also introduces its very own memory management &#8211; for <a href="http://ilnumerics.net/performance.html">very good reasons</a>. In order for the memory managements to work, <a href="http://ilnumerics.net/GeneralRules.html">individual array types</a> (ILArray, ILInArray, ILOutArray and ILRetArray) are used in ILNumerics algorithms. This makes great use of the strict type safety of .NET languages as C# and Visual Basic and of automatic conversions between those types.</p>
<p>Python on the other side is a dynamic language. It does not know the concept of types to the same extend. A straightforward application of the ILNumerics array types is not possible. IronPython, however offers workarounds (clr.Convert) but they are not able to provide the same syntactical convenience as a pure C# algorithm.</p>
<p>My recommendation for the utilization of ILNumerics Computing Engine therefore is as follows:</p>
<p>ILNumerics Computing Engine can be used without restriction. The utilization of existing algorithms is straightforward. Algorithms leveraging the ILNumerics Function Rules can be called directly without any type conversions. The creation of local variables on the other side requires type conversions from ILRetArray to ILArray. This can be done by help of IronPythons clr.Convert function.</p>
<p>The type conversion issue possibly makes it less feasible to write own ILNumerics Computing Engine algorithms in IronPython. But most the time, one would rather want to use existing python algorithms anyway. In order to actually create a new algorithm, one should rather utilize C# and compile the algorithm into its own .NET module which can than easily be imported into your python project and get interfaced from your python code.</p>
<h1>Summary</h1>
<p>This blog demonstrated how easy it is to utilize ILNumerics from IronPython. Especially the Visualization Engine is incorporated without any problems and offers the full set of visualization and plotting options out of the box. Algorithms created with ILNumerics Computation Engine can directly be interfaced and used &#8211; in parallel with numpy algorithms, if the need arise. The syntax of the Computing Engine however is not as expressive and more clumsy due to the absense of implicit type conversions and operator overloads. Complex algorithms one therefore would rather implement in C# or VisualBasic than in IronPython. For small algorithms, like data preprocessing and the like, ILNumerics Computing Engine serves as a faster alternative to numpy arrays.</p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/plotting-fun-with-ilnumerics-and-ironpython/">Plotting Fun with ILNumerics and IronPython</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/plotting-fun-with-ilnumerics-and-ironpython/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dark color schemes with ILPanel</title>
		<link>https://ilnumerics.net/blog/dark-color-schemes-with-ilpanel/</link>
		<comments>https://ilnumerics.net/blog/dark-color-schemes-with-ilpanel/#comments</comments>
		<pubDate>Fri, 18 Apr 2014 15:35:10 +0000</pubDate>
		<dc:creator><![CDATA[haymo]]></dc:creator>
				<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Usage]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[Color]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Dark]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=580</guid>
		<description><![CDATA[<p>I recently got a request for help in building an application, where ILPanel was supposed to create some plots with a dark background area. Dark color schemes are very popular in some industrial domains and ILNumerics&#8217; ILPanel gives the full flexibility for supporting dark colors. Here comes a simple example: And here comes the code &#8230; <a href="https://ilnumerics.net/blog/dark-color-schemes-with-ilpanel/" class="more-link">Continue reading <span class="screen-reader-text">Dark color schemes with ILPanel</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/dark-color-schemes-with-ilpanel/">Dark color schemes with ILPanel</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>I recently got a request for help in building an application, where ILPanel was supposed to create some plots with a dark background area. Dark color schemes are very popular in some industrial domains and ILNumerics&#8217; <code>ILPanel </code>gives the full flexibility for supporting dark colors. Here comes a simple example:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2014/04/TorusPartBlackBG1.png"><img class="aligncenter size-full wp-image-587" src="http://ilnumerics.net/blog/wp-content/uploads/2014/04/TorusPartBlackBG1.png" alt="" width="566" height="544" /></a><span id="more-580"></span></p>
<p>And here comes the code used to create this example:</p>
<pre class="brush: csharp; title: ; notranslate">
private void ilPanel1_Load(object sender, EventArgs e) {
    // create some test data
    ILArray&lt;float&gt; A = ILSpecialData.torus(1.3f, 0.6f);

    // create the plot: a simple surface
    ilPanel1.Scene.Add(new ILPlotCube(twoDMode: false) {
        new ILSurface(A, colormap: Colormaps.Summer) {
            // we also want a colorbar
            new ILColorbar() {
                Background = {
                    Color = Color.DarkGray
                }
            }
        }
    });

    // set the backcolor of the scene to black
    ilPanel1.BackColor = Color.Black; 

    // set labels color
    foreach (var label in ilPanel1.Scene.Find&lt;ILLabel&gt;()) {
        label.Color = Color.White;
        label.Fringe.Width = 0;
    }

    // set the color of the default labels for axis ticks
    foreach (var axis in ilPanel1.Scene.Find&lt;ILAxis&gt;()) {
        axis.Ticks.DefaultLabel.Color = Color.White;
        axis.Ticks.DefaultLabel.Fringe.Width = 0;
    }

    // some more configuration: the view limits
    ilPanel1.Scene.First&lt;ILPlotCube&gt;().Limits.Set(
        new Vector3(0, 0, 1), new Vector3(2, 2, -1));

}
</pre>
<p>In line 4 we use the <code>ILSpecialData </code>class to create some test data. <code>torus() </code>creates the X, Y and Z values which eventually assemble a torus when used in <code>ILSurface</code>. The next line creates and adds a new plot cube to the scene. We set its <code>two2Mode</code> property to <code>false</code>, so we can rotate the torus with the mouse.</p>
<p>The next line creates a new surface and provides the torus data to it. As colormap &#8216;Colormaps.Summer&#8217; is configured. Most surfaces need a colorbar in order to help mapping colors to actual values. We add a new colorbar below the surface and set its background color to some dark value.</p>
<p>Next, the BackColor of the main panel is set to black. Note, that setting the background color of a panel must be done in code in the current version (3.3.3). This is due to a bug in ILPanel which causes settings made in the designer to be ignored!</p>
<p>Now we have a dark background color but the labels still remain black. So let&#8217;s fix this: all labels which are part of the regular scene graph can easily be set at once. We simply use the <code>ILGroup.Find()</code> function to enumerate all labels and set their color to white. Also, we remove the fringe around them. Alternatively we could have set the fringe color to some dark color.</p>
<p>The last issue remaining is caused by the fact that labels for ticks cannot be configured here. The reason is, that tick labels are created dynamically. they don&#8217;t even exist at the time of execution of this code. So we must configure a thing called &#8216;<code>DefaultLabel</code>&#8216; instead. <code>DefaultLabel</code> is a member of the ticks collection of every axis object and used at runtime to provide default properties for all tick labels in auto mode.</p>
<p>This gives a nice dark color scheme. Keep in mind that the default color values for all scene-/plot objects are currently optimized for light background colors. Using dark backgrounds, therefore requires one to adjust the color on all plot objects accordingly.</p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/dark-color-schemes-with-ilpanel/">Dark color schemes with ILPanel</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/dark-color-schemes-with-ilpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
