Compute the Euclidean length of one 3D vector or a batch of 3D vectors:
∥v∥2=x2+y2+z2Here, x, y, and z are the three vector components. A single input has shape (3,) and returns a Python float. A batch has shape (N, 3) and returns a NumPy array containing one norm per row.
Input: v = [3, 4, 12]
Output: 13
Explanation: The squared components sum to 169, whose square root is 13.
Input: v = [[1, 0, 0], [0, 3, 4]]
Output: [1, 5]
Use np.sum(values ** 2, axis=-1) for both accepted shapes.
Convert a zero-dimensional result with float(norms); otherwise return the array.
Sign in to take notes on this problem
Accepts: array
Compute the Euclidean length of one 3D vector or a batch of 3D vectors:
∥v∥2=x2+y2+z2Here, x, y, and z are the three vector components. A single input has shape (3,) and returns a Python float. A batch has shape (N, 3) and returns a NumPy array containing one norm per row.
Input: v = [3, 4, 12]
Output: 13
Explanation: The squared components sum to 169, whose square root is 13.
Input: v = [[1, 0, 0], [0, 3, 4]]
Output: [1, 5]
Use np.sum(values ** 2, axis=-1) for both accepted shapes.
Convert a zero-dimensional result with float(norms); otherwise return the array.
Sign in to take notes on this problem
Accepts: array