MATLAB: viable alternative...?

315 views
Skip to first unread message

William Stein

unread,
Aug 15, 2011, 3:58:38 PM8/15/11
to sage-devel
Hi,

If somebody walked up to *you* and asked: "Is Sage now a viable
alternative to MATLAB?" what would you say?
I'm especially interested in what people who do numerical/applied
computation think.

My answer: "It's very difficult for *me* to answer this question
myself, because MATLAB is useless for most of my own
teaching/research/work, but I realize it is very widely used in
applied mathematics. Based on going to Scipy and the resources I've
seen online, it appears that the Numpy/Scipy stack is extremely useful
to actual people doing numerical computation. Maybe I'll try
asking on sage-devel."

[NOTE: I am interested in people's answers, rather than somebody
hijacking this thread to try to define "viable alternative" or say
this isn't a scientific survey or something. Please try not to hijack
this thread. Thanks!]

-- William

--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

kcrisman

unread,
Aug 15, 2011, 4:15:26 PM8/15/11
to sage-devel


On Aug 15, 3:58 pm, William Stein <wst...@gmail.com> wrote:
> Hi,
>
> If somebody walked up to *you* and asked: "Is Sage now a viable
> alternative to MATLAB?" what would you say?
> I'm especially interested in what people who do numerical/applied
> computation think.

An answer that's been given to me a number of times is "Maybe on the
computational side, but it doesn't have any drivers, and not as easy
of interfaces like Labview". Note that this is an answer given to me
by people who know of Sage but don't have interest in trying something
that isn't a drop-in replacement for MATLAB et al., not my actual use
experience. Third-party (both hardware and "recipe") support seems to
be key for "viability" in the sense you mean.

A good place to ask about this might be somewhere other than sage-
devel - maybe some open/Usenet list where a lot of MATLAB users lurk.
I don't know how to frame the question in a way that doesn't sound
like an advertisement, though.

- kcrisman

Jason Grout

unread,
Aug 15, 2011, 5:01:43 PM8/15/11
to sage-...@googlegroups.com
On 8/15/11 2:58 PM, William Stein wrote:
> Hi,
>
> If somebody walked up to *you* and asked: "Is Sage now a viable
> alternative to MATLAB?" what would you say?
> I'm especially interested in what people who do numerical/applied
> computation think.
>
> My answer: "It's very difficult for *me* to answer this question
> myself, because MATLAB is useless for most of my own
> teaching/research/work, but I realize it is very widely used in
> applied mathematics. Based on going to Scipy and the resources I've
> seen online, it appears that the Numpy/Scipy stack is extremely useful
> to actual people doing numerical computation. Maybe I'll try
> asking on sage-devel."

The scipy or numpy lists have threads on this occasionally. Usually
many people will chime in and say why they switched from MATLAB.

Here's at least one of these threads:

http://thread.gmane.org/gmane.comp.python.numeric.general/27115

and one message in particular:

http://thread.gmane.org/gmane.comp.python.numeric.general/27115/focus=27127

and another:

http://thread.gmane.org/gmane.comp.python.numeric.general/27115/focus=27127


And a message from another thread that has some very good links
comparing with matlab:

http://thread.gmane.org/gmane.comp.python.matplotlib.general/8249/focus=8259

And one more message (but look at the entire associated thread):

http://thread.gmane.org/gmane.comp.python.numeric.general/15078/focus=15080

People that would be good to ask that come to mind and from the above
threads would be:

* John Hunter (lead for Matplotlib)
* Travis Oliphant (maybe he wouldn't know, but I bet he knows people who
migrated from matlab)
* Sturla Molden
* Matthew Brett

Thanks,

Jason

David Joyner

unread,
Aug 15, 2011, 5:28:29 PM8/15/11
to sage-...@googlegroups.com
On Mon, Aug 15, 2011 at 3:58 PM, William Stein <wst...@gmail.com> wrote:
> Hi,
>
> If somebody walked up to *you* and asked: "Is Sage now a viable
> alternative to MATLAB?" what would you say?

Great question.

I teach in a predominately applied school and have been in lots of committees
where this issue has come up. The argument I've heard is basically that

(a) math software is a bit of a (necessary) extra burden on the student
who must first learn the theoretical aspects of the topic,

(b) matlab is used in industry more than any other math software,

(c) we should train students to know the most commonly used
software so as to maximize their value to a "potential employer".
(I teach at the USNA, which requires a military service, so by
"potential employer" I mean one after their service commitment
is up and they enter the private sector. AFAIK, the Navy does not
require matlab knowledge in any of their positions, though I do
think that a very good facility with math software *in general* is
of significant importance. In other words, if an officer arrives at
a new job and is told to "learn software X" they should be able to do
so very quickly.)

Do I agree matlab knowledge is very important? No. Do I mention
octave (as a free alternative to matlab) and Sage? Yes. Sadly for the
American taxpayer, this objection to the cost of matlab (which is
very cheap for students but very expensive for professionals) does
not have a serious effect since the engineering dept already requires
matlab.

Conclusion: I think Sage needs more engineers:-)
I presume a "matlab mode" option in the notebook would not hurt.

My 2 cents.

> I'm especially interested in what people who do numerical/applied
> computation think.
>

...

>  -- William
>
> --
> William Stein
> Professor of Mathematics
> University of Washington
> http://wstein.org
>

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

Rob Beezer

unread,
Aug 15, 2011, 6:30:42 PM8/15/11
to sage-devel
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.

We have everything else you need - simple matrix operations
(submatrices, transposes, etc, etc), all the usual functions (sine,
cosine, exponential, etc), a user interface (the notebook). So all
the surrounding bits and pieces are available (and possibly
superior). The "ecosystem" is in place.

We do a few things, thankfully very rarely, where we use exact
algorithms for matrices with floating-point entries (like rank, or
echelon form) and we shouldn't be. For those brought up doing things
exactly (myself included) the approach and philosophy takes some time
to get used to. I have a rant all composed on this subject from
several months ago, but did not unleash it since I wasn't prepared to
follow-up.

I am very interested in working on all of this, as I would like to use
both exact and inexact computations in a "second course" on linear
algebra. Unfortunately, my extended period of time for exclusive Sage
development is coming to an end (I'm writing my sabbatical final
report today).

So hear comes the thread-hijack - plenty to do - I have some patches
posted and plenty of ideas for further work. Look at the bottom of
the table at:
http://wiki.sagemath.org/devel/LatexToWorksheet

Rob

William Stein

unread,
Aug 16, 2011, 2:38:38 AM8/16/11
to sage-...@googlegroups.com
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 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?

-- William


>
> We have everything else you need - simple matrix operations
> (submatrices, transposes, etc, etc), all the usual functions (sine,
> cosine, exponential, etc), a user interface (the notebook).  So all
> the surrounding bits and pieces are available (and possibly
> superior).  The "ecosystem" is in place.
>
> We do a few things, thankfully very rarely, where we use exact
> algorithms for matrices with floating-point entries (like rank, or
> echelon form) and we shouldn't be.  For those brought up doing things
> exactly (myself included) the approach and philosophy takes some time
> to get used to.  I have a rant all composed on this subject from
> several months ago, but did not unleash it since I wasn't prepared to
> follow-up.
>
> I am very interested in working on all of this, as I would like to use
> both exact and inexact computations in a "second course" on linear
> algebra.  Unfortunately, my extended period of time for exclusive Sage
> development is coming to an end (I'm writing my sabbatical final
> report today).
>
> So hear comes the thread-hijack - plenty to do - I have some patches
> posted and plenty of ideas for further work.  Look at the bottom of
> the table at:
> http://wiki.sagemath.org/devel/LatexToWorksheet
>
> Rob
>

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

--

Rob Beezer

unread,
Aug 16, 2011, 3:44:56 AM8/16/11
to sage-devel
On Aug 15, 11:38 pm, William Stein <wst...@gmail.com> wrote:
> 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.

Sorry, I couldn't parse that. Did you mean "would" instead of
"wouldn't"? More directly - it appeared to me that the "popular"
matrix decompositions in MATLAB were all (or almost all) available to
be wrapped from SciPy/NumPy as Sage methods for RDF/CDF matrices.

> 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.

I have to be careful, because I would not claim to be a numerical
linear algebraist, so I am willing to be corrected - but I think an LU
decomposition would be the first choice for an alternative to rref.
It is basically what we used to call Gaussian elimination, rather than
Gauss-Jordan elimination, but with more care about pivoting in a
numerical setting. Enabling LU decomposition for rectangular matrices
(not just square), which is now possible in NumPy/SciPy, is a patch
with a positive review (iirc) and I have posted a patch for an exact
LU decomposition, which is able to run over generic rings twice as
fast as echelon form (as theory would predict). Needs review. An LU
decomposition is the lever for a similar speedup (2x) in solve_left()
over generic rings.

> 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).

I would vote for not allowing a naive/classical rref algorithm from
Sage to be applied to a matrix over RDF/CDF.

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

Consider the primary numerical matrix decompositions - LU, QR, SVD,
Cholesky, Schur. Rough recollection - and it depends on patches in-
progress - these are available in MATLAB, and almost all are also
available for Sage RDF/CDF matrices (maybe just Cholesky needs
attention). Some are available for exact Sage matrices (modulo
finding exact eigenvalues in some cases). Along with straight-out
numerical eigenvalues for Sage RDF/CDF matrices, and exact Jordan
canonical form and exact rational canonical form (over *any* field),
I'd posit roughly 75% coverage by Sage in this area, exact and RDF/CDF
combined. Maybe higher.

Rob

daly

unread,
Aug 16, 2011, 3:50:08 AM8/16/11
to sage-...@googlegroups.com
MIT's online linear algebra course with Gilbert Strang
mentions rref as one of the very first functions in Matlab.

Pedro Cruz

unread,
Aug 16, 2011, 6:41:36 AM8/16/11
to sage-...@googlegroups.com

Dear Sage project leader,

My experience is about Sage 4.6.2:

For numerical computations I have quieted of Sage/Sagenotebook and use only scipy/numpy directly using vim and shell. 

Sagenotebook has the advantage of shareable over the net worksheets but the editing 83 functions on it became hardwork because of those jumps on screen and no colors. I had problems making/seeing graphics. (maybe that is not a problem now)

Sage has the advantage of symbolic calculus which could help confirming some numerical calculations but the integration with scipy/numpy needs some attention to know if a given parameter is in Sage world or scipy/numpy world. Also Sage has the problem of taking to much time to load and using "attach" reveals some problems.

This is what I remember that lead me to the decision of quiting sage/sagenotebook for the specific purpose of pure numerical computation. (matlab was never needed).

I will improve this notes as soon as a new numerical projects began. Is there any thematic group or wiki for "numerical sage" ?

Pedro Cruz

Assistant Teacher

University of Aveiro

Portugal

Jason Grout

unread,
Aug 16, 2011, 8:32:15 AM8/16/11
to sage-...@googlegroups.com


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

Jason Grout

unread,
Aug 16, 2011, 8:41:45 AM8/16/11
to sage-...@googlegroups.com
On 8/16/11 2:44 AM, Rob Beezer wrote:

> I have to be careful, because I would not claim to be a numerical
> linear algebraist, so I am willing to be corrected - but I think an LU
> decomposition would be the first choice for an alternative to rref.
> It is basically what we used to call Gaussian elimination, rather than
> Gauss-Jordan elimination, but with more care about pivoting in a
> numerical setting. Enabling LU decomposition for rectangular matrices
> (not just square), which is now possible in NumPy/SciPy, is a patch
> with a positive review (iirc) and I have posted a patch for an exact
> LU decomposition, which is able to run over generic rings twice as
> fast as echelon form (as theory would predict). Needs review. An LU
> decomposition is the lever for a similar speedup (2x) in solve_left()
> over generic rings.
>


A long time ago, I also wrote an LU decomposition patch that used at
least two different types of pivoting. See
http://trac.sagemath.org/sage_trac/ticket/3048

> I would vote for not allowing a naive/classical rref algorithm from
> Sage to be applied to a matrix over RDF/CDF.


-1 if there is no way to do it, as it serves an important pedagogical
purpose. However it definitely should not be the default. LU
decomposition with partial pivoting should be the default, IIRC (but the
same disclaimer that you give above applies to me :).

Thanks,

Jason


Dima Pasechnik

unread,
Aug 16, 2011, 3:17:42 PM8/16/11
to sage-...@googlegroups.com
Yes and no. I know a largish community, people working on interior point methods for nonlinear optimization, where it is rather hard to get around without Matlab. Partly this is due to relative easiness of creating Matlab interfaces to C and Fortran code, which makes experimenting easier---- Matlab is used as a fronend to advanced high performance code. Sometimes to the point that the only way to use this code is to call it from Matlab. Partly it's inertia, of course.

Dima

Kresimir Kumericki

unread,
Aug 16, 2011, 3:49:17 PM8/16/11
to sage-...@googlegroups.com
On Tuesday, August 16, 2011 12:41:36 PM UTC+2, Pedro Cruz wrote:
 Sagenotebook has the advantage of shareable over the net worksheets but the editing 83 functions on it became hardwork because of those jumps on screen

This is exactly my feeling. In my case (I do both symbolical and numerical stuff in my research), I use sage for fast prototyping of a new project, but when stuff gets serious I export everything to python-numpy-vim because jumping around huge worksheet is just too awkward and slows me down.  But this is mostly objection to notebook interface (colapsible notebook sections would solve most of my problems). Sage backend itself
has enough numerical capabilities for me (although I don't really do heavy-duty numerics, and I came from Mathematica, not MATLAB).

Kresimir

Simon King

unread,
Aug 16, 2011, 4:29:44 PM8/16/11
to sage-devel
Hi Kresimir, hi all,

On 16 Aug., 21:49, Kresimir Kumericki <kku...@gmail.com> wrote:
> ... I use sage for fast prototyping of a new project, but
> when stuff gets serious I export everything to python-numpy-vim because
> jumping around huge worksheet is just too awkward and slows me down.

My impression of the sage notebook is a bit similar: It is very good
for doing a presentation or teaching in class, and it is good enough
if one is in an internet café that only provides a browser but not
putty.

However, when doing the real work (which is algebra, quite far from
numerics), the tool has always been emacs+vim+"sage on command line"
for me.

Why is it "python-numpy-vim" to you?

What is the reason for it not being "c-python-cython-sage-vim" resp.
"c-python-cython-sage-emacs"? I think an answer to that question could
reveal a spot where Sage could improve in order to be a viable
alternative to Matlab.

Cheers,
Simon

Jordi Gutiérrez Hermoso

unread,
Aug 16, 2011, 5:34:05 PM8/16/11
to sage-...@googlegroups.com, Octave Maintainers List
I'm cross-posting this to the Octave maintainers' mailing list in case
other maintainers also want to comment on it or correct anything I say
here.

On 15 August 2011 14:58, 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? I'm especially
> interested in what people who do numerical/applied computation
> think.

With Octave we deal with people like this all the time. They basically
want Matlab, not a substitute, because their
instructor/employer/whoever has told them it must be Matlab and it
can't be anything else. They often also have code written in Matlab
that can't be translated. In the case of running the exact same code,
which happens very frequently with Matlab, I can tell you that for
these people rewriting their code in Scipy isn't an alternative (I am
obviously also referrring to Numpy, as the core component of Scipy).

One of the most frequent requests we get in Octave and then everyone
will magically jump ship from Matlab is to implement a GUI (or an
editor, or a profiler, or an integrated debugger, or all of Simulink).
They want it to look almost exactly like Matlab too, or else they
won't use it. For a long time we've ignored this request, but it comes
up so often that it's hard to keep ignoring it, and a
Matlabish-looking GUI is a release goal for our next version, and the
work is well underway.

There are also a lot of people for whom Matlab is only incidental and
what they really want is Simulink. For this, neither scipy nor Octave
have any sort of alternative, but I understand Scilab has something
called Xcos that does sort of work like Simulink.

Matlab users also tend to have highly specific requests. They want the
*exact* same function from some particular Matlab toolbox and they
want it to work the same way in Octave (or presumably, a direct
equivalent in Scipy), even for silly things like rref because, again,
their instructor/employer/whoever told them that that is the function
they must use. I have recently started working with Scipy, and my
impression is that it has smaller set of contributed functions than
Octave and smaller than Matlab, so when someone from Matlab wants this
or that low-pass filter and accepts no substitute, they get easily
frustrated with the free alternatives and go back to Matlab. A big gap
in Scipy due to silly licencing issues is FFTW, which is the de-facto
standard FFT library both Octave and Matlab use; FFTPACK is an ok
substitute and all that Scipy has. Signal processing is one of
Matlab's biggest use cases and a poor FFT implementation is
problematic.

I imagine demanding users like this exist for the other three big M's
too, but Matlab to me seems to have a well-entrenched niche separate
from the other three M's whoh at least somewhat compete with each
other, whereas Matlab has no direct big competitor. The competition in
the other three M's has at least opened up the users of those CASes to
the possibility of learning a new syntax, but my impression is Matlab
users are less flexible in this regard.

HTH,
- Jordi G. H.
GNU Octave developer

Chris Godsil

unread,
Aug 16, 2011, 11:37:02 PM8/16/11
to sage-devel
I have not used matlab a lot, and not for some time, but I have
colleagues in
numerical optimization who use it heavily. I think there is
essentially no chance
that such people would move from matlab to sage. The only complaints I
have heard are
occasional mutterings about licensing. Matlab has very close
connections with academics
working in various forms of numerical analysis, and this is one of its
strengths.
The user interface is functional and pleasant to use. (Sage's syntax
is very wordy and
tab completion is at best poor compensation. I recognize this will not
be easily fixed.)

One big advantage of sage is that one can do numerical calculations
along with
computations in algebra or number theory or graph theory...
For my own work I find myself wanting to do numerical computations on
adjacency matrices
of graphs. For this matlab is not very useful because it is awkward to
generate the graphs
or read them in from a unix pipe. And if I wanted to compute an
automorphism group, I am
entirely lost. So I have been using sage for numerical computations.
The good news is that it works.

The bad news is that it is a very frustrating experience. To
illustrate with an example,
I wanted to compute spectral decompositions of symmetric real
matrices. This means I need
the eigenvalues and an orthogonal basis for each eigenspace. I must
use scipy/numpy,
because sage does not recognise that eigenvalues of symmetric matrices
are real.
Now the fun starts. The sort
of incantations needed to load stuff from numpy and scipy are
difficult to sort out. Basically
you make some semi-random trials until the output seems plausible, and
then hope everything
is working. The fact that the syntax for scipy and numpy differs from
that of sage is just
one more nuisance. For documentation, sage punts to the documentation
for scipy and numpy,
which is poor (and does not seem to be written by people who
understand numerical computation).

A more general issue is that, once I decide I want to work in floating
point, I want to stay
in floating point. I do not really want to deal with stuff like:

> sage: sin(2.0*pi)
> sin(2.00000000000000*pi)

And I'd love to see an engineer's face when s/he enters A.kernel() and
gets
back a message about free modules.

I agree strongly with comments of Pedro and Simon that editor+shell is
superior to the notebook
for this sort of work.

To finish, a few key points:
1. When I am doing numerical linear algebra, I'd like code to return
scalars, vectors, matrices.
So A.kernel() should just return either a basis or a matrix, for
example. The default routines
should call LAPACK or an equivalent, and we should have access to as
many of these as possible.
(All actual code should have been written by a professional numerical
analyst.)

2. Any computation which contains a floating point number or variable
should return
a floating point variable.

3. The syntax and behaviour should be consistent, whether I am doing
numerical linear algebra,
linear programming, semidefinite optimization, numerical
integration,...

Dima Pasechnik

unread,
Aug 17, 2011, 3:54:48 AM8/17/11
to sage-...@googlegroups.com
Chris,

On Wednesday, 17 August 2011 11:37:02 UTC+8, Chris Godsil wrote:
[...]

One big advantage of sage is that one can do numerical calculations
along with
computations in algebra or number theory or graph theory...
For my own work I find myself wanting to do numerical computations on
adjacency matrices
of graphs. For this matlab is not very useful because it is awkward to
generate the graphs
or read them in from a unix pipe. And if I wanted to compute an
automorphism group, I am
entirely lost. So I have been using sage for numerical computations.
The good news is that it works.

The bad news is that it is a very frustrating experience. To
illustrate with an example,
I wanted to compute spectral decompositions of symmetric real
matrices. This means I need

actually, did you try the built-in functionality for graph eigenvalues? I imagine it would alleviate some of your complaints. E.g.

sage: g=graphs.OctahedralGraph()  
sage: g.eigenspaces()
[
(4, Vector space of degree 6 and dimension 1 over Rational Field
User basis matrix:
[1 1 1 1 1 1]),
(-2, Vector space of degree 6 and dimension 2 over Rational Field
User basis matrix:
[ 1  0 -1 -1  0  1]
[ 0  1 -1 -1  1  0]),
(0, Vector space of degree 6 and dimension 3 over Rational Field
User basis matrix:
[ 1  0  0  0  0 -1]
[ 0  1  0  0 -1  0]
[ 0  0  1 -1  0  0])
]

Tim Lahey

unread,
Aug 17, 2011, 4:16:37 AM8/17/11
to sage-...@googlegroups.com
On Mon, Aug 15, 2011 at 3:58 PM, William Stein <wst...@gmail.com> wrote:
> Hi,
>
> If somebody walked up to *you* and asked: "Is Sage now a viable
> alternative to MATLAB?" what would you say?
> I'm especially interested in what people who do numerical/applied
> computation think.

I'm an engineer and I use MATLAB pretty extensively so I think I can
provide that viewpoint. Sage isn't really a viable alternative to
MATLAB and really isn't likely to be any time soon. The SciPy/NumPy
parts cover the basics of MATLAB, but most people use a number of
toolboxes that go beyond the basics. In my case, I use the System
Identification toolbox, the Spline toolbox, and some of the
optimization routines. In addition, I have a lot of existing code that
I rely upon that I'd have to convert.

The Spline toolbox I could reproduce a lot with the B-Spline routines
from the SLATEC library. The Fortran routines there are from de Boor's
Splines textbook (which is also the basis for the Spline toolbox). The
System ID toolbox is partially implemented in Octave (and possibly in
SciPy), but I've found no open source implementation of the routine I
find essential, ETFE (Empirical Transfer Function Estimate) which
given a set of input data and a set of output data will estimate the
transfer function.

Oh, I also rely upon Code Generation routines in Maple that output
MATLAB code. I could have them output Fortran or C, but then I'd have
to look at how to interface with them as well (but that's likely not
as seamless).

This is even aside from things like embedded code generation or Simulink.

I think you'd find that most people will run into cases where at least
one routine they need isn't supported. Now, that's been happening with
Octave and as such, they've been getting better toolbox support, but I
know I'd have to improve at least their System ID support before I
could think about switching.

Cheers,

Tim.

--
Tim Lahey
PhD Candidate, Systems Design Engineering
University of Waterloo
http://about.me/tjlahey

Chris Godsil

unread,
Aug 17, 2011, 8:59:27 AM8/17/11
to sage-devel
Dima

Thanks for the comments. First I was aware of the eigenspaces()
command. I am also aware that things are
improving all the time. For my actual example I needed an orthonormal
basis for each eigenspace and the
graphs are pretty random, so the eigenvalues are more or less
arbitrary reals.

Second, I was using the spectral decomposition problem only as an
example. The main point of my message is that
to use the numerical stuff you have to be quite dedicated.

And equally important, I did succeed in doing what I wanted and I
would not have been able to do it
without sage!

Chris

kcrisman

unread,
Aug 17, 2011, 10:13:32 AM8/17/11
to sage-devel
I didn't ask the question, but still want to really thank Tim, Chris,
and Jordi for their detailed, thoughtful and incisive comments that
greeted my RSS feed this morning! Very useful and informative.

- kcrisman

Dima Pasechnik

unread,
Aug 17, 2011, 11:10:09 AM8/17/11
to sage-...@googlegroups.com
graph eigenspaces (with default settings, maybe they can be tweaked?) are quite adequate for up to 25-30 vertices, then it get very slow, indeed...

For the kind of computations you have in mind, I prefer using cvxopt (a Sage package); although it's primarily 
for optimization, it has a nice sparse matrices support, and nice LAPACK interface:

its interface to Sage is quite rudimentary, but still...

Dima

Jason Grout

unread,
Aug 17, 2011, 11:36:41 AM8/17/11
to sage-...@googlegroups.com
On 8/17/11 7:59 AM, Chris Godsil wrote:
> Dima
>
> Thanks for the comments. First I was aware of the eigenspaces()
> command. I am also aware that things are
> improving all the time. For my actual example I needed an orthonormal
> basis for each eigenspace and the
> graphs are pretty random, so the eigenvalues are more or less
> arbitrary reals.


I might mention several other things. In fact, I was going to mention
this yesterday to show how using them was just as easy as MATLAB, but
after constructing the last example below, I realized you were right and
matlab was way easier! Anyways:

1. You can use the -pylab option to load a matlab-like environment
(which means you don't have to figure out a lot of the imports). The
-pylab option is actually an option to ipython (i.e., not
sage-specific), but works just as well with Sage:

sage: g=graphs.OctahedralGraph()
sage: a=g.am().numpy()
sage: eig(a) # matlab-like command from numpy/scipy through pylab
(array([ 4.00000000e+00, 1.40614246e-16, -2.00000000e+00,
-2.00000000e+00, -7.71031068e-17, -2.11137087e-16]), array([[
-4.08248290e-01, -7.07106781e-01, -5.77350269e-01,
-9.58724220e-02, -8.33596830e-18, -2.93912896e-17],
[ -4.08248290e-01, -8.75811329e-17, 2.88675135e-01,
-4.45121959e-01, 2.13205450e-01, 5.03280679e-01],
[ -4.08248290e-01, -5.98255573e-17, 2.88675135e-01,
5.40994381e-01, -6.74198366e-01, -4.96697653e-01],
[ -4.08248290e-01, -3.20699816e-17, 2.88675135e-01,
5.40994381e-01, 6.74198366e-01, 4.96697653e-01],
[ -4.08248290e-01, -3.20699816e-17, 2.88675135e-01,
-4.45121959e-01, -2.13205450e-01, -5.03280679e-01],
[ -4.08248290e-01, 7.07106781e-01, -5.77350269e-01,
-9.58724220e-02, 2.96978775e-17, 1.90446830e-17]]))


2. or you could use Sage's eigenmatrix_right command:

sage: g.am().eigenmatrix_right()
(
[ 4 0 0 0 0 0] [ 1 1 0 1 0 0]
[ 0 -2 0 0 0 0] [ 1 0 1 0 1 0]
[ 0 0 -2 0 0 0] [ 1 -1 -1 0 0 1]
[ 0 0 0 0 0 0] [ 1 -1 -1 0 0 -1]
[ 0 0 0 0 0 0] [ 1 0 1 0 -1 0]
[ 0 0 0 0 0 0], [ 1 1 0 -1 0 0]
)

which gives a much nicer orthogonal basis (columns of the right matrix)!

3. Or you could explicitly use the eigenvectors command, which gives the
eigenvalues and for each eigenvalue, a list of eigenvectors and the
algebraic multiplicity.

sage: g.eigenvectors()
[(4, [
(1, 1, 1, 1, 1, 1)
], 1), (-2, [
(1, 0, -1, -1, 0, 1),
(0, 1, -1, -1, 1, 0)
], 2), (0, [
(1, 0, 0, 0, 0, -1),
(0, 1, 0, 0, -1, 0),
(0, 0, 1, -1, 0, 0)
], 3)]

4. The reason I decided you were right about matlab was when I tried to
do the commands exactly as it would be in matlab, it looked a lot harder
than my example matlab session. Note again this is with sage -pylab

sage: a=array([[1,2,3],[4,5,6],[7,8,9]])
sage: b=a.dot(a.T) # b=a*a'
sage: eig(b)
(array([ 2.83858587e+02, 1.14141342e+00, -1.90551232e-15]),
array([[-0.21483724, -0.88723069, 0.40824829],
[-0.52058739, -0.24964395, -0.81649658],
[-0.82633754, 0.38794278, 0.40824829]]))


The "dot" above is really bothersome, especially since *. (i.e., star
*dot*) in matlab is the same as "*" for numpy arrays. Numpy folks have
been trying to get python to change for years and allow multiple
multiplication characters, and it probably isn't going to change anytime
soon. The "array" command above is also much harder than the matlab
a=[1 2 3; 4 5 6; 7 8 9].

You can make it a little easier in numpy if you use the numpy "matrix"
objects, but they are not extremely well-supported by numpy, so I avoid
them as much as possible. Note that "matrix" below is the *scipy*
matrix command, since -pylab overwrote Sage's matrix command. However,
matrix multiplication works naturally below, and the matrix-creating
command uses matlab-like syntax.

sage: a=matrix("1 2 3; 4 5 6; 7 8 9")
sage: a
matrix([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
sage: b=a*a.T
sage: eig(b)
(array([ 2.83858587e+02, 1.14141342e+00, -1.90551232e-15]),
matrix([[-0.21483724, -0.88723069, 0.40824829],
[-0.52058739, -0.24964395, -0.81649658],
[-0.82633754, 0.38794278, 0.40824829]]))


One conclusion: we should make Sage's matrix command accept a string
like the above example and parse it as matlab would.

Thanks,

Jason


Ivo Hedtke

unread,
Aug 17, 2011, 11:40:49 AM8/17/11
to sage-...@googlegroups.com

Am 17.08.2011 um 17:36 schrieb Jason Grout:

> One conclusion: we should make Sage's matrix command accept a string like the above example and parse it as matlab would.

+1

Jason Grout

unread,
Aug 17, 2011, 12:00:08 PM8/17/11
to sage-...@googlegroups.com

Another option is to make the preparser recognize syntax like:

[1 2 3; 4 5 6; 7 8 9]

or even

[A B; C D]

for making a matrix by stacking and concatenating matrices.

I don't know how strong of a case we could make for such a preparser
change, though. It'd have to have lots of support before it would even
be considered seriously.

Jason


Jordi Gutiérrez Hermoso

unread,
Aug 17, 2011, 4:34:32 PM8/17/11
to sage-...@googlegroups.com
On 17 August 2011 03:16, Tim Lahey <tim....@gmail.com> wrote:

> I think you'd find that most people will run into cases where at
> least one routine they need isn't supported. Now, that's been
> happening with Octave and as such, they've been getting better
> toolbox support, but I know I'd have to improve at least their
> System ID support before I could think about switching.

It seems like every dedicated Matlab user has a specific feature
request without which they absolutely can't use Octave (or Scilab or
Scipy). When I was but a wee lad, for me it was Matlab's JIT (although
I didn't even know that I was using it). I've learned to change my
habits to work with what Octave has, and I submit patches for what I
wish it had.

That being said, what is the system identification toolbox? The
Mathworks makes it look like it's a combination of Simulink with
something else.

- Jordi G. H.

Tim Lahey

unread,
Aug 17, 2011, 4:55:07 PM8/17/11
to sage-...@googlegroups.com
2011/8/17 Jordi Gutiérrez Hermoso <jor...@octave.org>:

>
> That being said, what is the system identification toolbox? The
> Mathworks makes it look like it's a combination of Simulink with
> something else.
>

There may be connections with Simulink, but on the whole it doesn't
have anything to do with it. The toolbox is based upon the book,
"System Identification - Theory for the User" By Lennart Ljung. It
uses various methods to get models of a system. Basically, it fits
data to differing kinds of models. The method I use ETFE (Empirical
Transfer Function Estimate) in the end gives a frequency spectrum
corresponding to the system's plant (based upon the given input and
output data). It's different than just doing a FFT on the output data.
But there are methods for Linear Time-Invariant systems, as well as
time-varying and non-linear systems. Most of the toolbox is centred
around these models and parameter estimation. Using the ETFE I'm not
limited to a specific model since the approach treats the system like
a black box getting a model of what happens based upon input and
output data alone rather than trying to fit to a specific modelling
approach (other than assuming the system is linear).

Documentation:
http://www.mathworks.com/help/toolbox/ident/

And the specific function I use most:
http://www.mathworks.com/help/toolbox/ident/ref/etfe.html

One of the advantages is that I can customize the output frequency
resolution. This is handy when I'm trying to find the natural
frequency since I need good resolution around the damped natural
frequency peaks.

Rob Beezer

unread,
Aug 17, 2011, 4:58:13 PM8/17/11
to sage-devel
On Aug 17, 9:00 am, Jason Grout <jason-s...@creativetrax.com> wrote:
> Another option is to make the preparser recognize syntax like:
>
> [1 2 3; 4 5 6; 7 8 9]

The preparser is evil. ;-)

Seriously, if we are going to preparse a matrix, I should think we
would allow multiline input as a prerequisite.

http://trac.sagemath.org/sage_trac/ticket/11621

Rob

Dan Drake

unread,
Aug 17, 2011, 8:45:04 PM8/17/11
to sage-...@googlegroups.com
On Wed, 17 Aug 2011 at 10:36AM -0500, Jason Grout wrote:
> Note that "matrix" below is the *scipy* matrix command, since -pylab
> overwrote Sage's matrix command. However, matrix multiplication works
> naturally below, and the matrix-creating command uses matlab-like
> syntax.
>
> sage: a=matrix("1 2 3; 4 5 6; 7 8 9")
> sage: a
> matrix([[1, 2, 3],
> [4, 5, 6],
> [7, 8, 9]])
> sage: b=a*a.T
> sage: eig(b)
> (array([ 2.83858587e+02, 1.14141342e+00, -1.90551232e-15]),
> matrix([[-0.21483724, -0.88723069, 0.40824829],
> [-0.52058739, -0.24964395, -0.81649658],
> [-0.82633754, 0.38794278, 0.40824829]]))
>
>
> One conclusion: we should make Sage's matrix command accept a string
> like the above example and parse it as matlab would.

This is now #11699: http://trac.sagemath.org/sage_trac/ticket/11699

I agree with Rob; this probably should be in matrix(), and not in the
preparser.

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc

Nils Bruin

unread,
Aug 17, 2011, 10:47:40 PM8/17/11
to sage-devel
>  signature.asc
> < 1KViewDownload

Nils Bruin

unread,
Aug 17, 2011, 11:02:37 PM8/17/11
to sage-devel
On Aug 17, 5:45 pm, Dan Drake <dr...@kaist.edu> wrote:
> This is now #11699:http://trac.sagemath.org/sage_trac/ticket/11699
>
> I agree with Rob; this probably should be in matrix(), and not in the
> preparser.

Are you thinking of having matrix(s) [with s a string] being
equivalent to

matrix([[eval(a) for a in r.strip().split(" ")] for r in
s.split(";")])

or something like that? It probably needs some cleaning to be tolerant
of more types of whitespace (perhaps it should also accept commas?)
and perhaps it should handle a "\n" as a ";".

The bigger problem is: How do you convert the strings representing
matrix entries to sage? What is going to be the base ring of the
matrix? This determines what to use instead of the "eval" above. Such
problems do not arise in Matlab because of the more limited scope: the
only numerical type is a float (double probably). In Sage it is not so
easy. In fact, you can already see that for matrix([[...],...]), sage
already exhibits surprising behaviour (although perfectly to
specifications):

sage: matrix([[1.00000000000000000000000000000]]).base_ring()
Real Field with 100 bits of precision
sage: matrix([[1.00000000000000000000000000000,1.000]]).base_ring()
Real Field with 53 bits of precision

(the common parent of two floats is the parent of the lower precision
one).

Jason Grout

unread,
Aug 17, 2011, 11:15:06 PM8/17/11
to sage-...@googlegroups.com
On 8/17/11 10:02 PM, Nils Bruin wrote:
> On Aug 17, 5:45 pm, Dan Drake<dr...@kaist.edu> wrote:
>> This is now #11699:http://trac.sagemath.org/sage_trac/ticket/11699
>>
>> I agree with Rob; this probably should be in matrix(), and not in the
>> preparser.
>
> Are you thinking of having matrix(s) [with s a string] being
> equivalent to
>
> matrix([[eval(a) for a in r.strip().split(" ")] for r in
> s.split(";")])
>
> or something like that? It probably needs some cleaning to be tolerant
> of more types of whitespace (perhaps it should also accept commas?)
> and perhaps it should handle a "\n" as a ";".

I've added example code to the ticket. Here is the current iteration:

# if a was the string passed in as the list of elements
a=a.replace(',', ' ').replace(';','\n') # or a.translate(s)
rows = a.split('\n')
# throw away empty rows
rows = [r for r in rows if r.strip()]
elements=[map(sage_eval, r.split()) for r in rows]
# now continue matrix processing with "elements" as the list of elements


Or if we could afford to initialize something at the module level, we'd
initialize this:

import string
s=string.maketrans(';,','\n ')

and replace the first line above with:

a=a.translate(s)

>
> The bigger problem is: How do you convert the strings representing
> matrix entries to sage? What is going to be the base ring of the
> matrix? This determines what to use instead of the "eval" above. Such
> problems do not arise in Matlab because of the more limited scope: the
> only numerical type is a float (double probably). In Sage it is not so
> easy.

This would be determined by the other arguments to matrix. I'm
proposing that the string would just take the place of the normal nested
list of entries, wherever it is, and would be interpreted as if they had
typed in a normal nested list of entries (using sage_eval). Thus, the
string would be converted to a nested list at the top of the matrix
constructor function.

Jason

Rob Beezer

unread,
Aug 18, 2011, 1:27:38 AM8/18/11
to sage-devel
On Aug 17, 8:02 pm, Nils Bruin <nbr...@sfu.ca> wrote:
> The bigger problem is: How do you convert the strings representing
> matrix entries to sage? What is going to be the base ring of the
> matrix? This determines what to use instead of the "eval" above.

Seems this thread *has* been hijacked. ;-)

I believe current behavior is buried in the Sequence() constructor,
which will determine a "universe" for the elements of a list. I am
reasonably confident this is where entries go in matrix() if a ring is
not provided, and for the purpose of finding a ring to hold all the
entries, but I have never carefully looked at the code/logic for
Sequence().

Rob

Robert Bradshaw

unread,
Aug 18, 2011, 1:29:13 AM8/18/11
to sage-...@googlegroups.com

Yes, this code is already there.

> I'm proposing
> that the string would just take the place of the normal nested list of
> entries, wherever it is, and would be interpreted as if they had typed in a
> normal nested list of entries (using sage_eval).  Thus, the string would be
> converted to a nested list at the top of the matrix constructor function.

To throw my 2 cents in, I'm not opposed to expanding the preparser to
handling [a, b; c, d] as matrix literals. Accepting strings is nice,
but not as natural (e.g. one looses tab completion and errors are much
more indirect). Splitting on spaces is error prone (e.g. "1 + sin(x)")
and so is naively splitting on commas [1, 2; pi, f(3, 4)]."

- Robert

dahl.j...@gmail.com

unread,
Aug 18, 2011, 1:37:19 AM8/18/11
to sage-devel
I develop optimization software professionally, and I use both Matlab
and Python
extensively.

I only use Matlab for prototyping numerical algorithms and inspecting
and manipulation matrices. I tend to stick with Matlab/Octave because
constructing/inspecting matrices is so simple and the linear algebra
expression are simple and look similar to what I started with on
paper.
I don't use Matlab as a real programming language, and I've never had
to
use any of the toolboxes.

I use Python whenever I need to prototype a more complicated
algorithm,
where the challenge is more on efficient data structures, etc., than
straightforward linear algebra. For me, Python works perfectly for
such
problems.

What I personally want from Python, for it to be a viable alternative
to Matlab is the following (viewpoints that I believe are shared by
many colleagues in academia and industry):

* Simple construction of sparse dense and matrices. Simple linear
algebra. We are working on matrices, so the datastructures should
be and act like matrices. Matlab got it right, why change it? In
99% of the time, I need ordinary 2D matrices, so make that feel simple
and natural.

* It's fine that some things only work for dense matrices and others
only
work for sparse matrices, but both datatypes should be present, and
whatever you expect to be able to do with them from C, you should be
able to do simply from Python.

* Easy interface to sparse and dense matrices from C.

A while back I was involved in developing a Python software package
CVXOPT (included in Sage, by the way), where we had to develop our
own matrix library because there was no viable alternative at the
time.
Since then Numpy/Scipy probably improved, but they still feel like
they were designed by people who did not have numerical linear algebra
in mind.

Jason Grout

unread,
Aug 18, 2011, 9:35:21 AM8/18/11
to sage-...@googlegroups.com


Good point. It turns out to be much harder if we don't just assume
numbers. I guess one way to do it would be to construct a parse tree
using the python parsing, except, of course, that semicolons make [1 2
3; 4 5 6] not valid syntax, though I suppose we could replace semicolons
and newlines with "][" and then filter out empty lists. Spaces also
would be problem in constructing a parse tree, since [1 2] isn't valid
syntax.

So yeah, expanding the preparser for this very common situation (easily
creating a doubly-nested list) is starting to look more like a good idea.

If we expanded the preparser, would [1 2; 3 4] create a matrix or just a
doubly-nested list? I can see arguments both ways, and this is where
Nils point really hits home. Almost always, I want matrices over QQ,
but [1 2; 3 4] won't naturally create a matrix over QQ. On the other
hand, typing matrix(QQ, [1 2; 3 4]) seems to take the fun out of the
syntax, since it's not too much easier than matrix(QQ, [[1,2], [3,4]])


Jason

John Cremona

unread,
Aug 18, 2011, 10:00:26 AM8/18/11
to sage-...@googlegroups.com
>
> Good point.  It turns out to be much harder if we don't just assume numbers.
>  I guess one way to do it would be to construct a parse tree using the
> python parsing, except, of course, that semicolons make [1 2 3; 4 5 6] not
> valid syntax, though I suppose we could replace semicolons and newlines with
> "][" and then filter out empty lists.  Spaces also would be problem in
> constructing a parse tree, since [1 2] isn't valid syntax.
>
> So yeah, expanding the preparser for this very common situation (easily
> creating a doubly-nested list) is starting to look more like a good idea.
>
> If we expanded the preparser, would [1 2; 3 4] create a matrix or just a
> doubly-nested list?  I can see arguments both ways, and this is where Nils
> point really hits home.  Almost always, I want matrices over QQ, but [1 2; 3
> 4] won't naturally create a matrix over QQ.  On the other hand, typing
> matrix(QQ, [1 2; 3 4]) seems to take the fun out of the syntax, since it's
> not too much easier than matrix(QQ, [[1,2], [3,4]])

Some of the code used to manage this:

sage: M = matrix(2,2,[1,2,3,4])
sage: PM = pari(M)
sage: PM
[1, 2; 3, 4]
sage: PM.sage()
[1 2]
[3 4]

could perhaps be reused like this:

sage: s = "[1,2;3,4]"
sage: pari(s).sage()
[1 2]
[3 4]
sage: s = "[1.1,2.2;3.3,4.4]"
sage: pari(s).sage()
[1.1000000000000000000000000000000000000
2.2000000000000000000000000000000000000]
[3.3000000000000000000000000000000000000
4.4000000000000000000000000000000000000]

so we are using the pari parser to construct a pari matrix, which then
knows how to be converted into sage.

John

Johan S. R. Nielsen

unread,
Aug 19, 2011, 3:55:58 AM8/19/11
to sage-devel
>
> Seems this thread *has* been hijacked. ;-)

Just want to add my opinion, which belongs in some void between the
original thread and the hijacked one ;-)

I am a ph.d. student in algebra, but have a background in computer
science. I don't do much numerics anymore, so I'm not exactly the
right person to ask, but I do hang around with a lot of numerics
people. So far, I agree with some of the very insightful comments on
the problems with working numerically in Sage *once you got the
matrices* that has come up (like the posts from Jordi Hermoso, Chris
Godsil and Tim Lahey).

However, I really don't believe that the current matrix-construction
syntax is what is seriously keeping Matlab people away from Sage --
and if it is, then that's simply silly! Comparing

M = [1 2;
3 4;
5 6]

with

M = matrix(RR,2,3,[
1, 2,
3, 4,
5, 6 ])

that's a very small syntax price to pay for 1) unambiguous,
straightforward syntax 2) complete control of element space. I always
disliked Matlab for its happy-go-lucky, ambiguous syntax, and I think
it is unnecessary to make specialised, ad-hoc syntax in Sage for (2D)
matrices (over X-bit floats).

My impression from my own math department is that a lot of Matlab
users know more or less only Matlab as a programming language, and
that they have always used this, and their advisor also used/s this.
They have the opinion that it is really difficult to learn a new
language, and will dislike *any* difference between Matlab and
"Alternative X", no matter how minute (much like Jordi mentioned
earlier). I think it would be silly to start introducing Matlab syntax
and renaming functions to look as much as possible like Matlab for
this reason. The ex-Matlab users would not stop complaining until Sage
was a completely compatible superset of Matlab anyway.

On the other hand, I think it would of course think it would be great
if all functionality needed for numerics people would be readily
available in Sage. Though not at the expense of a dichotomised syntax
and namespace to cater for Matlab devotees. In time, I think this
would make people migrate to Sage because of expense, ideology and
functionality.

Cheers,
Johan S. R. Nielsen

dahl.j...@gmail.com

unread,
Aug 19, 2011, 5:54:23 AM8/19/11
to sage-devel
Personally I don't mind that the syntax is different.

I was about to give some examples of indexing and slicing
of Numpy arrays, which I remembered to be odd for matrices, but
then I realized that the indexing/slicing works exactly like
I expect it to, e.g.,

>>> A[:, i]

picks out the i'th column. Has this always been the case
with Numpy? If that's the case, some of my objections
against Numpy are based on my own ignorance.

On Aug 19, 9:55 am, "Johan S. R. Nielsen" <J.S.R.Niel...@mat.dtu.dk>
wrote:

leif

unread,
Aug 19, 2011, 6:02:14 AM8/19/11
to sage-devel
On 19 Aug., 09:55, "Johan S. R. Nielsen" <J.S.R.Niel...@mat.dtu.dk>
wrote:
I mostly agree with Johan, especially in not (by default) adding lots
of alternate syntax from other programs to Sage, just to become kind
of (superficially) "compatible".

It shouldn't be that hard to implement functions which at least
partially translate MATLAB / Mma / whatever syntax (passed as a
string, or from a file) to corresponding Sage expressions and
commands, analoguous to preparse().

This could help [some of the] users familiar with or used to e.g.
MATLAB migrate to Sage.

We could then perhaps even support different input *modes*, but we
IMHO shouldn't try to accept all at the same time.

Another aspect of course is providing all the functions typically used
in numerical applications.


My 2 ct,

-leif

Harald Schilly

unread,
Aug 19, 2011, 6:07:23 AM8/19/11
to sage-...@googlegroups.com
Hi, I also studied numerical mathematics and I completely agree on you:

On Friday, August 19, 2011 9:55:58 AM UTC+2, Johan S. R. Nielsen wrote:
that's a very small syntax price to pay for …

I would also say that this is not the point at all. Parsing a string representing a matrix should be possible, but we shouldn't purely focus on matlab but see this more broadly.
 
My impression from my own math department is that a lot of Matlab
users know more or less only Matlab as a programming language...

I think the point with matlab is, that it is optimized for a narrow use case. That's nice as always, but stops you doing more complex things. For example, string manipulation and higher dimensional data arrays, structured data, the java programming interface etc. All this comes "after the fact" as some kind of addon to solve its limits. This whole approach of matlab forces the programmer to represent the data in specific ways that get very confusing. Instead of python lists, you have excel like matrices just because matrices are easy to do. Then you have index matrices and other matrices that mix with those you already have by having the same number of rows or columns… confusion starts. So yes, it's a hurdle and you have to learn proper programming and representing your data in a useful way when you want to switch from matlab to python, but it's worth. You safe yourself from headaches. 

I suggest we should look more broadly on the features matlab users expect from a viable alternative. For example, this EPD is a nice package and there you can see what is necessary to be compatible: tools to create a UI, interfacing with various data sources and machines, toolboxes (statistics, optimization, ...), plotting of course, etc. And as usual, the documentation needs to be better - not just reference, but proper introduction with learning paths and so on.

H

Harald Schilly

unread,
Aug 19, 2011, 6:12:36 AM8/19/11
to sage-...@googlegroups.com
On Friday, August 19, 2011 12:02:14 PM UTC+2, leif wrote:

It shouldn't be that hard to implement functions which at least
partially translate MATLAB / Mma / whatever syntax (passed as a
string, or from a file) to corresponding Sage expressions and
commands, analoguous to preparse().

That sounds nice, but it is a dangerous way. It's not only a lot of work, but if you don't explicitly tell new users that this system is really _different_ they hesitate to sit on their ass a bit to learn it and also will never fully comprehend the system and furthermore will never be productive with it. A good example is octave, where they have to copy all the matrix  bugs of matlab just to be compatible. Do we want to copy all the silly bugs too? If we want to be able to parse it, we would have to. I really don't like going down that path ...

H

leif

unread,
Aug 19, 2011, 8:27:32 AM8/19/11
to sage-devel
I didn't have a fully-fledged compiler (or clone) in mind, but rather
some kind of "interactive tutorial" (for migrants and people taking a
first look at Sage), to be used like one uses preparse() to get Sage-
specific constructs "explained", but rather the inverse way, quickly
giving [brief] answers to questions like:

* What's the name of function / operator xy (I have in Mma,
MATLAB, ...) in Sage?
* How do I construct the following Mma / ... expression in Sage?

We have tutorials, more or less interactive worksheets, and the
reference manual, but as far as I know no cheat sheets* for users
coming from the big M's, nor look-up functions other than for Sage
names at the command prompt.


Designing modules, classes and functions such that tab completion will
eventually give some insight on a topic (like UNIX's 'apropos') is
quite limited, and doesn't work at all for "foreign" functions (unless
we'd put them into the namespace, which would likely be limited and
IMHO a bad idea). The search_* functions aren't very appropriate
either for that purpose, and the lack of type declarations makes
docstrings lengthy and often necessary to read.


-leif

___________________________
* I vaguely remember to have once seen some [quite old?] list / table
mapping Mma function names to Sage's, but I'm not aware it is part of
the Sage distribution or prominently advertised. I may be wrong of
course. ;-)

Jason Grout

unread,
Aug 19, 2011, 8:29:16 AM8/19/11
to sage-...@googlegroups.com
On 8/19/11 4:54 AM, dahl.j...@gmail.com wrote:
> Personally I don't mind that the syntax is different.
>
> I was about to give some examples of indexing and slicing
> of Numpy arrays, which I remembered to be odd for matrices, but
> then I realized that the indexing/slicing works exactly like
> I expect it to, e.g.,
>
>>>> A[:, i]
>
> picks out the i'th column. Has this always been the case
> with Numpy? If that's the case, some of my objections
> against Numpy are based on my own ignorance.


IIRC, it's been in numpy for years. Certainly at least 5 years or so,
and probably far longer than that. In fact, you can do much more, just
like in matlab. You can index using a boolean array, for example. See
http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html or
http://www.scipy.org/NumPy_for_Matlab_Users#head-13d7391dd7e2c57d293809cff080260b46d8e664
for more details and examples.


You can use that notation with Sage matrices too. We've only had it for
maybe 4 years now, though. See
http://www.sagemath.org/doc/reference/sage/matrix/docs.html#indexing

Thanks,

Jason


Jason Grout

unread,
Aug 19, 2011, 8:32:54 AM8/19/11
to sage-...@googlegroups.com
On 8/19/11 2:55 AM, Johan S. R. Nielsen wrote:
> On the other hand, I think it would of course think it would be great
> if all functionality needed for numerics people would be readily
> available in Sage.

Since we rely so much on numpy/scipy for this stuff, maybe we could
continue to invite some of their top numerical linear algebra people to
a Sage Days, thus "sponsoring" them to work on things like this, e.g.,
wrapping more needed LAPACK functions, or wrapping them smarter, etc.
We've already done this in March (Mark Wiebe and Chuck Harris came).
It'd be cool to do it again.

Jason


Harald Schilly

unread,
Aug 19, 2011, 9:15:12 AM8/19/11
to sage-...@googlegroups.com
On Fri, Aug 19, 2011 at 14:27, leif <not.r...@online.de> wrote:
> I didn't have a fully-fledged compiler (or clone) in mind …

ok, good ;)

About your tutorials and documentation ideas, I think what could help
at least for the start is to mention the respective function in the
documentation. Then, when someone searches for function "x" s/he ends
up at the corresponding page in the sage documentation.

On Fri, Aug 19, 2011 at 14:32, Jason Grout <jason...@creativetrax.com> wrote:
> maybe we could continue to invite some of their top numerical linear algebra
> people to a Sage Days

big +1

H

daly

unread,
Aug 19, 2011, 1:11:26 PM8/19/11
to sage-...@googlegroups.com
On Fri, 2011-08-19 at 05:27 -0700, leif wrote:
> ___________________________
> * I vaguely remember to have once seen some [quite old?] list / table
> mapping Mma function names to Sage's, but I'm not aware it is part of
> the Sage distribution or prominently advertised. I may be wrong of
> course. ;-)

There is http://axiom-developer.org/axiom-website/rosetta.pdf
which does not include Sage, although I'd be happy to replace
it with a newer version that does. I'm not enough of a Sage
person to do it properly.

Tim Daly


Robert Bradshaw

unread,
Aug 19, 2011, 2:45:32 PM8/19/11
to sage-...@googlegroups.com

+1

> Designing modules, classes and functions such that tab completion will
> eventually give some insight on a topic (like UNIX's 'apropos') is
> quite limited, and doesn't work at all for "foreign" functions (unless
> we'd put them into the namespace, which would likely be limited and
> IMHO a bad idea).

Where it really shines is when I have an object, say E, and do

E.<tab>

But I agree that that alone is often insufficient.

More on topic, I strongly agree with the sentiments that we are trying
to create a viable alternative, not a clone. Sage does lack a concise
syntax for matrices which are a pretty basic type, and I think this
deficiency is probably worth addressing with the preparser. The [a, b;
c, d] syntax is a natural one (pari as well as Matlab uses it), though
I'm open to suggestions. FWIW, Maple and Mathematical require nested
lists just as Sage does now. As for the basering, we have

[a, b; c, d].change_ring(QQ)

but change_ring might be a bit obscure. Maybe "over" could be provided as well.

- Robert

Volker Braun

unread,
Aug 19, 2011, 3:11:49 PM8/19/11
to sage-...@googlegroups.com
For the record, Maple also provides a specialized matrix/vector constructor <1,2,3> = column vector, <1|2|3> = row vector and nested <> brackets created matrices by gluing vectors together, so

<<1,2>|<3,4>> = transpose( <<1|3>,<2|4>>)



kcrisman

unread,
Aug 19, 2011, 3:12:20 PM8/19/11
to sage-devel
> More on topic, I strongly agree with the sentiments that we are trying
> to create a viable alternative, not a clone. Sage does lack a concise
> syntax for matrices which are a pretty basic type, and I think this
> deficiency is probably worth addressing with the preparser. The [a, b;
> c, d] syntax is a natural one (pari as well as Matlab uses it), though
> I'm open to suggestions. FWIW, Maple and Mathematical require nested
> lists just as Sage does now. As for the basering, we have
>
>     [a, b; c, d].change_ring(QQ)
>
> but change_ring might be a bit obscure. Maybe "over" could be provided as well.

Wow, that could be quite useful.

Jason Grout

unread,
Aug 19, 2011, 3:26:06 PM8/19/11
to sage-...@googlegroups.com
On 8/19/11 1:45 PM, Robert Bradshaw wrote:
> [a, b; c, d].change_ring(QQ)

What if I want a 1-row matrix. Will this work?

[a,b,c,d]

Of course, this will be a problem since that is valid list syntax. For
that reason, it seems more consistent that the semicolon is a shortcut
for doubly-nested lists, and still insist the user do something with a
matrix creation command.

But then what about:

[1, 2,
3, 4]

From the previous messages (where newlines are treated like
semicolons), that should be a square 2x2 matrix, but again, it is valid
python syntax.

Thanks,

Jason


Volker Braun

unread,
Aug 19, 2011, 4:50:15 PM8/19/11
to sage-...@googlegroups.com
For the 1-row matrix case, how about

[1, 2, 3, 4; ]

This is similar to the one-element tuple (1,) in Python.

William Stein

unread,
Aug 19, 2011, 4:59:00 PM8/19/11
to sage-...@googlegroups.com

I like that.

Interestingly, it works in MATLAB, but not in PARI.

William

Nils Bruin

unread,
Aug 19, 2011, 5:25:24 PM8/19/11
to sage-devel
On Aug 19, 12:26 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
> On 8/19/11 1:45 PM, Robert Bradshaw wrote:
>
> >      [a, b; c, d].change_ring(QQ)

You'd have to take care that

[1.000000000000000000000001, 1.0; 2.0,
3.0].change_ring(RealField(100))

doesn't lose precision on the way, which suggests that "[;]" syntax
should result in a "matrix literal".

> What if I want a 1-row matrix.  Will this work?
>
> [a,b,c,d]

In analogy to (a,) being a singleton, this should probably be
[a,b,c,d;]

> But then what about:
>
> [1, 2,
> 3, 4]
>
>  From the previous messages (where newlines are treated like
> semicolons), that should be a square 2x2 matrix, but again, it is valid
> python syntax.

Hence, I don't think a preparser based solution should support this.
Saving the "..." comes at the cost of having to type the ;s

Also note that once we're doing this, we should probably also support
matrices over matrices, so

[ [1,2;3,4] , [5,6;7,8]; [9,10;11,12], [13,14;15,16]]

should also be supported (just because your grammar specification will
be a horribly ugly mess if you want to disallow this construct).
This basically means that the preparser actually has to parse its
input (http://en.wikipedia.org/wiki/
Pumping_lemma_for_regular_languages can be used that parenthesis
matching cannot be done using regular languages, although some modern
"regex" implementation might have features for it).

Matrices over matrices are weakly supported presently:

sage: M=matrix(2,2,[1,2,3,4])
sage: A=matrix(2,2,[M,M,M,M])
sage: B=A^2
sage: B[0,0]
[14 20]
[30 44]
sage: M*M+M*M #that's what the entry should be
[14 20]
[30 44]

but pretty much anything else fails (including printing these objects,
because printing apparently needs hash(M))

Independent of the example above, nested matrix literals could happen
anyway:

[ 1, 2; 3, det( [4,1;0,1]) ]

Jason Grout

unread,
Aug 19, 2011, 6:07:54 PM8/19/11
to sage-...@googlegroups.com

It makes sense to work in matlab. It seems that matlab compresses empty
rows (for example, [1 2 3 4 ; ; 5 6 7 8] gives a 2x4 matrix). So
initially it is a 3-row matrix, but then matlab compresses the second
row since it is an empty row. Or I guess another way to say it is that
matlab compresses consecutive column delimiters. So matlab being sloppy
(or convenient?) makes it work.

Jason


Jason Grout

unread,
Aug 19, 2011, 6:15:57 PM8/19/11
to sage-...@googlegroups.com
On 8/19/11 4:25 PM, Nils Bruin wrote:
> In analogy to (a,) being a singleton, this should probably be
> [a,b,c,d;]

Interesting. In python, this is often stated as "the comma operator
makes a tuple, not the parentheses". So we're saying that the semicolon
is what makes a matrix. Interesting. So if there is no semicolon, it
isn't a matrix.

Should we support spaces for element delimiters? That would be
consistent with matlab, and I personally prefer [1 2; 3 4] over
[1,2;3,4] (since the , and ; are too similar, so it takes a moment to
determine which is an element and which is a row delimiter). If we
support spaces, then it seems a little weird that [1 2 3] is not good
syntax, but [1 2 3; ] is good syntax.

Also, I guess it is nice in matlab that you can do:

a=[

<paste in a table of numbers you copied from a web page

]

and get a nice matrix, since newlines count as row delimiters.

Thanks,

Jason


Simon King

unread,
Aug 19, 2011, 6:21:53 PM8/19/11
to sage-devel
On 19 Aug., 21:26, Jason Grout <jason-s...@creativetrax.com> wrote:
> But then what about:
>
> [1, 2,
> 3, 4]

Note the small difference:
[1,2,
3,4]
is a list in Python. But
[1,2
3,4]
(if I am not mistaken) is a syntax error in Python, and thus the
preparser could preprocess it and turn it into a matrix:

The line break replaces the semicolon, hence, the example that you
give corresponds to [1,2,;3,4] (which hopefully is a syntax error in
Matlab), while the second version becomes [1,2;3,4] (which seems to be
the matlab idea of a matrix).

That said, I think one of the strength of Sage is to use a mainstream
language. It should not be weakened too much by syntactical sugar, in
particular if it lacks precision (by gratuitous assumptions on the
base ring).

Concerning some matlab users feeling irritated by any deviation from
matlab syntax: I guess that Sage is not going to be a Matlab clone,
and thus that kind of users is lost.

Every thinking person must be aware that, to some extent, *the same*
idea can be expressed in different languages. I hope that every person
working in numerics would not mind to use a CAS with a decent
programming language, provided that it offers *the functions* (but not
necessarily the function names or the syntax) of Matlab.

Concerning matrices: Are people working in numerics really
interactively typing in matrices? Or are they usually just reading
matrices from files that are created by programs (e.g., based on data
from an experiment)? If the latter is the case then syntactical sugar
wouldn't really matter.

Cheers,
Simon

Robert Bradshaw

unread,
Aug 19, 2011, 6:57:20 PM8/19/11
to sage-...@googlegroups.com
On Fri, Aug 19, 2011 at 2:25 PM, Nils Bruin <nbr...@sfu.ca> wrote:
> On Aug 19, 12:26 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
>> On 8/19/11 1:45 PM, Robert Bradshaw wrote:
>>
>> >      [a, b; c, d].change_ring(QQ)
>
> You'd have to take care that
>
> [1.000000000000000000000001, 1.0; 2.0,
> 3.0].change_ring(RealField(100))
>
> doesn't lose precision on the way, which suggests that "[;]" syntax
> should result in a "matrix literal".

That would greatly complicate things, I'd rather the syntactic sugar
stay simple. I don't see it as being any worse than

sage: (x + 1.00000000000000000001).change_ring(RealField(100))
x + 1.0000000000000000000101643954

If one cares about the basering that much, use the normal matrix constructor.

>> What if I want a 1-row matrix.  Will this work?
>>
>> [a,b,c,d]
>
> In analogy to (a,) being a singleton, this should probably be
> [a,b,c,d;]

+1

>> But then what about:
>>
>> [1, 2,
>> 3, 4]

-1.

I don't think we should treat newlines specially.

>>  From the previous messages (where newlines are treated like
>> semicolons), that should be a square 2x2 matrix, but again, it is valid
>> python syntax.
>
> Hence, I don't think a preparser based solution should support this.
> Saving the "..." comes at the cost of having to type the ;s
>
> Also note that once we're doing this, we should probably also support
> matrices over matrices, so
>
> [ [1,2;3,4] , [5,6;7,8]; [9,10;11,12], [13,14;15,16]]
>
> should also be supported (just because your grammar specification will
> be a horribly ugly mess if you want to disallow this construct).
> This basically means that the preparser actually has to parse its
> input (http://en.wikipedia.org/wiki/
> Pumping_lemma_for_regular_languages can be used that parenthesis
> matching cannot be done using regular languages, although some modern
> "regex" implementation might have features for it).

I don't see a compelling reason to support it. For better or for
worse, "Un-preparsed sage" doesn't really have a grammar. It's more
like the C preprocessor that does textual substitutions before the
real parser takes effect. (Not that the C preprocessor isn't a
horrendous hack, but writing C without it would be even worse. :-)

That being said, counting brackets would suffice without needing to do
a full parsing. (String literals are already stripped at this point.)

> Matrices over matrices are weakly supported presently:
>
> sage: M=matrix(2,2,[1,2,3,4])
> sage: A=matrix(2,2,[M,M,M,M])
> sage: B=A^2
> sage: B[0,0]
> [14 20]
> [30 44]
> sage: M*M+M*M #that's what the entry should be
> [14 20]
> [30 44]
>
> but pretty much anything else fails (including printing these objects,
> because printing apparently needs hash(M))
>
> Independent of the example above, nested matrix literals could happen
> anyway:
>
> [ 1, 2; 3, det( [4,1;0,1]) ]
>

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

Robert Bradshaw

unread,
Aug 19, 2011, 7:05:35 PM8/19/11
to sage-...@googlegroups.com
On Fri, Aug 19, 2011 at 3:21 PM, Simon King <simon...@uni-jena.de> wrote:
> On 19 Aug., 21:26, Jason Grout <jason-s...@creativetrax.com> wrote:
>> But then what about:
>>
>> [1, 2,
>> 3, 4]
>
> Note the small difference:
> [1,2,
> 3,4]
> is a list in Python. But
> [1,2
> 3,4]
> (if I am not mistaken) is a syntax error in Python, and thus the
> preparser could preprocess it and turn it into a matrix:

IMHO, small difference == bad idea

> The line break replaces the semicolon, hence, the example that you
> give corresponds  to [1,2,;3,4] (which hopefully is a syntax error in
> Matlab), while the second version becomes [1,2;3,4] (which seems to be
> the matlab idea of a matrix).
>
> That said, I think one of the strength of Sage is to use a mainstream
> language. It should not be  weakened too much by syntactical sugar, in
> particular if it lacks precision (by gratuitous assumptions on the
> base ring).
>
> Concerning some matlab users feeling irritated by any deviation from
> matlab syntax: I guess that Sage is not going to be a Matlab clone,
> and thus that kind of users is lost.
>
> Every thinking person must be aware that, to some extent, *the same*
> idea can be expressed in different languages. I hope that every person
> working in numerics would not mind to use a CAS with a decent
> programming language, provided that it offers *the functions* (but not
> necessarily the function names or the syntax) of Matlab.

I don't see this a question of cloning Matlab, rather it's a feature
(concise matrix literals) that we'd like to have too.

> Concerning matrices: Are people working in numerics really
> interactively typing in matrices? Or are they usually just reading
> matrices from files that are created by programs (e.g., based on data
> from an experiment)? If the latter is the case then syntactical sugar
> wouldn't really matter.

Personally, I'd want them for 2x2 matrices.

I would also be in favor of supporting a much more flexible
matrix(str) constructor, where (for example) newlines would be treated
as row breaks and other whitespace between identifiers treated as
column breaks (similar to implicit multiplication) and
leading/trailing []'s are ignored. E.g. could do

sage: matrix("""


[1 2]
[3 4]
""")

- Robert

Jason Grout

unread,
Aug 19, 2011, 7:26:00 PM8/19/11
to sage-...@googlegroups.com
On 8/19/11 5:21 PM, Simon King wrote:
> The line break replaces the semicolon, hence, the example that you
> give corresponds to [1,2,;3,4] (which hopefully is a syntax error in
> Matlab), while the second version becomes [1,2;3,4] (which seems to be
> the matlab idea of a matrix).

Again, matlab is (sloppy|convenient|lenient):

>> [1,2,;3,4]

ans =

1 2
3 4


Thanks,

Jason


dahl.j...@gmail.com

unread,
Aug 20, 2011, 2:16:58 AM8/20/11
to sage-devel
It's a good point that for most work you don't type in matrices by
hand. What is more useful is probably various ways of inspecting
matrices easily (print submatrices, plot the sparsity pattern,
evaluate expressions involving the matrix, etc.)

Chris Godsil

unread,
Aug 20, 2011, 10:11:09 AM8/20/11
to sage-devel
Simon

You raise a number of very good points. In my case, my matrices are
produced by some other routine or
will be read in from a file. When I do type in small matrices, I've
never found the syntax to be
a problem. The sort of thing that has annoyed me is that matrix() and
Matrix() both work, but vector()
does not, only Vector(). And if P is a graph then P.am().charpoly()
works but P.charpoly() does not
(but both A.characteristic_polynomial() and
P.characteristic_polynomial() do).

The point being that consistency is more important than the details of
syntax,
in part because it makes the syntax easier to learn and to remember.

Sage does tend to have problems with consistency between areas. Since
one of sage's strength versus matlab
is that it is a general purpose package, I think this issue merits
some attention.

Also, if you look back at the problems in this thread raised by people
with numerical experience, I do not think
syntax was a significant issue.

Chris

Harald Schilly

unread,
Aug 20, 2011, 11:07:49 AM8/20/11
to sage-...@googlegroups.com
On Sat, Aug 20, 2011 at 16:11, Chris Godsil <cgo...@uwaterloo.ca> wrote:
> The point being that consistency is more important than the details of
> syntax,
> in part because it makes the syntax easier to learn and to remember.

I completely agree with you! Also, just adding this parsing of
matrix-strings doesn't change anything in terms of
adoption-friendliness. It might be nice for playing around or solving
some educational examples, but it's irrelevant for the average matlab
user.

H

Jason Grout

unread,
Aug 20, 2011, 11:15:45 AM8/20/11
to sage-...@googlegroups.com
On 8/20/11 10:07 AM, Harald Schilly wrote:
> I completely agree with you! Also, just adding this parsing of
> matrix-strings doesn't change anything in terms of
> adoption-friendliness. It might be nice for playing around or solving
> some educational examples, but it's irrelevant for the average matlab
> user.

+1. I'm pretty convinced now that an easier syntax for creating
matrices should be rather low on the priority list (especially since it
is rather more difficult than I initially thought).

Jason

Rob Beezer

unread,
Aug 20, 2011, 2:20:33 PM8/20/11
to sage-devel
On Aug 20, 7:11 am, Chris Godsil <cgod...@uwaterloo.ca> wrote:
> And if P is a graph then P.am().charpoly()
> works but P.charpoly() does not
> (but both A.characteristic_polynomial() and
> P.characteristic_polynomial() do).

Patch to enable P.charpoly() ready for review at:
http://trac.sagemath.org/sage_trac/ticket/11711

Rob Beezer

unread,
Aug 20, 2011, 2:31:29 PM8/20/11
to sage-devel
I find the preparser perilous. It does some great things, such as the
"F.<a> =" syntax. But every addition seems to come with a high cost.
The *.sage/*.py dichotomy is confusing for new folks who want to write
scripts immediately. And then there is the whole Integer() quagmire.

On the flip side, I have never bristled at Sage syntax for matrices.
And I hardly ever type in a matrix anyway, except when doing dumb
little tests. If I need a small "classroom example" I use the various
versions of the random_matrix() constructor repeatedly until I get a
matrix with the desired properties *and* the desired aesthetics.

What I would really like to have is a routine that prints a matrix in
a (column-aligned) form that is acceptable input (continuation
markers, etc) so it can be cut/paste into doctests, worksheets, and
examples. (Yes, I know Mathematica's InputForm[].) Not a hard thing
to build, just have not reached that far down my list yet.

Rob

William Stein

unread,
Aug 20, 2011, 3:30:06 PM8/20/11
to sage-...@googlegroups.com

Since you mention "InputForm[]", I can't help but mention Sage's
analogue of that (written by Carl Witty), which is called
"sage_input":

sage: a = random_matrix(QQ,4)
sage: sage_input(a)
matrix(QQ, [[0, 1, -1, 1/2], [0, -1, -2, 0], [0, 0, 2, 0], [1, 0, -1, 2]])


If I were entering the above matrix by hand, I would likely do:

a = matrix(QQ, 4,
[0, 1, -1, 1/2,
0, -1, -2, 0,
0, 0, 2, 0,
1, 0, -1, 2])

I would gain absolutely nothing at all in this case by using
semicolons at the end of each line.

Rob Beezer

unread,
Aug 21, 2011, 2:06:04 PM8/21/11
to sage-devel
On Aug 20, 12:30 pm, William Stein <wst...@gmail.com> wrote:
> Since you mention "InputForm[]", I can't help but mention Sage's
> analogue of that (written by Carl Witty), which is called
> "sage_input":

After posting, I knew I should have done a modicum of research first.
Thanks for the reminder about sage_input().

> sage: a = random_matrix(QQ,4)
> sage: sage_input(a)
> matrix(QQ, [[0, 1, -1, 1/2], [0, -1, -2, 0], [0, 0, 2, 0], [1, 0, -1, 2]])

Maybe I will extend it to (optionally) produce

matrix(QQ, [[0, 1, -1, 1/2],
... [0, -1, -2, 0],
... [0, 0, 2, 0],
... [1, 0, -1, 2]])

for quick-and-easy cut-and-paste into doctests, etc.

Rob

v_...@ukr.net

unread,
Aug 25, 2011, 5:42:55 AM8/25/11
to sage-...@googlegroups.com
Hello!
Just in case somebody is still interested in opinions on the initial
topic.

Since I'm not familiar with Matlab myself, I asked some people who is
familiar "Why do they choose Matlab and not any other system, for
example, Sage".

- Most of them didn't know about Sage at all till that moment.
- Most of them started to use Matlab just because they heard this word
from other students / PhD students / lecturers and once they got used
to it, they want nothing else.
- Some of them a ready to switch to ANY other system any time IF they
find it more useful or more suitable for their work.
- Some of them had not used any kind of CAS before and are ready to
start with any system (including Sage) if somebody teaches them how to
work with it.

These two last categories seem the most promising to me. And while
the people from the latter one do not make any decisions basing on
*their own* opinion, people from the former one tend to be more
conscious and flexible. What they need is a set of functions they use
in their work (with any names - not necessarily matching those from
Matlab), a detailed reference manual to look for such functions and
their usage and a huge amount of ready recipes and scripts on the
Internet for copy-pasting into their own programs.

For example, one of them said: "When I need to use some relatively
new method, it is very likely that I will find its implementation in a
form of a Matlab script (or maybe he said "toolbox" - I'm not sure
about how they call it) much earlier that in any other language/system.
That is why I just take it and use it. And of course, I need to use
Matlab to run it."

Another example - one of them asked me: "Where can I find a complete
list of functions available in Sage?" I had to explain him that Sage
includes a number of mathematical packages each one having its own
documentation, reference manuals, examples and so on on their websites.
But such an answer simply sounds like "I don't know". And what kind of
help is that?

So, summarizing all stated above, it seems to me that the main cause
of Sage being undervalued is the lack of documentation/books/reference
manuals/forums/ready recipes/etc. in different languages. For example,
almost all people in xUSSR countries usually look for some kind of
support in Russian. And that's quite a lot of people. They can easily
obtain any kind of help on Matlab in Russian, but they can get almost
no help at all in Russian for Sage.

P.S. None of them mentioned the syntax differences, namely in the
matrix notation, although this probably does not say much by itself

Regards,
Vladimir

On Mon, 15 Aug 2011 12:58:38 -0700
William Stein <wst...@gmail.com> wrote:

> Hi,
>
> If somebody walked up to *you* and asked: "Is Sage now a viable
> alternative to MATLAB?" what would you say?
> I'm especially interested in what people who do numerical/applied
> computation think.
>
> My answer: "It's very difficult for *me* to answer this question
> myself, because MATLAB is useless for most of my own
> teaching/research/work, but I realize it is very widely used in
> applied mathematics. Based on going to Scipy and the resources I've
> seen online, it appears that the Numpy/Scipy stack is extremely useful
> to actual people doing numerical computation. Maybe I'll try
> asking on sage-devel."
>
> [NOTE: I am interested in people's answers, rather than somebody
> hijacking this thread to try to define "viable alternative" or say
> this isn't a scientific survey or something. Please try not to hijack
> this thread. Thanks!]
>
> -- William
>

-----
<v_...@ukr.net>

Jason Grout

unread,
Aug 25, 2011, 9:44:11 AM8/25/11
to sage-...@googlegroups.com
On 8/25/11 4:42 AM, v_...@ukr.net wrote:
> Another example - one of them asked me: "Where can I find a complete
> list of functions available in Sage?" I had to explain him that Sage
> includes a number of mathematical packages each one having its own
> documentation, reference manuals, examples and so on on their websites.
> But such an answer simply sounds like "I don't know". And what kind of
> help is that?


You might look at http://sagemath.org/doc/reference/genindex.html,
though it's so big, I don't know how helpful it is to just browse the
entire list...

Jason


Maarten Derickx

unread,
Aug 25, 2011, 10:43:37 AM8/25/11
to sage-...@googlegroups.com


> and a huge amount of ready recipes and scripts on the
Internet for copy-pasting into their own programs.


This clearly exists, but then you don't have to search for sage, but search for python.

rjf

unread,
Aug 26, 2011, 3:40:24 PM8/26/11
to sage-devel
Trying not to hijack this thread ...

Why do people use particular software (e.g. Matlab vs. Octave
vs. ..Sage..)
a. Their teacher tells them to use it
b. They do not pay for it anyway (school license, company license)
c. They know it works and they don't have to mess with installing it.
d. Their friends and colleagues use it. (applications ready-made)
e. The company that sells it is responsive to customer questions.
f. The company sells a ready-made optimized installations for your
computer and OS.
g. The company (or other companies) sell ready-made application
packages that you
can buy for specific common engineering tasks (e.g. signal processing,
circuit design,
financial options analysis) etc.

I suspect that most engineers are happy to pay someone else some
amount of money so
they do not have to do work which is essentially irrelevant to their
occupational training in, say, civil engineeering, structural
engineering, etc. Just as I am happy to
pay a plumber (well, not THAT happy) to do something that I could, in
principle, do
myself if I spent enough time at it, and had the right tools. Thus
the tradeoff of
<free + n hours playing install-slave+read-docs-slave+ write program>
vs
<pay $200 / type parameters into someone's canned program's graphical
interface>
is fairly clear, at least if your salary is more than $200/n per hour.

I think that many Matlab users who are compelled to buy licenses and
have concerns over the cost are aware of the free-clone possibilities
like Octave. I think that using Sage because it overlaps with and/or
is a superset of Matlab is not so appealing to someone who is already
a Matlab user familiar with Matlab syntax and not much else.

I've used Matlab myself, and I've written a parser for (an early)
version of Matlab's syntax, and interfaced other programs with
matlab. I do not consider myself a typical Matlab user, however.
I have an opportunity to observe them (at least the ones in an
academic setting).



n Aug 15, 12:58 pm, William Stein <wst...@gmail.com> wrote:
> Hi,
>
> If somebody walked up to *you* and asked: "Is Sage now a viable
> alternative to MATLAB?" what would you say?
> I'm especially interested in what people who do numerical/applied
> computation think.
>
> My answer: "It's very difficult for *me* to answer this question
> myself, because MATLAB is useless for most of my own
> teaching/research/work, but I realize it is very widely used in
> applied mathematics.   Based on going to Scipy and the resources I've
> seen online, it appears that the Numpy/Scipy stack is extremely useful
> to actual people doing numerical computation.      Maybe I'll try
> asking on sage-devel."
>
> [NOTE:  I am interested in people's answers, rather than somebody
> hijacking this thread to try to define "viable alternative" or say
> this isn't a scientific survey or something.  Please try not to hijack
> this thread.  Thanks!]
>
>  -- William
>
> --
> William Stein
> Professor of Mathematics
> University of Washingtonhttp://wstein.org

Paul Leopardi

unread,
Aug 27, 2011, 10:30:46 PM8/27/11
to sage-devel
Hi William,
On Aug 16, 5:58 am, 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?
> I'm especially interested in what people who do numerical/applied
> computation think.
>
> My answer: "It's very difficult for *me* to answer this question
> myself, because MATLAB is useless for most of my own
> teaching/research/work, but I realize it is very widely used in
> applied mathematics. Based on going to Scipy and the resources I've
> seen online, it appears that the Numpy/Scipy stack is extremely useful
> to actual people doing numerical computation. Maybe I'll try
> asking on sage-devel."

I am currently teaching numerical linear algebra at ANU (MATH3512:
Matrix Computations), using Trefethen and Bau's Numerical Linear
Algebra as a textbook. Trefethen and Bau, as you know, uses Matlab for
its examples and exercises. My course switched from Scilab (a Matlab
almost-clone) to Python/ IPython/ SciPy/ NumPy/ Matplotlib just this
year. Each year, one issue keeps repeating: there is a spread of
student backgrounds from non-programmer to programmer, and from non-
mathematician to mathematician. The non-programmers often say that
there is not enough explicit instruction in the programming aspects of
the course. The course currently includes about one hour of lecture
and 8 hours of computer labs devoted to learning programming, using
the Python platform mentioned above. The labs are based on 6 of the
tutorial worksheets written and used for MATH3511 Scientific
Computing, which also switched to Python this year. I am encouraging
my students to use ipython -pylab and to use NumPy matrices whenever
possible. They will also be using sparse matrices. I have also
demonstrated Sage to students in one of the computer labs.

The idea of using the Sage Notebook interface via the Web is quite
appealing, but I haven't tried switching the course to Sage because I
am afraid of the complications involved in rewriting the tutorial
materials and in running the labs. In particular, to run the labs
successfully, would I need to know all the peculiarities and pitfalls
involved in Sage coercion for linear algebra classes? Do matrices in
complex double precision and real double precision produce the same
results in Sage as the would using ipython -pylab ? Is it worthwhile
to study the algorithm implementations used by Sage, as opposed to
those in NumPy and SciPy alone?

Another issue is that students want to be able to run their numerical
software as standalone on their laptops. My course would need to help
them install Sage on Windows, Mac and possibly Linux. Right now, the
students are using Python directly on the Windows machines in the
labs, and using ssh on the Macs in the labs to connect to a Linux-
based cluster running Python, as well as running on their own laptops.
I have encouraged them to try the Enthought Academic Download, to ease
any installation difficulties.

These are questions which I did not give myself enough time to study
in the first semester before I had to start teaching in second
semester. Perhaps if I start now, I can obtain a clearer idea of how
to teach numerical linear algebra using Sage from next year onward.
Would participating in a Sage Days help?

William Stein

unread,
Aug 27, 2011, 10:55:49 PM8/27/11
to sage-...@googlegroups.com

You could set the default "system" for the notebook to be Python
instead of Sage.
Then you can use the course materials you've already developed with
almost no changes at all, since all of "Python/ IPython/ SciPy/ NumPy/
Matplotlib" are included in Sage. The main thing you have to do is
explain how to draw matplotlib plots in the notebook (using savefig).

> Another issue is that students want to be able to run their numerical
> software as standalone on their laptops. My course would need to help
> them install Sage on Windows, Mac and possibly Linux. Right now, the
> students are using Python directly on the Windows machines in the
> labs, and using ssh on the Macs in the labs to connect to a Linux-
> based cluster running Python,

It sounds like all of that lab installation has nothing to do with the students.

> as well as running on their own laptops.

That's the one part that would involve students actually doing
something. Normal people do successfully install Sage... That said,
running Sage on Windows is definitely not the best experience, since
Windows has fostered a less than optimal ecosystem for open source
software. (Sage is fine on Linux and Mac.)

> I have encouraged them to try the Enthought Academic Download, to ease
> any installation difficulties.

Has that worked well? EPD of course has excellent Windows support.

> These are questions which I did not give myself enough time to study
> in the first semester before I had to start teaching in second
> semester. Perhaps if I start now, I can obtain a clearer idea of how
> to teach numerical linear algebra using Sage from next year onward.
> Would participating in a Sage Days help?

Yes, though the extent to which it helps would depend on the Sage Days.

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

--

David Ketcheson

unread,
Aug 31, 2011, 5:05:17 AM8/31/11
to sage-devel
Qualifications to answer this question:
-I have used MATLAB for 10 years in my research
-About 3 years ago, I mostly switched to Python+numpy/scipy/
matplotlib, and I lead a project that includes about a dozen people
developing code in Python
-I use SAGE (mainly the notebook) in my teaching.

For most MATLAB users, I think SAGE adds little or nothing to what
numpy/scipy/matplotlib already offer. Indeed, it tends to complicate
things because of the preprocessing and potential conflict of
namespaces (you can get around these, but they are potential pitfalls
for a beginner). As for using native SAGE functions and objects, the
fact that I must set up a ring or field before I create a matrix
already makes them too cumbersome to use. As mentioned already, the
feature I use SAGE for is the notebook, and I generally put %python at
the top of each worksheet. One other thing I've experimented with is
software that will compute exactly or in floating point, depending on
the nature of the input. In the end I went with Sympy rather than
SAGE for the exact computations

I think numpy and matplotlib are good replacements for the
corresponding parts of MATLAB. But many parts of Scipy are, in my
experience, a disaster. I rarely use it. Instead, I take advantage
of the many good numerical libraries with Python interfaces (e.g.
IPopt, PETSc). I think the advantage of all of these wrappers (and
the ease of creating your own wrappers) is beginning to overtake
MATLAB's toolboxes in usefulness, but the catch is that you have to
know a bit more to use them since they're not all designed by a single
commercial entity. In my case, interfaces to these packages in some
cases represent "killer features" of Python that would prevent me from
switching back to MATLAB because it doesn't have them. Access to
PETSc is a prime example, since I regularly compute on tens of
thousands of cores at a time (how much would 20,000 MATLAB licenses
set you back?) And I maintain that development of larger object-
oriented code bases is much more manageable in Python than in MATLAB.

A final consideration: on some platforms it can still be challenging
for novices to install numpy, matplotlib, and scipy. SAGE is a
convenient way to get them. So is Enthought's Python Distribution
(free for academics).

-David


On Aug 15, 10:58 pm, William Stein <wst...@gmail.com> wrote:
> Hi,
>
> If somebody walked up to *you* and asked: "Is Sage now a viable
> alternative toMATLAB?" what would you say?
> I'm especially interested in what people who do numerical/applied
> computation think.
>
> My answer: "It's very difficult for *me* to answer this question
> myself, becauseMATLABis useless for most of my own
> teaching/research/work, but I realize it is very widely used in
> applied mathematics.   Based on going to Scipy and the resources I've
> seen online, it appears that the Numpy/Scipy stack is extremely useful
> to actual people doing numerical computation.      Maybe I'll try
> asking on sage-devel."
>
> [NOTE:  I am interested in people's answers, rather than somebody
> hijacking this thread to try to define "viable alternative" or say
> this isn't a scientific survey or something.  Please try not to hijack
> this thread.  Thanks!]
>
>  -- William
>

Maarten Derickx

unread,
Aug 31, 2011, 1:20:37 PM8/31/11
to sage-...@googlegroups.com
There was one very concrete thing that I found out recently that would probably have set me off if I was a matlab user trying to switch to sage.

sage: (-2.0)^(1/3)
0.629960524947437 + 1.09112363597172*I

William Stein

unread,
Aug 31, 2011, 1:32:11 PM8/31/11
to sage-...@googlegroups.com

(1) If I remember correctly, things are this way because Paul
Zimmerman was "set off" by the above returning a real root, which it
used to do (the default in Maxima, by the way). He had some very good
consistency reasons for preferring the complex branch by default.

(2) Just out of curiosity, did you even *try* the above in Matlab!?
You might be surprised to find that it returns the same thing as Sage!

< M A T L A B >
Copyright 1984-2006 The MathWorks, Inc.
Version 7.2.0.283 (R2006a)
January 27, 2006


To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

>> (-2.0)^(1/3)

ans =

0.6300 + 1.0911i


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

--

Maarten Derickx

unread,
Aug 31, 2011, 1:41:31 PM8/31/11
to sage-...@googlegroups.com
Sorry, don't have acces to matlab, maybe I should have stayed out of this discussion and forget my prejudice about matlab.

William Stein

unread,
Aug 31, 2011, 2:07:11 PM8/31/11
to sage-...@googlegroups.com

No worries! I've been hanging out on sage-flame too much recently, so
I'm sorry that my response was so inappropriate.

By the way, try typing "matlab" on sage.math.washington.edu.

-- William

Juanlu001

unread,
Sep 1, 2011, 4:25:53 AM9/1/11
to sage-...@googlegroups.com
Sorry David, could you clarify what parts of Scipy do you think are a disaster? Just for curiosity. I am a student and I am trying nowadays to use these Python packages to perform numerical computations, and I am very interested on what is being said in this thread.

William Stein

unread,
Sep 1, 2011, 1:31:04 PM9/1/11
to sage-...@googlegroups.com

I would also like to here what parts David is referring to.

Personally, I've used scipy for various things and have been quite
pleased with everything I've used from scipy, except the stats module.
All the optimization and special functions (say) that I used seemed
pretty good. The stats module definitely needed more work. It may
have improved a lot since then, but I don't know.

-- William

Harald Schilly

unread,
Sep 1, 2011, 4:44:15 PM9/1/11
to sage-...@googlegroups.com
On Thu, Sep 1, 2011 at 18:31, William Stein <wst...@gmail.com> wrote:
> scipy

just for the sake of completeness, the next layer above scipy are those scikits:
http://scikits.appspot.com/scikits
especially scikit-learn ( http://scikit-learn.sourceforge.net/stable/
) is quite interesting (ex google summer of code project) and
personally, i hope those newer modules are of higher quality than
those parts in scipy.

H

David Ketcheson

unread,
Sep 6, 2011, 1:46:05 AM9/6/11
to sage-devel
I may have been too harsh in using the term 'disaster'. I am
certainly glad that scipy exists, but I use it with extreme caution.

First, it is quite disorganized. Say you want to solve an ODE.
First, you have to know to import scipy.integrate (importing scipy
doesn't give you scipy.integrate, for some reason, and why would you
guess that solving ODEs fits under the 'integrate' package anyway?).
Next, you then find all of the following:

scipy.integrate.ode
scipy.integrate.odeint
scipy.integrate.odepack.odeint
scipy.integrate.vode

(not to mention scipy.integrate._odepack and scipy.integrate._dop)

Next, the documentation is out of sync. After you (somehow) decide
which to use, you read the documentation but later discover that it is
wrong (doesn't correctly list the arguments that a function takes) in
some places. Finally, there are bugs. You find an ODE solver for
stiff problems and apply it but discover (as my numerical analysis
students did last spring) that it doesn't work properly for stiff
systems, as the time to solve scales linearly with the problem
stiffness, even when the accuracy tolerances are extremely loose. I
should add that I did eventually find a stiff solver among these
packages that worked properly. But it was enough of a headache that
now I just use my own code instead.

I find that much of scipy has problems like this.

-David

On Sep 1, 8:31 pm, William Stein <wst...@gmail.com> wrote:

Dumont Thierry

unread,
Sep 6, 2011, 2:49:47 AM9/6/11
to sage-...@googlegroups.com
Le 06/09/2011 07:46, David Ketcheson a écrit :
> I may have been too harsh in using the term 'disaster'. I am
> certainly glad that scipy exists, but I use it with extreme caution.
>
> First, it is quite disorganized. Say you want to solve an ODE.
> First, you have to know to import scipy.integrate (importing scipy
> doesn't give you scipy.integrate, for some reason, and why would you
> guess that solving ODEs fits under the 'integrate' package anyway?).
> Next, you then find all of the following:
>
> scipy.integrate.ode
> scipy.integrate.odeint
> scipy.integrate.odepack.odeint
> scipy.integrate.vode
>
> (not to mention scipy.integrate._odepack and scipy.integrate._dop)
>
> Next, the documentation is out of sync. After you (somehow) decide
> which to use, you read the documentation but later discover that it is
> wrong (doesn't correctly list the arguments that a function takes) in
> some places. Finally, there are bugs. You find an ODE solver for
> stiff problems and apply it but discover (as my numerical analysis
> students did last spring) that it doesn't work properly for stiff
> systems, as the time to solve scales linearly with the problem
> stiffness, even when the accuracy tolerances are extremely loose.

This is quite strange: I think that scipy calls lsode in this case, is
not it?
lsode is a good program, even if it is old.
The problem may be in the interface (the callbacks?) betwen scipy and lsode.

I agree with you: scipy is low level!

Some parts *cannot* be used: the sparse matrices for example: this is
extremly slow (matrices are build with a dictionary, or at least pure
python).

t.d.

tdumont.vcf

Jason Grout

unread,
Sep 6, 2011, 8:12:38 AM9/6/11
to sage-...@googlegroups.com


Coincidentally, there is a current thread on scipy-dev to improve the
optimization routine interfaces and docs to take care of issues like
this [1]. My guess is that a similar discussion about the integrate
package might also solicit help in improving the interface, if you or
someone had time to work on it. Also, I bet that there is some sort of
funding that could be applied for to work on this sort of thing as well.

Thanks,

Jason

[1] See http://thread.gmane.org/gmane.comp.python.scientific.user/27823

Jason Grout

unread,
Sep 6, 2011, 8:35:51 AM9/6/11
to sage-...@googlegroups.com
On 9/6/11 7:12 AM, Jason Grout wrote:
> current thread on scipy-dev

Sorry; it's on scipy-user. The link is still correct.

Jason


Reply all
Reply to author
Forward
0 new messages