Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在c语言中将整数数组转换为矩阵#_C#_Mathnet Numerics - Fatal编程技术网

C# 如何在c语言中将整数数组转换为矩阵#

C# 如何在c语言中将整数数组转换为矩阵#,c#,mathnet-numerics,C#,Mathnet Numerics,我有一个名为resp的整数数组,我想将它重写/转换为一个名为resp的行矩阵 int[] resp= {1, 0, 1, 0}; 我正在使用图书馆 我该怎么做呢?在Mathnet中,无法初始化整数数组。事实上,这方面的支持有限。如果您尝试,您将得到以下结果: Unhandled Exception: System.TypeInitializationException: The type initializer for 'MathNet.Numerics.LinearAlgebra.Vect

我有一个名为
resp
的整数数组,我想将它重写/转换为一个名为
resp
行矩阵

int[] resp= {1, 0, 1, 0};
我正在使用图书馆


我该怎么做呢?

在Mathnet中,无法初始化整数数组。事实上,这方面的支持有限。如果您尝试,您将得到以下结果:

Unhandled Exception: System.TypeInitializationException: The type initializer 
for 'MathNet.Numerics.LinearAlgebra.Vector`1' threw an exception. ---> 
System.NotSupportedException: Matrices and vectors of type 'Int32' 
are not supported. Only Double, Single, Complex or Complex32 are supported at this point.
可以使用类似的值(使用双精度)初始化向量,如下所示:

var resp = new [] {1.0, 0.0, 1.0, 0.0};
var V = Vector<double>.Build;
var rowVector = V.DenseOfArray(resp);
var resp=new[]{1.0,0.0,1.0,0.0};
var V=Vector.Build;
var rowVector=V.DenseOfArray(分别);

为了构建矩阵,您需要一个多维数组

数组
resp
的定义是什么?你没有提供任何人需要的信息来给你一个合适的答案。这看起来像是
[1,0,1,0]
的行矩阵(行向量?)。您的预期输出是什么?输出将与[1,0,1,0]相同;只有对象类型应该更改。好的,那么要将其转换为什么类型?据我所知,.NET没有表示行向量的特定类型,但您现在使用的数组是一个合理的近似值。你使用的是一个没有在你的问题中包含相关信息的库吗?我已经编辑了所有人为你的问题提供合理答案所需的关键最低信息。今后,请尽最大努力在问题的第一次迭代中包含此信息。非常感谢。