# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Numpy
# Numpy is used by most scientific packages in Python
# Numpy provides a matrix class

# +
import numpy as np
#Arrays
y = np.array([1,3,2])
print('y: ', y)
             
print('shape: ', y.shape)

# +
import numpy as np
#matrix: 2D array
mat = np.matrix('1 2; 3 4')

print(mat)
# -

# Reshape function

import numpy as np
A = np.array([1,1,2,3,5,8,13,21,34]).reshape(3,3)
print(A)
print('shape: ', A.shape)

# Zeros function

import numpy as np
zero_mat = np.zeros((3,4),dtype=int)
print(zero_mat)

# Arrange function

# +
import numpy as np
B = np.arange(0,16,3)
print(B)

B = B.reshape(3,2)
print(B)

# -

# # Arithmetic operations:

# +
import numpy as np
A = np.array([1,1,2,3,5,8,13,21,34]).reshape(3,3)

print(A)

print(A * 2)

print(A / 2)

# +
import numpy as np
#Matrix multiplication 
A = np.array([1,1,2,3,5,8,13,21,34]).reshape(3,3)
print(A)
print(A*A)


y = np. array([1, 3, 2])
print(A*y)



# +
#Numpy operations are element wise operations.
A = np.array([1,1,2,3,5,8,13,21,34]).reshape(3,3)

print(A)

#exponentiation
print(A**2)

#dot function:
print(np.dot(A,A))

# +
#Inner product 
x = np.array([1,3,2])[:,None]
z = np.array([3,4,5])[:,None]

print(np.sum(x*z))

#Transpose
print(z.T)

#Outter product
print(np.dot(x,z.T))

#Element wise product
print(x*z)
# -



StarcoderdataJupyterScriptsDedupFiltered