线性代数 行矩阵的值
Prerequisites:
先决条件:
Learn: how to find the minimum value from comparison of each element in two matrices using an inbuilt function in the numpy library?
了解:如何使用numpy库中的内置函数从两个矩阵中每个元素的比较中找到最小值?
Syntax:
句法:
numpy.minimum(Matrix_M1, Matrix_M2)
Return:
返回:
A matrix of same dimension with given matrix containing minimum value at each entry among both matrices.
具有给定矩阵的相同维度的矩阵在两个矩阵的每个条目中均包含最小值。
用于比较矩阵最小值的Python代码 (Python code for comparing minimum from matrices)
# Linear Algebra Learning Sequence
# Minimum Value Comparing
import numpy as np
M = np.array([[2,3,4], [4,4,8], [4,8455,7], [4,8,99] ])
MM = np.array([[2,3,46], [4,44,8], [4,8,7], [4,8,9] ])
print("\n\n---Matrix A---\n", M)
print("\n\n---Matrix B---\n", MM)
print('\n\n---minimum value comparasion : ', np.minimum(M,MM))
Output:
输出:
---Matrix A---
[[ 2 3 4]
[ 4 4 8]
[ 4 8455 7]
[ 4 8 99]]
---Matrix B---
[[ 2 3 46]
[ 4 44 8]
[ 4 8 7]
[ 4 8 9]]
---minimum value comparasion : [[2 3 4]
[4 4 8]
[4 8 7]
[4 8 9]]
翻译自: https://www.includehelp.com/python/comparing-minimum-from-matrices.aspx
线性代数 行矩阵的值