From 00ae19d4d3241be30f5aaba51968c0bd76659835 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Wed, 27 Dec 2023 16:20:17 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- numpy/broadcasting/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/numpy/broadcasting/README.md b/numpy/broadcasting/README.md index f6ac187..71d1c5f 100644 --- a/numpy/broadcasting/README.md +++ b/numpy/broadcasting/README.md @@ -12,3 +12,21 @@ Broadcasting: Automatic adaption of dimensions​ Questions to [David Rotermund](mailto:davrot@uni-bremen.de) + +![broadcasting_1.png](broadcasting_1.png) + +Figure 1 (from [numpy.org](https://numpy.org/devdocs/user/basics.broadcasting.html)) : In the simplest example of broadcasting, the scalar b is stretched to become an array of same shape as a so the shapes are compatible for element-by-element multiplication. + +![broadcasting_2.png](broadcasting_2.png) + +Figure 2 (from [numpy.org](https://numpy.org/devdocs/user/basics.broadcasting.html)) : A one dimensional array added to a two dimensional array results in broadcasting if number of 1-d array elements matches the number of 2-d array columns. + +![broadcasting_3.png](broadcasting_3.png) + +Figure 3 (from [numpy.org](https://numpy.org/devdocs/user/basics.broadcasting.html)) : When the trailing dimensions of the arrays are unequal, broadcasting fails because it is impossible to align the values in the rows of the 1st array with the elements of the 2nd arrays for element-by-element addition. + +![broadcasting_4.png](broadcasting_4.png) + +Figure 4 (from [numpy.org](https://numpy.org/devdocs/user/basics.broadcasting.html)) : In some cases, broadcasting stretches both arrays to form an output array larger than either of the initial arrays. + +