আউটার প্রোডাক্ট: দুটি ১-ডি অ্যারে
numpy.outer() ফাংশন দুটি একমাত্রিক অ্যারের আউটার প্রোডাক্ট দেয়। ফলাফল একটি ২-ডি ম্যাট্রিক্স যেখানে প্রতিটি উপাদান = arr1[i] * arr2[j]।
উদাহরণ কোড
import numpy as np
arr1 = np.array([5, 10, 15])
arr2 = np.array([20, 25, 30])
print("Array1...\n", arr1)
print("\nArray2...\n", arr2)
print("\nDimensions of Array1...\n", arr1.ndim)
print("\nDimensions of Array2...\n", arr2.ndim)
print("\nShape of Array1...\n", arr1.shape)
print("\nShape of Array2...\n", arr2.shape)
result = np.outer(arr1, arr2)
print("\nOuter Product Result:\n", result)
আউটপুট
Array1... [ 5 10 15]
Array2... [20 25 30]
Dimensions of Array1... 1
Dimensions of Array2... 1
Shape of Array1... (3,)
Shape of Array2... (3,)
Outer Product Result:
[[100 125 150]
[200 250 300]
[300 375 450]]