在C#中使用

用它编写的Math.NET Numerics可以很好地与C#和相关的.Net语言配合使用。使用Visual Studio或具有内置NuGet支持的其他IDE时,可以通过添加对MathNet.NumericsNuGet包的引用来快速入门。或者,您可以使用命令行工具来抓取该软件包,nuget.exe install MathNet.Numerics -Pre 或者直接下载Zip软件包。

比如生成随机数

using MathNet.Numerics;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.Random;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Random rng = SystemRandomSource.Default;
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(rng.NextDouble());
                Console.WriteLine(rng.NextDecimal());
                Console.WriteLine("----");
            }

            Console.ReadKey();
        }
    }
}Code language: JavaScript (javascript)
Previous:
Next:

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注