# Revision history [back]

It seems like your question has two parts:

1. What does this Matlab code do?
2. How do I turn this into Sage/Numpy/Scipy?
3. What is this Matlab code used for?

This first question is perhaps not best asked in this forum but I'll provide some insight. For the second question I'll suggest some outside resources that can get you started. As for that last question, I'm afraid you'll have to ask your professor about that.

The Matlab function mACfd creates an $N_2^2 \times N_2^2$ matrixA and a vector C of $N_2^2$ components. A is a banded matrix. (i.e. Tridiagonal with additional diagonals distance $N_2$ away.) The way Matlab is creating this matrix-vector pair is by means of a nested for loop across the indices $i$ and $j$ with an auxillary index $k = (i-1)N_2+j$

Python/Sage/Numpy/Scipy does loops, of course, so starting with the numpy.array or numpy.matrix object you should be on your way to writing the same routine. See the Numpy Basics documentation for an introduction to using these data types.

It seems like your question has two three parts:

1. What does this Matlab code do?
2. How do I turn this into Sage/Numpy/Scipy?
3. What is this Matlab code used for?

This first question is perhaps not best asked in this forum but I'll provide some insight. For the second question I'll suggest some outside resources that can get you started. As for that last question, I'm afraid you'll have to ask your professor about that.

The Matlab function mACfd creates an $N_2^2 \times N_2^2$ matrixA and a vector C of $N_2^2$ components. A is a banded matrix. (i.e. Tridiagonal with additional diagonals distance $N_2$ away.) The way Matlab is creating this matrix-vector pair is by means of a nested for loop across the indices $i$ and $j$ with an auxillary index $k = (i-1)N_2+j$

Python/Sage/Numpy/Scipy does loops, of course, so starting with the numpy.array or numpy.matrix object you should be on your way to writing the same routine. See the Numpy Basics documentation for an introduction to using these data types.