Creating a Computing Module
Algorithms in ILNumerics are easily created based on the ILNumerics Computing Engine. You can start by adding a preinstalled item template (.NET Framework only) or you can setup your project manually.
Setup your Project manually
1. Add the ILNumerics references. ILNumerics.Computing and ILNumerics.Core are required. ILNumerics.numpy is recommended. .NET Framwork projects add references from the GAC (Visual Studio Solution Explorer -> Add Reference Dialog -> Assemblies -> Extensions). .NET Core projects add the references from the ILNumerics installation folder (/bin subfolder).
2. .NET Core projects only: add the nuget package: Microsoft.Windows.Compatibility.
This short video demonstrates the required steps:
Follow the steps in the next video tutorial, in order to write your first ILNumerics algorithm:
Like these videos? Here is a more advanced introduction on some debugging features of ILNumerics:
Computing Module Item Template (Full .NET Framework only)
Alternatively to the manual setup you can start your computing algorithm in Visual Studio for any C# based project based on a preinstalled item template (full .NET Framework only). 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 a fast and easy 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 - as shown above. 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'.
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
Writing Functions with ILNumerics - Example