%%capture
!apt install octave
import numpy as np

Convolve

%%writefile conv1.m
% https://www.mathworks.com/help/matlab/ref/conv.html
u = [1 1 1];
v = [1 1 0 0 0 1 1];
w = conv(u,v)
Writing conv1.m
!octave conv1.m
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
w =

   1   2   2   1   0   1   2   2   1

u = [1, 1, 1]
v = [1, 1, 0, 0, 0, 1, 1]
w = np.convolve(u, v)
w
array([1, 2, 2, 1, 0, 1, 2, 2, 1])

Matrix multiplication

%%writefile matmul.m
% https://www.tutorialspoint.com/matlab/matlab_matrix_multiplication.htm
a = [ 1 2 3; 2 3 4; 1 2 5]
b = [ 2 1 3 ; 5 0 -2; 2 3 -1]
prod = a * b
Writing matmul.m
!octave matmul.m
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
a =

   1   2   3
   2   3   4
   1   2   5

b =

   2   1   3
   5   0  -2
   2   3  -1

prod =

   18   10   -4
   27   14   -4
   22   16   -6

a = np.array([[1, 2, 3], [2, 3, 4], [1, 2, 5]])
b = np.array([[2, 1, 3], [5, 0, -2], [2, 3, -1]])
prod = a @ b
prod
array([[18, 10, -4],
       [27, 14, -4],
       [22, 16, -6]])

Element-wise multiplication

%%writefile ew_matmul.m
% https://www.tutorialspoint.com/matlab/matlab_matrix_multiplication.htm
a = [ 1 2 3; 2 3 4; 1 2 5]
b = [ 2 1 3 ; 5 0 -2; 2 3 -1]
prod = a .* b
Writing ew_matmul.m
!octave ew_matmul.m
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
a =

   1   2   3
   2   3   4
   1   2   5

b =

   2   1   3
   5   0  -2
   2   3  -1

prod =

    2    2    9
   10    0   -8
    2    6   -5

prod = a * b
prod
array([[ 2,  2,  9],
       [10,  0, -8],
       [ 2,  6, -5]])