![](/img/trans.png)
[英]Equivalent functionality of Matlab unique() in MathNET.Numerics?
[英]MathNet.Numerics operation return types
我正在使用MathsNet.Numerics lib。 我想對復數向量進行運算,即
using MathNet.Numerics.LinearAlgebra.Complex
這給了我Vector
作為MathNet.Numerics.LinearAlgebra.Generic.Vector<T>
復雜版本
但是,對Vector
的操作不會返回可分配給Vector
對象:
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
進行操作的方法(例如Conjugate
和PointwiseMultiply
)的返回值不能分配給Vector
?
類型層次結構: Vector<T> <- Complex.Vector <- Complex.DenseVector
.Net在覆蓋方法時不支持專用於返回類型(協方差),因此從技術上講,我們無法修改Conjugate
以派生類型返回Complex.Vector
甚至Complex.DenseVector
。
通常,我們建議僅在字段和方法參數中使用預期的通用類型(即Vector<Complex>
),或者在您打算重用變量時使用。 在Math.NET Numerics v3中,已對此進行了簡化,因此幾乎不再需要使用實際的實現類型。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.