Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 N22×N22 matrixA and a vector C of N22 components. A is a banded matrix. (i.e. Tridiagonal with additional diagonals distance N2 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=(i1)N2+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.

click to hide/show revision 2
two parts -> three parts

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 N22×N22 matrixA and a vector C of N22 components. A is a banded matrix. (i.e. Tridiagonal with additional diagonals distance N2 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=(i1)N2+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.