Option Strict On Issue casting of type matrix


I’m robotic engineer and not skilled developer I work mainly with transformation matrices and I just installed for evaluation your lib on a OS Win7 Pro using VS2008 with VB.NET .NET 3.5.
I was looking for a tech support and hope this is link can help.

with “Option Strict On” I had problem with the declaration:
Dim M2 As Matrix =Matrix.Build.Dense(4, 4, Pi)

because the Matrix builder (and not the Matrix(of).build) return a type “Matrix(of Double)” and not of type “Matrix”, so I had to workaround:
Dim M2 As Matrix = CType(Matrix.Build.Dense(4, 4, Pi), Matrix)
Dim M1 As Matrix(Of Double) = Matrix.Build.Dense(6, 3)
Dim M3 As Matrix = New DenseMatrix(6, 3)

Am I correct the Matrix builder shall return a type matrix ?
If this is the wrong place for tech support please let me know where to address the issue

Best Regards

I recommend to use the generic types only. With generic types you’ll never have to type cast between different matrix types. That would essentially be your second workaround.

As such, Matrix(Of Double).Build.Dense(...) does indeed return a Matrix(Of Double).

Note that MathNet.Numerics.LinearAlgebra.Double.Matrix inherits from MathNet.Numerics.LinearAlgebra.Matrix(Of Double). That’s why you have been able to use the simpler notion Matrix.Build instead of ``Matrix(Of Double).Build`, but it is really the same.