2013-10-29 57 views
0

我正在使用MathsNet.Numerics庫。我想在復向量,即我
using MathNet.Numerics.LinearAlgebra.Complex
這給了我VectorVectorMathNet.Numerics.LinearAlgebra.Generic.Vector<T>
Operatations爲複雜版本S但不分配對象返回Vector做業務:MathNet.Numerics操作返回類型

Complex[] complexData = new Complex[n] 
... fill data, fft etc ... 
Vector vectorReference = new DenseVector(complexData); 
vectorReference = vectorReference.Conjugate(); // Error. 

錯誤CS0266:無法隱式轉換類型 'MathNet.Numerics.LinearAlgebra.Generic.Vector<System.Numerics.Complex>' 到'MathNet.Numerics.LinearAlgebra.Complex.Vector'

爲什麼在Vector s上運行的方法的返回值(例如, ConjugatePointwiseMultiply)不可分配給Vector s?

+0

任何原因你還原我的編輯,改善拼寫和格式? – Stijn

+0

對不起Stijn - 我們做了一個快速編輯,我失去了一個變化 - 隨時可以重新申請。 – Ricibob

+0

沒問題,有時同時編輯無法正確合併。 – Stijn

回答

1

類型層次:Vector<T> <- Complex.Vector <- Complex.DenseVector

.NET不支持重載的方法時,專門返回類型(方差),所以我們在技術上不能修改Conjugate在派生類返回Complex.Vector甚至Complex.DenseVector

一般而言,我們建議期望在字段和方法參數中使用泛型類型(即Vector<Complex>) - 或者當您打算重用變量時。在Math.NET Numerics v3中,這已經被精簡了,所以幾乎從不需要使用實際的實現類型。