Alexander Hess
ec3097e220
The sample_package folder serves as an example in notebook 02 as to what a Python package looks like. Its contents actually belong to the chapter on object-orientation.
14 lines
362 B
Python
14 lines
362 B
Python
"""This module provides utility functions."""
|
|
|
|
|
|
def norm(vector_or_matrix):
|
|
"""Calculate the Frobenius or Euclidean norm of a matrix or vector.
|
|
|
|
Args:
|
|
vector_or_matrix (Vector/Matrix): the entries whose squares
|
|
are to be summed up
|
|
|
|
Returns:
|
|
norm (float)
|
|
"""
|
|
return math.sqrt(sum(x ** 2 for x in vector_or_matrix))
|