octave, matlab, maxima



Macsyma can translate ".m" files into macsyma programs, or run programs
typed in, interactively. From the demo file we see this:

An m file:


function S = sub(A, i, j)
%SUB     Principal submatrix of A.
%        SUB(A,i,j) is A(i:j,i:j).
%        SUB(A,i)  is the leading principal submatrix of order i,
A(1:i,1:i),
%        if i>0, and the trailing principal submatrix of order ABS(i) if
i<0.

% from netlib/matlab/linearalgebra/testmatrices, `Version 1.2, May 30 1990'

if nargin == 2
   if i >= 0
      S = A(1:i, 1:i);
   else
      n = min(size(A));
      S = A(n+i+1:n, n+i+1:n);
   end
else
   S = A(i:j, i:j);
end

is translated into this

* -*- Mode: Macsyma -*- */
/* Translation of #P"C:\\Macsyma\\Macsyma2\\demo\\sub.m" on 5/27 2008 23:09
*/

QPUT(SUB,"C:\\Macsyma\\Macsyma2\\demo\\sub.m",MATLAB_SOURCE)$

SUB([INPUT]) := BLOCK([N,\s,MAT_NARGIN,\a,I,J],
    LOCAL(N,\s,MAT_NARGIN,\a,I,J),
    MAT_NARGIN : LENGTH(INPUT),
    IF MAT_NARGIN > 3 THEN WRONG_NUMBER_OF_ARGS_ERROR('SUB),
    [\a,I,J] : MATTRAN_FN_ARGS(INPUT,3-MAT_NARGIN),
    CATCH(IF MAT_TRUE(MAT_NARGIN = 2)
	      THEN (IF MAT_TRUE(I >= 0)
		        THEN \s <: \a[1..I,1..I]
		        ELSE (N <: MAT_MIN(MAT_SIZE(\a)),
			      \s <: \a[N+I+1..N,N+I+1..N]))
	      ELSE \s <: \a[I..J,I..J]),
    \s)$

also note that commercial macsyma has this feature, regardless of matlab...

1..2..10   --> [1,3,5,7,9].

That is like the 1:2:10 syntax of matlab, free.... furthermore,
a[1..2,1..2] creates a new sub matrix from matrix a.

Just for the curious, to fill in what Dan mentioned.


RJF




> -----Original Message-----
> From: maxima-bounces at math.utexas.edu 
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Dan Stanger
> Sent: Tuesday, May 27, 2008 5:54 PM
> To: maxima mailing list
> Subject: Re: [Maxima] octave, matlab, maxima
> 
> Hello All,
> The commercial Macsyma has a translator from Mathlab to 
> Macsyma, which 
> may be available in the demo version.
> Documentation on it is available in the reference manual, which is 
> available online.  It may be helpful to study what they implemented.
> Dan Stanger