This project has moved. For the latest updates, please go here.

Remarks on the API

Mar 18, 2011 at 8:11 AM

Hi all,

Some remarks on the API now. I think it may be possible to simplify it. It's only mere questions I asked myself when using the API, maybe there are not relevant, stupid, or not applicable because of some other constraints I don't know, so do not take them as wishes but only as mere remarks from a mere user that is used to use Matlab.

There are in my opinion to many kinds of matrices (DenseMatrix, SparseMatrix, DenseVector, SparseVector...).

I think that 99.99% of times a DenseMatrix is selected, and I also think that most people do not even know what is a Sparse Matrix. You could simplify the API by assuming a matrix is always "dense", except if the user explicitly ask for a Sparse Matrix (e.g. a flag "IsSparse" in the constructor, with default value false).

Having a separate class for vector is also disturbing : is it a row vector, a column vector ? Would it not be possible to have a single class for matrices and vectors ?

Matrix / Vector classes have a lot of methods. Would it make sense to implement the "algorithmic methods" in a sepate static class ? This is how it is done in ILNumerics and also (in a way) in Matlab, i.e. instead of writing : mat2 = mat1.Inverse() we would write mat2 = Inverse(mat1). It would simplify the Matrix class, and it may also be simpler on an implementation point of view, because you could write a single implementation of  methods which are common to matrices and vectors (for example, there is no Sum() method for Matrix, only for Vector, but on Matlab using sum() on a Matrix returns a vector where each element is the sum of the columns, and sum(sum(mat)) returns the sum of all the elements of the matrix. Using a separate static class for the "algorithms" will make this kind of feature more simple to implement in an homogeneous way for matrices and vectors).

Best regards,


Mar 18, 2011 at 8:14 AM
Edited Mar 18, 2011 at 8:18 AM

Other ideas for the "static algorithm class" : classical mathematical functions (trigonometric functions, abs, ceil, floor, exp...) that would apply the function on every element of the matrix.

Other idea : implicit methods to cast a Matrix to/from a C# array.