
Hi,
I've got a simple piece of code:
Public Shared Function ConversionMatrix(ByVal Array1(,) As Double) As Double(,)
Dim Matrix1 As Matrix = New DenseMatrix(Array1)
Matrix1 = Matrix1 * 4
Return Matrix1.Transpose.ToArray
End Function
But when I turn on Option Strict (trying to improve my code library) it insists that it should be:
Public Shared Function ConversionMatrix(ByVal Array1(,) As Double) As Double(,)
Dim Matrix1 As Matrix = New DenseMatrix(Array1)
Matrix1 = CType(Matrix1 * 4, Matrix)
Return Matrix1.Transpose.ToArray
End Function
because it's an implicit conversion from MathNet.Numerics.LinearAlgebra.Generic.Matrix(of Double) to MathNet.Numerics.LinearAlgebra.Generic.Double.Matrix
So, my question is: Is there a better way of coding this which doesn't require the type conversion?
Thanks,
Andrew



Ok, that example was trivial.
I sorted it by writing:
Public Shared Function ConversionMatrix(ByVal Array1(,) As Double) As Double(,)
Dim Matrix1 As DenseMatrix = New DenseMatrix(Array1)
Matrix1 = Matrix1 * 4
Return Matrix1.Transpose.ToArray
End Function
but I have a similar issue here:
Public Shared Function BezierCurve(ByVal DefinedXs() As Double, ByVal DefinedYs() As Double, ByVal OutputXs() As Double) As Double(,)
Dim i, j As Integer
Dim NumInputPoints As Integer = DefinedXs.Count
Dim NumOutputPoints As Integer = OutputXs.Count
Dim NumSections As Integer = NumInputPoints  1
Dim PointVectorList As DenseMatrix = New DenseMatrix(NumInputPoints, 2)
PointVectorList.SetColumn(0, DefinedXs)
PointVectorList.SetColumn(1, DefinedYs)
Dim SectionPoints(NumSections  1, 3) As DenseVector
SectionPoints(0, 0) = PointVectorList.Row(0)
SectionPoints(0, 1) = PointVectorList.Row(0)
SectionPoints(0, 2) = PointVectorList.Row(1)
SectionPoints(0, 3) = PointVectorList.Row(2)
where the PointVectorList.Row(0) returns a Generic.Vector(of Double) and not a Double.DenseVector
Same question really  how do i get round this?
Thanks.

