Auto-grading for Coding the Matrix, Edition One (beta version)

Make sure you have Python 3.x on your computer.  In the following, I will assume that python3 is the command used to invoke Python.  (On Windows, it might be just python.)

Create a single directory, called matrix, in which you will put all your code.

Download the submission script,, to the matrix directory.

To get your work graded,
python3 <stencil filename>
For example, to submit solutions to problems appearing in the chapter The Function, edit, and then use the command
Note that these commands are executed not from within the Python REPL, but within a console or shell or Command Prompt.

More about submit

The submit script asks for your username. This can be anything you like. When you submit a correct answer, the script stores a "receipt" in a subdirectory receipts of your matrix directory, specifying your username, the data, and the identifier of the problem you solved.

To avoid having to give your username each time you run the submit script, you can create a file profile.txt in your matrix directory with the following line in it:
USERNAME philipklein
where "philipklein" is replaced with your chosen username. Later I will write about other features of the submit script. In particular, we plan to have a leaderboard; you will be able to request that your successful submits be reported to the leaderboard.

The Stencil files

More stencil files will be added as I complete them.  Note that these are still rough and should be considered beta versions.  Contact me at if you have questions or bug reports.

The Function (includes most of the problems in Lab 0.6) (Includes several of the problems in Lab 0.6)

The Field

The Vector (implementation of the Vec class)

The Vector Space

The Matrix (implementation of the Mat class)

The Basis


Gaussian Elimination

The Inner Product


The Singular Value Decomposition

The Eigenvector