Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

create a tridiagonal matrix

In MATLAB, we can produce a tridiagonal matrix of order 2*m+1.

   matlab: m = 5;
   matlab: diag(-m:m) + diag(ones(2*m,1),1) + diag(ones(2*m,1),-1)

In SAGE, do I have to write a function, two for-loops, or is there a convenient way? Perhaps it's already defined in one package, scipy/numpy, maxima, ....

Thanks in advance!


define a my_function, here are two example codes http://sage.math.canterbury.ac.nz/home/pub/222/ http://sage.math.canterbury.ac.nz/home/pub/223/

create a tridiagonal matrix

In MATLAB, we can produce a tridiagonal matrix of order 2*m+1.

   matlab: m = 5;
   matlab: diag(-m:m) + diag(ones(2*m,1),1) + diag(ones(2*m,1),-1)

In SAGE, do I have to write a function, two for-loops, or is there a convenient way? Perhaps it's already defined in one package, scipy/numpy, maxima, ....

Thanks in advance!


define a my_function, here are two example codes http://sage.math.canterbury.ac.nz/home/pub/222/ codes

http://sage.math.canterbury.ac.nz/home/pub/222/

http://sage.math.canterbury.ac.nz/home/pub/223/