# Norm of vector and matrix

```
# Times were captured with the timeit module
import numpy as np
# Norm of vector
a = [41,23,22,15,6,11]
np_a = np.array(a)
print(np.linalg.norm(np_a)) # 0.3047s
print(sum([val**2 for val in a])**0.5) # 0.028s, no external library needed
# Result in both cases: 55.4616984954
# Norm of matrix
A = [
[18,22,21,10],
[13,6,4,11],
[7,15,20,18],
[6,5,11,16]
]
np_A = np.array(A)
print(np.linalg.norm(np_A)) # 0.3744s
print(np.sqrt(np.sum(np_A**2))) # 0.4466s
print(sum([val**2 for sublist in A for val in sublist])**0.5) # 0.0725s, no library
# Result in all cases: 55.9195851201
```