Skip to content

Commit

Permalink
adjust matlab inplace modification in main comparison table (#71)
Browse files Browse the repository at this point in the history
* adjust matlab inplace modification

* update

* add link and text
  • Loading branch information
mmcky authored Jul 30, 2020
1 parent 0b11259 commit 0d726e6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,15 @@ Programming
| | f = @(x) a + x | return a + x | f(x) = a + x |
| | f(1.0) | f(1.0) | f(1.0) |
+-------------------------+--------------------------------------+---------------------------------------+-------------------------------+
| | .. code-block:: matlab | .. code-block:: python | .. code-block:: julia |
| | | | |
| Inplace Modification | function f(out, x) | def f(x): | function f!(out, x) |
| | out = x.^2 | x **=2 | out .= x.^2 |
| | end | return | end |
| | x = rand(10) | | x = rand(10) |
| | y = zeros(length(x), 1) | x = np.random.rand(10) | y = similar(x) |
| | f(y, x) | f(x) | f!(y, x) |
| | No consistent or simple syntax | .. code-block:: python | .. code-block:: julia |
| | to achieve |inplace-matlab|_ | | |
| Inplace Modification | | def f(x): | function f!(out, x) |
| | | x **=2 | out .= x.^2 |
| | | return | end |
| | | | x = rand(10) |
| | | x = np.random.rand(10) | y = similar(x) |
| | | f(x) | f!(y, x) |
+-------------------------+--------------------------------------+---------------------------------------+-------------------------------+

.. |inplace-matlab| replace:: this
.. _inplace-matlab: https://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/

0 comments on commit 0d726e6

Please sign in to comment.