On 8/16/11 1:38 AM, William Stein wrote:
On Mon, Aug 15, 2011 at 3:30 PM, Rob Beezer<goo...@beezer.cotse.net>  wrote:
On Aug 15, 12:58 pm, William Stein<wst...@gmail.com>  wrote:
If somebody walked up to *you* and asked: "Is Sage now a viable
alternative to MATLAB?" what would you say?

Good question.

If you consider "matrix algebra" as the core functionality of MATLAB,
then I think Sage could very easily be a viable alternative, but is
not there yet.  I realize that MATLAB is more than just matrix
algebra, but I am going to restrict my comments to that (important)
area.

I came from Mathematica, and have never been a MATLAB user.  I did
recently look at the MATLAB documentation very carefully, at a time
when I was also in the NumPy/SciPy documentation frequently and also
had my head in  sage/matrix/matrix_double_dense.pyx  regularly.

With Jason Grout's NumPy backend supporting Sage matrices over RDF/CDF
it is very straightforward to implement NumPy/SciPy functionality for
various common operations, computations and decompositions.  So there
is little excuse for not exposing almost everything NumPy/SciPy do in
this area, other than it is a pain in the *ss to doctest this
numerical stuff across platforms when you do not control the
underlying implementation.  Off the top of my head, I would say we are
75% of the way to matching MATLAB on the big stuff, function-by-
function.

It sound like it wouldn't be difficult for you to name one single
Matlab matrix function that engineers would actually use that
Numpy/Scipy doesn't have?      I wonder why it's not in numpy yet.


I believe there are a few such functions, and they aren't in numpy yet because no one has implemented them. Remember that there are far fewer numpy developers than Sage developers, for example.

I also think there are a lot of functions in matlab that are smarter than the ones in numpy. What I mean is that the functions in matlab handle more cases or wrap more lapack functions under a single call. For example, there are a lot of matlab functions that will automatically use different lapack functions depending on the structure of the matrix or various options to the function, whereas the numpy equivalent will just use a standard lapack function for a generic case.

Of course, this conversation would be *much* better to have on the numpy list. Would you like me to post there?


I know one example sort of like this, which is "rref", for reduced row
echelon form.  However, in a numerical setting, my understanding is
that engineers would never ever use rref directly anyways.
Nonetheless, Matlab has it and Numpy/Scipy don't, because there is no
point in having it.

Incidentally, as I discovered by putting this on a homework assignment
for my class, it genuinely is really easy to implement rref in Numpy,
and the result from almost anybody is very impressively fast, even in
pure Python (Cython barely helps in this case, since Numpy is already
so optimized).

Also, with your "75%" above, do you mean when working with Sage
matrices or Numpy arrays?

IIRC, Numpy matrices are discouraged. Lots of functions in numpy are not written with the matrix class in mind, so they will take numpy matrices, for example, but will return numpy arrays. This, of course, messes lots of stuff up. There have been threads on the numpy list about deprecating matrices or the lack of attention that the matrix class has.

Note to those that are confused: numpy has two basic data structures: arrays (any dimension) and matrices. Think of matrices as a subclass of arrays that are (1) only 2-dimensional, and (2) have some convenience things, like A*B is standard matrix multiplication, etc. Numpy arrays used by the vast majority of people. You can see some of the differences here: http://www.scipy.org/NumPy_for_Matlab_Users

Personally I decided a long time ago that it wasn't worth the gotchas to work with numpy matrices, so when I work with numpy, it's always with the numpy arrays.

Thanks,

Jason



--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to