Open slai7880 opened 8 years ago
We do not need to worry about b and x being 1x3 or 3x1. Numpy functions will take care of that for you. You can first try them on Jupyter notebook to gain some confidence.
The problem is we do. In the header of exercise3.py some functions are imported and we are only allowed to use those functions however clearly we need to perform matrix addition and subtraction when computing things like (L + U), while add and subtract is not included in the header so I suppose we need to implement them. In this case we do need to worry about the dimension, unless I miss some tricks.
We do not need to worry about b and x being 1x3 or 3x1. Numpy functions will take care of that for you. You can first try them on Jupyter notebook to gain some confidence.
To clarify, as mentioned in class when you perform
M = numpy.array( ... ) # m x n array
v = numpy.array( ... ) # array of n elements
numpy.dot(M, v)
the array v
is treated as if it were a column vector.
This design decision will make more sense, interestingly enough, when we start talking about C this week. The question being, what is an efficient way to store matrices and vectors in C?
This is part of the code I copied from the provided test suite:
It looks like it's trying to define an equation Ax = b, where A is 3 by 3, x(variable x0) is 1 by 3 and b is also 1 by 3. But this violates the rule of matrix operation doesn't it? Should we manually solve it in our implementation in exercise 3? Or should we just keep it this way and pretend x to be 3 by 1 and b 3 by 1?