[英]Math.Net SVD Algorithm throws Errors for Large Matrices
我一直在通过 Math.NET 数字( https://numerics.mathdotnet.com/ )使用 SVD() 的英特尔 MKL 实现。 我已经成功运行了该算法。 但是,对于非常大的矩阵(在本例中为 64,000 x 500),我收到以下错误:
未处理的异常。 System.OverflowException: 算术运算导致溢出。 在 MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage`1..ctor(Int32 rows, Int32 columns) at MathNet.Numerics.LinearAlgebra.Double.DenseMatrix..ctor(Int32 order) at MathNet.Numerics.LinearAlgebra.Double.Factorization. DenseSvd.Create(DenseMatrix matrix, Boolean computeVectors) at MathNet.Numerics.LinearAlgebra.Double.DenseMatrix.Svd(Boolean computeVectors) >
有没有人遇到过类似的事情? 我想知道这是否是 Math.Net 实现的问题,还是与大矩阵一起使用时的英特尔 MKL 的问题。 是否有任何人可以建议可以实施的修复程序允许库在更大的矩阵上运行?
源代码
using System;
using MathNet.Numerics.LinearAlgebra;
using System.Diagnostics;
namespace Copula
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Parsing matrix dimensions from input parameters.");
//int n_rows = Int32.Parse(args[0]);
//int n_columns = Int32.Parse(args[1]);
int n_columns = 500;
int n_rows = 64000;
Console.WriteLine("Generating Random matrix wtih dimensions " + n_rows + " rows and " + n_columns + " columns.");
var stop_watch = Stopwatch.StartNew();
var time_series_matrix = GenerateRandomMatrix(n_rows, n_columns);
stop_watch.Stop();
Console.Write("Took " + stop_watch.Elapsed + "\n");
Console.WriteLine("Performing SVD.");
stop_watch = Stopwatch.StartNew();
var ts_svd = time_series_matrix.Svd();
stop_watch.Stop();
Console.Write("Took " + stop_watch.Elapsed + "\n");
}
static Matrix<double> GenerateRandomMatrix(int n_rows, int n_columns)
{
Matrix<double> out_matrix = Matrix<double>.Build.Random(n_rows, n_columns);
return out_matrix;
}
}
}
项目文件
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MathNet.Numerics" Version="4.8.1" />
<PackageReference Include="MathNet.Numerics.MKL.Win-x64" Version="2.3.0" />
<PackageReference Include="Meta.Numerics" Version="4.0.7" />
</ItemGroup>
</Project>
在运行小得多的案例时,您是否看到同样的问题? 比如说1Kx1K?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.