Skip to content
Snippets Groups Projects
Commit d2a0b8ed authored by Nicolas Aspert's avatar Nicolas Aspert
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
README.md 0 → 100644
# Matrix Analysis, spring semester 2025
This repository contains the notebooks for the exercises sessions of the EPFL bachelor course [EE-312 Matrix Analysis](https://edu.epfl.ch/studyplan/en/bachelor/electrical-and-electronics-engineering/coursebook/matrix-analysis-EE-312) ([moodle](https://moodle.epfl.ch/course/view.php?id=16942)).
The course will address the following topics:
- Linear transformations
- Pseudo-inverse
- Projections and norms
- Eigenvalues, eigenvectors and eigenvalue problems
- Singular Value Decomposition
- Linear Equations
- Random matrices
- Linear Least Squares
- Linear differential and difference equations
## Installation
### Noto
You can run the notebooks using EPFL's jupyterhub service <https://noto.epfl.ch>. In this case you only need to login into noto, clone this repository using the `Git -> Clone a repository` menu. Noto's default environment already has all the required packages pre-installed.
### Local installation
For a local installation, you will need [git], [Python], and packages such as [numpy](https://numpy.org) or [Python scientific stack][scipy].
If you don't know how to install those on your platform, we recommend to install [Miniconda], a distribution of the [conda] package and environment manager.
Follow the below instructions to install it and create an environment for the course.
1. Download the Python 3.x installer for Windows, macOS, or Linux from <https://conda.io/miniconda.html> and install with default settings. For windows, it is advised to use the the Windows Subsystem for Linux (WSL) which allows you to run all Linux commands and applications within Windows. In order to use it, you need to install it first, e.g. for [Ubuntu](https://ubuntu.com/wsl) (but other Linux distributions are available as well). Once installed, open the Ubuntu WSL and proceed with Miniconda installation for Linux and create the environment.
Skip this step if you have conda already installed.
* macOS: double-click on `Miniconda3-latest-MacOSX-x86_64.pkg` or run `bash Miniconda3-latest-MacOSX-x86_64.sh` in a terminal.
* Linux: run `bash Miniconda3-latest-Linux-x86_64.sh` in a terminal or use your package manager.
1. Open a terminal.
Windows: open the Anaconda Prompt from the Start menu.
1. Install git with `conda install git`.
1. Navigate to the folder where you want to store the course material with `cd path/to/folder`.
1. Download this repository with `git clone https://gitlab.epfl.ch/lts2/matrix-analysis-2024`.
1. Enter the repository with `cd matrix-analysis-2025`.
1. Create an environment with the packages required for the course with `conda env create -f environment.yml`.
1. Run the steps below to start Jupyter. You should be able to run the [`test_install.ipynb`][test_install] notebook.
Every time you want to work, do the following:
1. Open a terminal. Windows: open the Anaconda Prompt from the Start menu.
1. Activate the environment with `conda activate matrix-analysis-2025`.
1. Navigate to the folder where you stored the course material with `cd path/to/folder/matrix-analysis-2025`.
1. Start Jupyter with `jupyter lab`. The command should open a new tab in your web browser.
1. Edit and run the notebooks from your browser.
1. Once done, you can run `conda deactivate` to leave the `matrix-analysis-2024` environment.
[git]: https://git-scm.com
[python]: https://www.python.org
[scipy]: https://www.scipy.org
[anaconda]: https://www.anaconda.com/download
[miniconda]: https://conda.io/miniconda.html
[conda]: https://conda.io
[conda-forge]: https://conda-forge.org
[test_install]: https://nbviewer.org/github/epfl-lts2/matrix-analysis-2025/blob/master/test_install.ipynb
### Binder/Colab...
You can also run those notebooks using other online services such as [binder](https://mybinder.org) or [Google colab](https://colab.research.google.com/).
Clicking on one of the badges below will open this repository in binder/colab.
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/epfl-lts2/matrix-analysis-2024/HEAD)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/epfl-lts2/matrix-analysis-2024/)
### Workaround for MacOS swiss layout keyboards
Jupyterlab suffers from an annoying quirk when using a swiss layout keyboard on MacOs which prevents you from (simply) typing the '@' character in a cell using `Alt + G`. This is a [known issue](https://github.com/jupyterlab/jupyterlab/issues/7704), for which a workaround exists.
Create a keyboard shortcut: open `Settings>Advanced Settings>Keyboard Shortcuts` and add the following configuration block:
```
{
shortcuts: [
{
command: 'apputils:run-first-enabled',
selector: 'body',
keys: [
'Alt G',
],
args: {
commands: [
'console:replace-selection',
'fileeditor:replace-selection',
'notebook:replace-selection',
],
args: {
text: '@',
},
},
},
],
}
```
## Team
* Lecturer:
[Pierre Vandergheynst](https://people.epfl.ch/pierre.vandergheynst)
* Assistants:
[Nicolas Aspert](https://people.epfl.ch/nicolas.aspert),
name: matrix-analysis-2025
channels:
- defaults
dependencies:
- jupyterlab=4.2.5
- matplotlib=3.9.2
- numpy=1.26.4
- pandas=2.2.3
- python=3.11.10
- requests=2.32.3
- scikit-image=0.24.0
- scikit-learn=1.5.1
- scipy=1.14.1
\ No newline at end of file
%% Cell type:markdown id:0e44bd91-51a7-4c56-92e5-c196be7941af tags:
# [Matrix Analysis'24]: test your installation
[matrix analysis'24]: https://github.com/epfl-lts2/matrix-analysis-2024
[EPFL LTS2](https://lts2.epfl.ch)
%% Cell type:markdown id:81936a03-dd2d-4348-af93-828a107ec5c1 tags:
This is a mini "test" Jupyter notebook to make sure the main packages we'll use are installed.
Run it after following the [installation instructions](https://github.com/epfl-lts2/matrix-analysis-2024#installation).
%% Cell type:markdown id:2dc4d30c-4162-4347-9ea1-7bc5249c81ee tags:
## Standalone dependencies
If you get a `command not found` error, try to run `conda install <package-name>` (in the `matrix-analysis-2024` environment, i.e., after `conda activate matrix-analysis-2024`).
%% Cell type:code id:4737f499-386c-463b-8630-85e7bfac5acc tags:
``` python
!conda --version # this will fail on Noto
```
%% Cell type:code id:ec0596c7-967b-4399-81da-6602bbdcc17d tags:
``` python
!git --version
```
%% Cell type:code id:0862c7bf-8ae0-4f9a-b96a-1698e59e4aed tags:
``` python
from platform import python_version
print(python_version())
```
%% Cell type:code id:41138a01-2426-4cbf-9661-a7e780f06ef4 tags:
``` python
!jupyter --version
!ipython --version
!jupyter-lab --version
!jupyter-notebook --version
```
%% Cell type:markdown id:e3d1d1b1-f09f-44ad-ba14-726451d9898b tags:
## Python packages
If you get a `ModuleNotFoundError` error, try to run `conda install <package-name>` (in the `matrix-analysis-2023` environment, i.e., after `conda activate matrix-analysis-2024`).
%% Cell type:code id:a1141b09-2122-4862-8b69-2c9d40187662 tags:
``` python
import numpy as np
np.__version__
```
%% Cell type:code id:c9537241-0f85-4d72-a62f-039826aa7f8c tags:
``` python
import scipy
scipy.__version__
```
%% Cell type:code id:3860668d-bb4c-4121-94d5-f4655167afc2 tags:
``` python
import matplotlib as mpl
mpl.__version__
```
%% Cell type:markdown id:08ef3716-82c6-4d00-bdb8-e9d3225c8b69 tags:
## Small test
%% Cell type:code id:0aa07bd9-448b-4ceb-a3d8-15109cb439e1 tags:
``` python
%matplotlib inline
```
%% Cell type:code id:734b2128-a529-491b-b75e-71874db8de71 tags:
``` python
import matplotlib.pyplot as plt
def plot_vect(x, b, xlim, ylim):
'''
function to plot two vectors,
x - the original vector
b - the transformed vector
xlim - the limit for x
ylim - the limit for y
'''
plt.figure(figsize = (10, 6))
plt.quiver(0,0,x[0],x[1],\
color='k',angles='xy',\
scale_units='xy',scale=1,\
label='Original vector')
plt.quiver(0,0,b[0],b[1],\
color='g',angles='xy',\
scale_units='xy',scale=1,\
label ='Transformed vector')
plt.xlim(xlim)
plt.ylim(ylim)
plt.xlabel('X')
plt.ylabel('Y')
plt.legend()
plt.show()
```
%% Cell type:code id:c493443b-930d-49ba-ae19-823e5dae362c tags:
``` python
A = np.array([[2, 0],[0, 1]])
x = np.array([1, 1])
b = np.dot(A, x.T)
plot_vect(x,b,(0,3),(0,2))
```
%% Cell type:code id:c6002c2a-1d9c-4ca3-aa11-7f4b5cf0c30a tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment