Hi Everyone
This week's grading assignments are out. Please return them by replying to the grading email by Friday 14:30. If you submitted a homework but didn't receive one to grade, please let me know. You may give half points if you so desire.
There is a lot of free reign in this homework. You should test each of the three functions on the following arrays:
sage: m = matrix(RDF,[[1,2],[2,3],[-1,3],[0,4]]); m
[ 1.0 2.0]
[ 2.0 3.0]
[-1.0 3.0]
[ 0.0 4.0]
sage: m.echelon_form()
[1.0 0.0]
[0.0 1.0]
[0.0 0.0]
[0.0 0.0]
sage: m = matrix(RDF,[[1,2,3],[4,5,6],[7,8,9]]); m
[1.0 2.0 3.0]
[4.0 5.0 6.0]
[7.0 8.0 9.0]
sage: m.echelon_form()
[ 1.0 0.0 -1.0]
[ 0.0 1.0 2.0]
[ 0.0 0.0 0.0]
sage: m = matrix(RDF,[[3,-1,-3,1],[0,0,3,1],[1,-3,0,-3]]); m
[ 3.0 -1.0 -3.0 1.0]
[ 0.0 0.0 3.0 1.0]
[ 1.0 -3.0 0.0 -3.0]
sage: m.echelon_form()
[ 1.0 0.0 0.0 1.125]
[ 0.0 1.0 0.0 1.375]
[ 0.0 0.0 1.0 0.333333333333]
sage: m = matrix(RDF,[[1,4,9,16,25],[2,4,6,8,10],[2,3,5,7,11]]); m
[ 1.0 4.0 9.0 16.0 25.0]
[ 2.0 4.0 6.0 8.0 10.0]
[ 2.0 3.0 5.0 7.0 11.0]
sage: m.echelon_form()
[ 1.0 0.0 0.0 -0.5 1.5]
[ 0.0 1.0 0.0 -1.5 -6.5]
[ 0.0 0.0 1.0 2.5 5.5]
If you copy the above text directly into Sage, you can use 'numpy.array(m)' to coerce the matrices directly into Numpy arrays with float64 entries.
You don't have to test the gradee's code on numpy arrays with int dtypes; it suffices to stick to those arrays with float dtypes.
Finally, when it comes to giving partial grade, I've given guidelines below, but don't be afraid to use your own judgement. Just remember to justify your grading in the write-up. Comments and constructive criticism are especially important in this week's grading.
Regards
Simon Spicer
Total: X/20 points.
Question 1: X/10 points
Your comments here.
Don't worry about roundoff/approximation errors, numerical stability issues etc. If the gradee's code produces the same or almost the same echelon as Sage's echelon_form() method for the above arrays, you can give full grade. Also, don't worry trying to construct pathologically difficult examples to test; the focus of this homework set is not on algorithmic/numerical wizardry, but rather on optimization using Cython.
10 points: The gradee's code successfully computes the echelon form of the arrays listed above. It is okay if the algorithm fails for corner cases, exceptionally large arrays, int arrays etc. It also doesn't matter if the code isn't neat or commented (although hopefully it is).
7-9 points: The code works but produces the wrong output, or contains easily fixable errors.
4-6 points: The function works on some of the inputs, but is seriously flawed, or the code can be made to work with relatively few adjustments.
1-3 points: The code does not work; however, a moderate to serious attempt has been made at the problem.
0 points: The question has not been attempted.
Question 2: X/4 points total
For this question, the minimum amount of work should have been done to make the code compile in Cython. If the code compiles and it looks identical to the previous question except for an %Cython at the top (and the gradee's Python function works perfectly), you may give full grade.
This question also calls for comparing timings of various array sizes and dtypes. It's okay if this has been rolled into the analysis of question 3, but subtract a point if it hasn't been mentioned at all.
4 points: The gradee's code successfully compiles, and produces exactly correct output for the array examples given above.
3 points: The code compiles but produces incorrect output on some of the test arrays, or it doesn't compile but can be made to do so with minimal effort.
2 points: The code compiles but produces completely bogus output, or the code doesn't compile, but could conceivably be made to work with a moderate amount of effort.
1 point: The code does not compile and is not likely to without considerable effort; however, an attempt has been made at the problem.
0 points: The question has not been attempted.
Question 3: X/6 points total
To get full grade, the gradee must have done two things:
- Invoked some Cython-specific structure to speed up the function. This could include, for example, using a cdef or cpdef function, or using Cython objects. A good rule of thumb is that if the %Cython is removed from the top of the cell, the code no longer executes as pure Python.
- Explicitly benchmarked their new code versus their old code, as required by the question, and written some sort of an analysis thereon.
These parts are worth 3 points each.
Cythonizing:
3 points: The gradee has incorporated some nontrivial Cythonic structure in their code; it compiles, and produces the same output as question 2
2 points: As above, but the code no longer compiles (but can be made to do so relatively easily), or the output has been altered
1 point: An attempt has been made to modify the code of question 2, but the code does not compile or produces completely bogus output
0 points: This part of the question has not been attempted.
Benchmarking:
3 points: The code has been explicitly timed on some inputs and compared to the running times of the code from the previous two questions. Some comment has been made about performance.
2 points: Some timings have been made, but the results are generally terse/uninformative, or no comment on the timings has been made.
1 point: Timings have been described qualitatively but not listed explicitly.
0 points: This part of the question has not been attempted.
It doesn't matter if the gradee's new code is not, in fact, faster than their code from question 1 or 2 (although this would be nice), so long as it has been sufficienty Cythonized and benchmarked (Numpy has been so heavily optimized that it will be difficult to get huge speedups in any case).
...