0% found this document useful (0 votes)
3 views

Piar CSNM2020 Exo2

Uploaded by

Iris ZAME
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Piar CSNM2020 Exo2

Uploaded by

Iris ZAME
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Computer Science and Numerical Modeling

Bruno PIAR
Monday, September 14, 2020
Due Thursday, October 1, 2020

B Exercice 1 – The objective is here to practice array broadcasting in numpy.


1 Understand the numpy.mean function and in particular its axis keyword argument
[VanderPlas, Python Data Science Handbook, 2017, pp 60-61].
2 Given a two-dimensional numpy ndarray, build with a single statement a new column-
wise demeaned array by substracting to all the items of each column the mean of that
column.
3 Given a two-dimensional numpy ndarray, build with a single statement a new row-wise
demeaned array by substracting to all the items of each row the mean of that row.
Details can be found in [McKinney, Python for Data Analysis, 2018, Appendix A].

B Exercice 2 – The objective is here to review some basics of linear algebra. The following
book will be used: [Meyer, Matrix Analysis and Applied Linear Algebra, 2000].
1 Understand Gaussian elimination (section 1.2), implement it (without pivoting) and
test the implementation on the following system (page 5):

2x + y + z = 1
6 x + 2 y + z = −1
−2 x + 2 y + z = 7

2 Understand Gauss-Jordan method (section 1.3), implement it (without pivoting) and


test the implementation on the following system (example 1.3.1 page 15):

2 x1 + 2 x2 + 6 x3 = 4
2 x1 + x2 + 7 x3 = 6
−2 x1 − 6 x2 − 7 x3 = −1

2 Generalize the previous implementation of the Gauss-Jordan method to compute the


inverse of a matrix (page 118) and test on the matrix (example 3.7.3 page 119):
 
1 1 1
1 2 2
1 2 3

All the implementations will be done using numpy ndarray and vectorized operations.
Within each function, more than one level of indentation should not be necessary.

You might also like