问题标签 [math.net]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
4418 浏览

c# - Svd recomposition with Mathnet numerics library seems wrong

I'm looking for non regression between Mathnet.Iridium and Mathnet.Numerics. Here is my code, using Mathnet.Numerics :

When i compare recompo and the initial matrix, they are different. I found this difference when comparing each decomposition matrix with the previous implementation :

  • U and singularValueDecomposition.LeftSingularVectors are equal
  • W and singularValueDecomposition.S are equal
  • VT and Matrix.Transpose(singulaValueDecomposition.RightSingularVectors) are different

Finally, recomposition with older API is correct.

MathNet.Numerics version used : Math.NET Numerics v2.5.0

So my question is : Where is my mistake when rebuilding initial matrix with the new API ?

RecompoMatrix =

  • 3 0 0 0 0
  • 0 -1.216846655456 2.83903817786199 1.4472680220698 2.89215520227421
  • 0 -2.46695399700557 8.657344064164 0.92863757484644 -0.31963101527516
  • 0 0.349540484418384 8.20515629935223 -2.26741625715781 -12.3049605878983
  • 0 -0.402667067831389 -6.32914150795323 9.13315298351198 8.3884053064068
0 投票
1 回答
706 浏览

complex-numbers - Math.Net Complex32 除法给出 NaN

好的,所以我有两个大的复数值。顶部和底部:

顶部 = 4.0107e+030

机器人 = 5.46725E26 -2.806428e26i

当我在 Math.Net 的 Complex32 中划分这两个数字时,它给了我一个实数和虚数的 NaN。我假设它与精度有关。

当我使用 Matlab 时,我得到以下信息:

顶部/底部 = 5.8060e+003 +2.9803e+003i

当我使用 System.Numerics 时,我得到了非常接近 matlabs 的东西,至少按照正确的大小顺序:

顶部/底部 = +5575.19343780947 +2676.09270239214i System.Numerics.Complex

我想知道,哪一个是正确的?为什么 Math.Net 给我一个错误的答案我正在运行模拟并且我非常关心数字的准确性?有任何解决这个问题的方法吗?我将处理很多大的复数。

另外,如果有人知道 .net 的一个很好的 Complex 库,它支持特殊函数,例如补全误差函数和复杂参数的误差函数,那就太好了。我发现 Math.Net 不支持 complex32 的 cerf

0 投票
1 回答
1210 浏览

c# - 获取密集矩阵元素的最小值和最大值

使用MathNet.numericsC# ,我创建了密集的双精度矩阵。

我希望找到矩阵的最小和最大元素值。

是否有获取密集矩阵元素的最大值/最小值的访问器?

其实我这样做

0 投票
1 回答
264 浏览

math.net - Is there a way to get a spearmans correlation matrix for more than two arrays?

I have code that produces N arrays of doubles and I'd like to create a spearmans correlation matrix. Is there a function to do it for me or do I have to iterate through all the combinations and build my own correlation matrix with Correlation.Spearman()?

0 投票
1 回答
1467 浏览

vector - 如何将新元素添加到 DenseVector

我需要在现有的 DenseVector 中添加一个新元素(双值)。我找到了一些解决方法,但是,在 Math.NET 中如何做到这一点的正确方法是什么?

0 投票
1 回答
379 浏览

sqlclr - 在 SQL Server 中使用 mathnet-numerics 作为 CLR 程序集

有没有人成功地将 MathNet.Numerics 用作 SQL Server 中的 CLR 程序集?

在 Windows 8 上使用 SQL Server 2012,我成功地创建了一个指向 DLL 的 CREATE ASSEMBLY,但是当我尝试这样做时

我收到一条错误消息:

“不符合 UDT 规范:缺少自定义属性 Microsoft.SqlServer.Server.SqlUserDefinedTYpeAttribute”。

0 投票
2 回答
2684 浏览

c# - 向量与系统数组和 Math.NET 上简单数学运算的 ILNumerics 的性能

我最近正在研究 C# 中的数值算法。因此,我做了一些实验来寻找最适合 .NET 的数学库。我经常做的一件事是评估目标函数,这些函数通常是将向量作为输入并返回向量作为输出的函数。我比较了 ILNumerics、系统数组和 Math.NET 中相同目标函数的实现。ILNumerics 的语法确实使它脱颖而出,因为它类似于 MatLab 和 R 的冗长数学公式。但是,我发现对于相同数量的评估,ILNumerics 似乎比 Math.NET 的任一系统数组花费的时间要长得多。下面是我用来比较的代码。我在这里没有做任何线性代数,只是纯粹将数学公式应用于长向量。

不幸的是,测试表明 ILNumerics 花费了太长时间来完成如此简单的事情。

我真的很喜欢它让代码看起来很像数学公式的方式。但是,系统数组或 Math.NET 花费更多时间来评估上述函数意味着我必须选择其他替代方案而不是 ILNumerics,即使这会导致函数的解释时间更长、更难。

我是否以错误的方式使用 ILNumerics?还是在这种情况下设计速度较慢。也许我没有将它用于最合适的目的。有人可以解释吗?

测试中使用 ILNumerics 3.2.2.0 和 Math.NET.Numerics 2.6.1.30。

0 投票
1 回答
2546 浏览

c# - 使用带有 C# 的 Math.Net Numerics 以数值方式添加两个向量的值

我有两个向量,如下所示:

我基本上想要一个向量 vdX,其结果是将 vdA 的所有元素与 vdB 的所有值相加。

使用 MathNet.Numerics 我找不到执行此操作的函数。

在 C# 中,我编写此代码来执行此操作

是否有任何其他选项可以在 c# 中使用 Math.Net Numerics 更快地完成此任务?

0 投票
1 回答
817 浏览

c# - MathNet.Numerics operation return types

I'm using MathsNet.Numerics lib. I want to do operations on Complex Vectors i.e. I'm
using MathNet.Numerics.LinearAlgebra.Complex
which gives me Vector as Complex version of MathNet.Numerics.LinearAlgebra.Generic.Vector<T>
Operatations on Vectors however don't return objects assignable to Vector:

error CS0266: Cannot implicitly convert type 'MathNet.Numerics.LinearAlgebra.Generic.Vector<System.Numerics.Complex>' to 'MathNet.Numerics.LinearAlgebra.Complex.Vector'

Why are the return values of methods that operate on Vectors (e.g. Conjugate and PointwiseMultiply) not assignable to Vectors?

0 投票
1 回答
623 浏览

f# - MathNet Numerics 内存不足异常

我在我的 F# 项目中使用 MathNet.Numerics,但在处理应该在其职权范围内的矩阵时,它会耗尽内存。

编辑:问题绝对不在于 MathNet.Numerics。这是我正在做的事情,虽然我还没有弄清楚那可能是什么。

这是我构建 MNIST 矩阵的方式。也许我要打开文件流或其他东西,但我看不出情况会如何。

使用这个,

炸毁。

是他们还是我?我从http://yann.lecun.com/exdb/mnist/中提取了文件,以防有人想自己尝试。

编辑 1:罪魁祸首是对loadMnistImage. 根据 Gene Belitski 的建议,我运行了代码

行前和行后

行前,还好;在该行之后,它因同样的内存不足异常而爆炸。我原以为这些use声明会发布文件,我会没事的(这不是一个庞大的文件)。但是,我错过了一些东西,所以我会继续挖掘,如果有人看到任何东西,请告诉我。

编辑2:当我如下简化文件阅读器时,问题就消失了。看起来问题出在列表的惰性评估上。