2

resp名前付きの整数配列を書き換え/変換したいというrow matrix名前の整数配列がありrespます。

int[] resp= {1, 0, 1, 0};

Mathnet.Numericsライブラリを使用しています。

どうやってやるの?

4

1 に答える 1

1

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.

次のように、同様の値 (double を使用) でベクトルを初期化できます。

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

行列を構築するには、多次元配列が必要です。

于 2015-05-12T05:33:20.067 に答える