mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.5k stars 896 forks source link

Translating from Colt #133

Open BrannonKing opened 11 years ago

BrannonKing commented 11 years ago

I've been translating some code from Java to C#. The Java side uses Colt and Math Commons. They have a few useful methods where I don't see an equivalent in MathNet. Namely:

  1. Is there some way to append rows? I see the Append method, but that seems to only be for columns. Also, I don't see a way to append vectors.
  2. They have some handy matrix constructors that take a 2D list of matrices.
  3. Their Multiply and Add operators have overloads that take a scalar multiplier. That way you can combine the two operations into one.
  4. It would be nice if SetSubMatrix had some overloads that would pull the width/height from the matrix being passed in.
  5. It would be nice if there were some methods to determine if a matrix is symmetric positive definite, semi-definite, negative, etc.

Thanks for your time.

cdrnet commented 11 years ago
  1. The equivalent of Append but for rows would be Stack. We should improve the docs to point to each other. Note that both Append and Stack expect matrices. To append/stack a vector you could use InsertColumn/InsertRow instead. I realize the naming is not very consistent there...
  2. Yes, I think we should add that one (as static functions in line with the others). Internally it could leverage the existing submatrix routines of the storage classes.
  3. We actually have such implementations in the providers, it is just not exposed. We may want to consider this, but mostly for performance reasons and since it is a very common operation. I doesn't help on readability though IMO.
  4. We could provide an int-int-matrix overload without rowCount and columnCount, assuming you want to write the whole submatrix. Yes, I suspect this is the most common use case by far.
  5. I think we'd have to leverage the eigenvalue decomposition for this - or try a cholesky decomposition if applicable (faster)? Or we could use Sylvester's criterion.
BrannonKing commented 11 years ago

Thanks for the thorough response. I don't see any insert methods on the Vector class. Was there some way to append/splice vectors without having to convert them to matrices first?