roofline.devPublic Beta

L2 Norm

0EASYPracticeReport issue

Compute the L2 norm of each row of a matrix.

Given matrix XX of shape n×mn \times m in row-major order, produce vector y\underline{y} of length nn such that

yi=jmXij2y_i = \sqrt{\sum_{j}^{m} X_{i\,j}^2}

Input

  • X - input matrix of shape n×mn \times m stored in row-major order.
  • n - the number of rows in X.
  • m - the number of columns in X.

Output

  • Y - output vector of length n where each element is the L2 norm of the corresponding row of X.
Open on a desktop browser to write and submit code.

Public submissions

Practice problem · every submission below is public, click to view code

No public submissions yet — be the first to submit.