Numpy Matrix Ops

矩陣乘法和點積。

在編輯器中嘗試

概述

NumPyarrays are C-contiguous maps insideWASM.

Operations run natively using predefined LAPACK functions.

程式碼和執行輸出

Multiplication array pipeline using numpy internally.

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)
端子輸出
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]]

逐步實施

  • 資料處理
  • ML Pipeline math
  • AI tensor initialization

常見問題解答

支援 C 擴充嗎?

大多數標準資料科學 C 擴充功能都已預先編譯並打包在Pyodide執行階段核心中。

相關主題