Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 10 additions & 10 deletions docs_input/basics/matlabpython.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Conversion Table
| Operation | MATLAB | Python | MatX | Notes | Examples |
+===========================+========================================+================================================+=================================================+========================================================================================================================+==========+
| Basic indexing | ``A(1,5)`` | ``A[0,4]`` | ``A(0,4)`` | Retrieves the element in the first row and fifth column | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| Tensor addition | ``A + B`` | ``A + B`` | ``A + B`` | Adds two tensors element-wise | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| Tensor subtraction | ``A - B`` | ``A - B`` | ``A - B`` | Subtracts two tensors element-wise | |
Expand All @@ -43,7 +43,7 @@ Conversion Table
| Tensor slice (contiguous) | ``A(1:4,2:5)`` | ``A[0:5,1:6]`` | ``Slice({0,1}, {5,6});`` | Slices 4 elements of the outer dimension starting at 0, | |
| | | | | and 5 elements of the inner dimension, starting at the second element. | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| Tensor slice (w/stride) | ``A(1:2:end,2:3,8)`` | ``A[::2,1:9:3]`` | ``A.Slice({0,1}, {matxEnd,6}, {2,3});`` | Slices N elements of the outer dimension starting at the first element and picking every second element until the end. | |
| Tensor slice (w/stride) | ``A(1:2:end,2:3:8)`` | ``A[::2,1:9:3]`` | ``A.Slice({0,1}, {matxEnd,9}, {2,3});`` | Slices N elements of the outer dimension starting at the first element and picking every second element until the end. | |
| | | | | In the inner dimension, start at the first element and grab every third item, and stop at the 8th item. | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| Cloning a dimension | ``reshape(repmat(A, [4,1]), [4 4 4])`` | ``np.repeat(np.expand_dims(A, axis=0), 5, 0)`` | ``A.Clone<3>({5, matxKeepDim, matxKeepDim})`` | Takes a 4x4 2D tensor and makes it a 5x4x4 3D tensor where every outer dimension replicates the two inner | |
Expand All @@ -54,18 +54,18 @@ Conversion Table
| Permute dimensions | ``permute(A, [3 2 1])`` | ``np.einsum('kij->ijk', A)`` | ``A.Permute({2,1,0})`` | Permutes the three axes into the opposite order | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| Get real values | ``real(A)`` | ``np.real(A)`` | ``A.RealView()`` | Returns only the real values of the complex series | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| Matrix multiply (GEMM) | ``A * B`` | ``np.matmul(A, B)`` | ``matmul(A, B)`` | Computes the matrix multiplication of ``A * B`` | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| Compute matrix inverse | ``inv(A)`` | ``np.linalg.inv(A)`` | ``inv(A)`` | Computes the inverse of matrix A using LU factorization | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| 1D FFT | ``fft(A)`` | ``np.fft.fft(A)`` | ``fft(A)`` | Computes the 1D fast fourier transfor, (FFT) of rows of A | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| 1D IFFT | ``ifft(A)`` | ``np.fft.ifft(A)`` | ``ifft(A)`` | Computes the 1D inverse fast fourier transfor, (IFFT) of rows of A | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| 2D FFT | ``fft2(A)`` | ``np.fft.fft2(A)`` | ``fft2(A)`` | Computes the 2D fast fourier transfor, (FFT) of matrices in outer 2 dimensions of A | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| 2D IFFT | ``ifft2(A)`` | ``np.fft.ifft2(A)`` | ``ifft2(A)`` | Computes the 2D inverse fast fourier transfor, (IFFT) of matrices in outer 2 dimensions of A | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
| Covariance | ``cov(A)`` | ``np.cov(A)`` | ``cov(A)`` | Computes the covariance on the rows of matrix A | |
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
+---------------------------+----------------------------------------+------------------------------------------------+-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------+
Loading