I am switching from MATLAB to VS2012. I want to use Math.net Numeric to solve my matrix based equations. I am having hard time to define a simple matrix in VS2012 in VB environment using Math.Net matrix. I have found many articles on F# and how to define a matrix, but no luck in VB. I tried Public MAT1 As Matrix(Of
but I don't know how to finish the declaration. Does anyone know? Thank you.
Asked
Active
Viewed 1,987 times
1

alulak
- 13
- 4
-
I think you can use multi-dimensional arrays for matrices. – Paul Ishak Apr 07 '15 at 04:31
1 Answers
1
The MathNet library has predefined Matrix classes for singles, doubles, and complex values.
For example, to instantiate a 3x3 matrix of doubles, use:
Dim m = MathNet.Numerics.LinearAlgebra.Double.Matrix.Build.DenseOfArray({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}})
Each operation on the matrix returns a transformed matrix:
Dim m2 = m.Multiply(1.5)

Craig Johnson
- 744
- 4
- 8
-
Matrix(Of T) is an abstract class, hence why you need to use the implemented classes and supplied class factories. No reason you couldn't roll your own for different types if you wanted to (not likely necessary, though). – Craig Johnson Apr 07 '15 at 04:37
-
2
-
-
Christoph, Thank you for the short option. Can I define a dynamic matrix as `Matrix(Of Double).Build.DenseOfArray({,})` ? Or I should reshape anyway down in the road? – alulak Apr 08 '15 at 04:51
-
No, a matrix cannot be empty (as this doesn't make sense mathematically). – Christoph Rüegg Apr 08 '15 at 16:49