Gram Matrix

easynumpy_linalg

Implement gram_matrix(X).

Given a 2D array X of shape (m, n) (m rows / samples), return the (m, m) Gram matrix G where G[i, j] is the dot product of row i and row j. No for/while loops.

Constraints
  • no scipy, sklearn
  • no for/while loops

Your solution

Edit gram_matrix and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

The Gram matrix of rows is X @ X.T.