Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions content/numpy-for-matlab-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,42 +699,42 @@ There are pros and cons to using both:

- `array`

- `:)` Element-wise multiplication is easy: `A*B`.
- `:(` You have to remember that matrix multiplication has its own
- 🙂 Element-wise multiplication is easy: `A*B`.
- 🙁 You have to remember that matrix multiplication has its own
operator, `@`.
- `:)` You can treat one-dimensional arrays as *either* row or column
- 🙂 You can treat one-dimensional arrays as *either* row or column
vectors. `A @ v` treats `v` as a column vector, while
`v @ A` treats `v` as a row vector. This can save you having to
type a lot of transposes.
- `:)` `array` is the "default" NumPy type, so it gets the most
- 🙂 `array` is the "default" NumPy type, so it gets the most
testing, and is the type most likely to be returned by 3rd party
code that uses NumPy.
- `:)` Is quite at home handling data of any number of dimensions.
- `:)` Closer in semantics to tensor algebra, if you are familiar
- 🙂 Is quite at home handling data of any number of dimensions.
- 🙂 Closer in semantics to tensor algebra, if you are familiar
with that.
- `:)` *All* operations (`*`, `/`, `+`, `-` etc.) are
- 🙂 *All* operations (`*`, `/`, `+`, `-` etc.) are
element-wise.
- `:(` Sparse matrices from `scipy.sparse` do not interact as well
- 🙁 Sparse matrices from `scipy.sparse` do not interact as well
with arrays.

- `matrix`

- `:\\` Behavior is more like that of MATLAB matrices.
- `<:(` Maximum of two-dimensional. To hold three-dimensional data you
- 😕 Behavior is more like that of MATLAB matrices.
- 🙁 Maximum of two-dimensional. To hold three-dimensional data you
need `array` or perhaps a Python list of `matrix`.
- `<:(` Minimum of two-dimensional. You cannot have vectors. They must be
- 🙁 Minimum of two-dimensional. You cannot have vectors. They must be
cast as single-column or single-row matrices.
- `<:(` Since `array` is the default in NumPy, some functions may
- 🙁 Since `array` is the default in NumPy, some functions may
return an `array` even if you give them a `matrix` as an
argument. This shouldn't happen with NumPy functions (if it does
it's a bug), but 3rd party code based on NumPy may not honor type
preservation like NumPy does.
- `:)` `A*B` is matrix multiplication, so it looks just like you write
- 🙂 `A*B` is matrix multiplication, so it looks just like you write
it in linear algebra (For Python >= 3.5 plain arrays have the same
convenience with the `@` operator).
- `<:(` Element-wise multiplication requires calling a function,
- 🙁 Element-wise multiplication requires calling a function,
`multiply(A,B)`.
- `<:(` The use of operator overloading is a bit illogical: `*`
- 🙁 The use of operator overloading is a bit illogical: `*`
does not work element-wise but `/` does.
- Interaction with `scipy.sparse` is a bit cleaner.

Expand Down
Loading