QuantEcon / QuantEcon.cheatsheet

A cheatsheet for Python and Julia
154 stars 64 forks source link

Row/column vector examples #13

Closed sglyon closed 7 years ago

sglyon commented 7 years ago

Right now the first two examples are the following

+-----------------------------+--------------------------+---------------------------------------+--------------------------+
| Operation                   |         MATLAB           | Python                                | Julia                    |
+=============================+==========================+=======================================+==========================+
|                             | .. code-block:: matlab   | .. code-block:: python                | .. code-block:: julia    |
|                             |                          |                                       |                          |
| Create a row vector         |     A = [1 2 3]          |  A = np.array([1, 2, 3])              |     A = [1 2 3]          |
+-----------------------------+--------------------------+---------------------------------------+--------------------------+
|                             | .. code-block:: matlab   | .. code-block:: python                | .. code-block:: julia    |
|                             |                          |                                       |                          |
| Create a column vector      |     A = [1; 2; 3]        |  A = np.array([1, 2, 3]).reshape(3,1) |     A = [1; 2; 3]        |
+-----------------------------+--------------------------+---------------------------------------+--------------------------+

This isn't quite accurate. In the row vector example both matlab and Julia would create an array A that has dimensions (1, 3), whereas in python A would have shape (3,)

In the second example matlab and python would have size (3, 1), while the Julia would have size (3,).

Here are some suggestions for how we might improve these examples: