Creating a Computing Module
Algorithms in ILNumerics are easily created based on an ILNumerics Computing Module. Computing Modules are easily created in Visual Studio for any C# based project. Right click on the project in the solution explorer and choose the ADD NEW ITEM dialog. (Make sure to right-click on the project node! The template will not show in the ADD NEW ITEM list when trying to add a solution item!)
Select the Computing Module item template from the list and confirm by pressing "Add".
This will add references to the ILNumerics assemblies to your project and add a new Computing Module class which you can use as a starting point for your own algorithm implementations.
The Computing Module implements a class with two methods – solely for demonstration purpose:
- SimpleMethod - an ILNumerics method with two array input parameters and one array return value
- MethodWithOutputParameters - showing the use of output parameters in ILNumerics
You can start implementing your own algorithm inside the method bodies, change the methods freely or replace them with your own functions.
Starting with a Computing Module item template is the fastest and easiest way of writing your own algorithms with ILNumerics. However, you do not have to use the Computing Module in order to use ILNumerics in your code. If you want to start without a template, you can simply add a reference to the ILNumerics assemblies (ILNumerics.Core, ILNumerics.Computing, ILNumerics.IO.HDF5, ILNumerics.Toolboxes.Optimization etc.) to your project manually. In the Solution Explorer right click on the References node of your project, select 'Assemblies' and choose the 'Extensions' tab. Now filter for the assembly name: 'ILNumerics' or 'HDF5'...
Visit the online documentation in order to learn how to write algorithms with ILNumerics.
In order to run the computing module, let your project know, where to start with. Double click on the Properties node in the Solution Explorer and select 'Computing_Module1' as Startup Object in the project settings:
As one example of a simple algorihm in ILNumerics, we can invert a matrix. Replace the body of the SimpleMethod() with the following code:
We can call that SimpleMethod from the Main function of the Computing Module:
This will print the first five elements from the first five rows of the inverse to the console:
Visit the online documentation in order to learn how to write algorithms in ILNumerics.
Important Rules at a Glance
Local array variables are mostly of type
Make sure to define the array variable type explicitely! The
Similarly, for Visual Basic:
Import the static
Further reading: Computing Engine Documentation.
ILNumerics® Quick Reference Charts
A short introduction showing the general usage of an ILNumerics Computing Module: