在http://ilnumerics.net/$Editions.html下载ILNumerics社区版压缩包,现在版本为v2.13,约27.3MB。解压缩后目录结构如图1所示。
图1 ILNumerics源码包解压内容
现在需要编译ILNumerics函数库,用VisualStudio打开工程文件ILNumerics.csproj,编译一遍,在生成目录下Debug/Release下就有生成的ILNumerics.dill库了,如图2所示。
图2 编译结果
下面要做的就是将ILNumerics函数库添加到你的工程中去了。
首先,在项目引用中添加对ILNumerics.dll的引用,并且将图1中bin32(如果你的计算机是64位则对应bin64)目录下的libiomp5md.dll,mkl_custom32.dll,OpenTK.dll文件以内容文件添加到工程根目录,如果是Linux平台,自然应该添加的是*.so文件,如图3所示 。
图3 将ILNumerics添加到工程
二.利用ILNumerics做个小例子
下面就利用ILNumerics简单求解线性方程组,该示例来自官方网页。要注意的是,先引用ILNumerics命名空间。另外主类Program继承了ILNumerics.ILMath类,以方便使用它的静态函数,但实际中可能不太会这么用。
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using ILNumerics;
- namespace ConsoleApplication1 {
- // it is recommended to derive from ILMath
- class Program : ILNumerics.ILMath {
- static void Main(string[] args) {
- // create a matrix A, give values explicitely
- ILArray<double> A = array<double>(