let v = [| 5.0; 2.0; 3.0; 11.0 |]
let m2 = new DenseMatrix(2, 2, v)
let invm = m2.Inverse()
let invt = m2.Transpose()
Here m2 is a Matrix. However, invm and invt are Generic.Matrix<float>. Why this conversion?
Shortly, because the signatures of DenseMatrix.Inverse() and DenseMatrix.Transpose() are
DenseMatrix.Inverse: unit -> Matrix<float>
DenseMatrix.Transpose: unit -> Matrix<float>
Matrix is an abstract class that provides common implementation of Inverse and Transpose methods for any matrix. Concrete derived subclasses DenseMatrix, SparseMatrix, and DiagonalMatrix just optimize way of storing matrix data depending on each use case.
You may upcast
let m2 = new DenseMatrix(2, 2, v) :> Matrix<float>
and manipulate with generic types after matrix creation. You may want checking related topic Matrix vs DenseMatrix for further details.
matrix [[ 5.0; 3.0]; [2.0; 11.0]]) or one of the factory functions in the DenseMatrix module of the F# extensions, the matrix will automatically be of the generic type.