mathnet/mathnet-numerics — pull request #48 by tpetricek (2012-09-23 15:30:54+00:00)
Title: Add slicing operations for F#

The pull request adds extension method `GetSlice` to the generic `Matrix<'T>` and `Vector<'T>` types. This makes it possible to use F# slicing syntax to get submatrix and subvector as follows (see also [F# snippet](http://www.fssnip.net/dQ):

// Get some slices from a vector
let v = vector [ 1.0; 2.0; 3.0 ]
v.[0 .. 1] // elements [1.0; 2.0]
v.[1 ..] // elements [2.0; 3.0]
v.[.. 1] // elements [1.0; 2.0]

// Example: Get some slices from a matrix
let m = matrix [ [ 1.0; 2.0; 3.0 ]
[ 4.0; 5.0; 6.0 ] ]

m.[0 .. 1, 0 .. 1] // get first square 2x2
m.[0 .. 1, 2 ..] // get the last column
m.[1 .., 0 .. 2] // get the last row

The pull request implements the extensions in the `MathNet.Numerics.LinearAlgebra.Generic` namespace, so they will only be visible when the `MathNet.Numerics.LinearAlgebra.Generic` namespace is opened. I'm not sure what is the best design. Perhaps they should be available when `MathNet.Numerics.FSharp` is opened - that might be nicer. Since `MathNet.Numerics.FSharp` is a module, we would have to add the code to the `Main.fs` file (just copy the `FSharpExtensions` module with the `AutoOpen` attribute there).