... | @@ -202,10 +202,10 @@ How much faster is NumPy? Let us run a quick using [benchmark_broadcasting.py](h |
... | @@ -202,10 +202,10 @@ How much faster is NumPy? Let us run a quick using [benchmark_broadcasting.py](h |
|
On a Core i7-6700k... For 1 million numbers, run 100 times... The NumPy code is
|
|
On a Core i7-6700k... For 1 million numbers, run 100 times... The NumPy code is
|
|
a little over 10 times faster than the pure Python code.
|
|
a little over 10 times faster than the pure Python code.
|
|
|
|
|
|
| | Time |
|
|
| | Time (sec) |
|
|
| :--- | ---: |
|
|
| :--- | ---: |
|
|
| Python | 5.1248 |
|
|
| Python | 5.1248 |
|
|
| NumPy | 0.3168 |
|
|
| NumPy | 0.3168 |
|
|
|
|
|
|
|
|
|
|
## Remaining Topics
|
|
## Remaining Topics
|
... | @@ -220,9 +220,6 @@ There are a few more topics to introduce: |
... | @@ -220,9 +220,6 @@ There are a few more topics to introduce: |
|
|
|
|
|
# Implementing a Matrix Solver
|
|
# Implementing a Matrix Solver
|
|
|
|
|
|
|
|
|
|
## Linear Algebra
|
|
|
|
|
|
|
|
In CS 417/517 Computational Methods... I require students to [implement a
|
|
In CS 417/517 Computational Methods... I require students to [implement a
|
|
Matrix Solver... from
|
|
Matrix Solver... from
|
|
scratch](https://www.cs.odu.edu/~tkennedy/cs417/s21/Assts/matrixSolverExercise/).
|
|
scratch](https://www.cs.odu.edu/~tkennedy/cs417/s21/Assts/matrixSolverExercise/).
|
... | @@ -232,6 +229,8 @@ Let us implement a quick NumPy based Matrix solver, for this [Discrete Case |
... | @@ -232,6 +229,8 @@ Let us implement a quick NumPy based Matrix solver, for this [Discrete Case |
|
Least Squares Approximation
|
|
Least Squares Approximation
|
|
Problem](https://www.cs.odu.edu/~tkennedy/cs417/s21/Public/approximationExample2/).
|
|
Problem](https://www.cs.odu.edu/~tkennedy/cs417/s21/Public/approximationExample2/).
|
|
|
|
|
|
|
|
The code snippets in this section are extracted from [least_squares.py](https://git-community.cs.odu.edu/tkennedy/python-workshop/-/blob/master/NumPy/least_squares.py).
|
|
|
|
|
|
```python
|
|
```python
|
|
import numpy as np
|
|
import numpy as np
|
|
|
|
|
... | | ... | |