Numpy Matrix Ops

Matrix multiplication and dot product.

Try Numpy Matrix Ops Code

How it Works

NumPy arrays are C-contiguous maps inside WASM.

Operations run natively using predefined LAPACK functions.

Source Code

Multiplication array pipeline using numpy internally.

matrix.py
Try in Editor
import numpy as np

# Create two 3x3 matrices
matrix_A = np.array([
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
])

matrix_B = np.array([
    [9, 8, 7],
    [6, 5, 4],
    [3, 2, 1]
])

print("Matrix A:")
print(matrix_A)
print("\nMatrix B:")
print(matrix_B)

# Matrix Multiplication (Dot Product)
result = np.dot(matrix_A, matrix_B)
print("\nResult of A * B:")
print(result)

# Transpose
print("\nTranspose of Result:")
print(result.T)
Terminal Output
Matrix A:
[[1 2 3]
 [4 5 6]
 [7 8 9]]

Matrix B:
[[9 8 7]
 [6 5 4]
 [3 2 1]]

Result of A * B:
[[ 30  24  18]
 [ 84  69  54]
 [138 114  90]]

Transpose of Result:
[[ 30  84 138]
 [ 24  69 114]
 [ 18  54  90]]

Real-world Applications

  • Data processing
  • ML Pipeline math
  • AI tensor initialization

Frequently Asked Questions

Are C-Extensions supported?

Most standard data-science C-extensions are pre-compiled and packed within the Pyodide runtime core.