Add second indexer to Math.NET Numerics

Not sure how to meet the demands of stackoverflow on this one...

I'd like to modify the MathNET Numerics package so that I can use the indexer to access or assign to a sub-matrix as follows:

A[rows, cols] 

where rows and cols are int[]

I've written an extension method Sub(int[] rows, int[] cols) which achieves the same but it would be smarter to have the indexing manner.

IS it possible to add an extension of the indexer without rebuilding the whole package? If so how?

Jon Skeet
people
quotationmark

No, there's no such thing as an "extension indexer" right now. Extension methods are as close as you can get. However, it's entirely possible (but not guaranteed) that they'll come in C# 8. So your options are:

  • Wait for C# 8
  • Use your own private fork of the library
  • Try to get your changes accepted into the library
  • Stick to extension methods

people

See more on this question at Stackoverflow