Exercises
Ex. 1 → Two matrices A, B are called similar, if there exists a matrix S, such that B = S-1 A S. A and B have the same eigenvalues. Write a test checking that two matrices are similar, by comparing their eigenvalues. Is it a functional or a unit test?
Ex. 2 → Create two vectors of large dimension. Compare the execution time of various ways to compute their dot
product:
- SciPy function:
dot(v,w)
- Generator and sum:
sum((x*y for x,y in zip(v,w)))
- Comprehensive list and sum:
sum([x*y for x,y in zip(v,w)])
Ex. 3 → Let u be a vector. The vector v with components
is called a moving average of u. Determine which of the two alternatives to ...
Get Scientific Computing with Python 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.