使用python学线性代数_外部产品属性| 使用Python的线性代数

使用python学线性代数

Prerequisites:

先决条件:

Property 1:

属性1:

Outer product in linear algebra involves two vectors of any dimension but the order is important. When the order is reversed, the product changes, and the resultant matrix changes.

线性代数的外积涉及两个任意维度的向量,但是顺序很重要。 当顺序颠倒时,乘积将更改,结果矩阵也会更改。

Syntax:

句法:

numpy.outer(Vec_1, Vec_2) != numpy.outer(Vec_2, Vec_1)

Program:

程序:

# Linear Algebra Learning Sequence
# Outer Product Property I

import numpy as np

a = np.array([2, 4, 8, 7, 7])
b = np.array([2, 3, 1, 7, 8])

#outer product in both order
opab = np.outer(a,b)
opba = np.outer(b,a)

print('---A---\n', a)
print('\n\n---B---\n', b)
print('\n\nOuter Product as A.B : ', opab)
print('\n\nOuter Product as A.B : ', opba)

Output:

输出:

---A---
 [2 4 8 7 7]


---B---
 [2 3 1 7 8]


Outer Product as A.B :  [[ 4  6  2 14 16]
 [ 8 12  4 28 32]
 [16 24  8 56 64]
 [14 21  7 49 56]
 [14 21  7 49 56]]


Outer Product as A.B :  [[ 4  8 16 14 14]
 [ 6 12 24 21 21]
 [ 2  4  8  7  7]
 [14 28 56 49 49]
 [16 32 64 56 56]]

Property 2:

属性2:

Outer product in linear algebra involves two vectors of any dimension but the order is important. If the first Vector is of M dimension and 2nd of N, then the outer product matrix will have dimension MxN.

线性代数的外积涉及两个任意维度的向量,但是顺序很重要。 如果第一个向量的维数为M ,第二个向量的维数为N ,则外部乘积矩阵的维数为MxN

Syntax:

句法:

[m,n] = numpy.shape(numpy.outer(Vec_1, Vec_2))

Program:

程序:

# Linear Algebra Learning Sequence
# Outer Product Property I

import numpy as np

a = np.array([2, 4, 8, 7, 7, 9, -6])
b = np.array([2, 3, 1, 7, 8])

#outer product in both order
opab = np.outer(a,b)

dim = np.shape(opab)

print('A : ', a, '\nDimension of first vector :', len(a))
print('B : ', b, '\nDimension of second vector : ', len(b))
print('\n\nOuter Product as A.B : ', opab)
print('Outer product Dimensions : ', dim)

Output:

输出:

A :  [ 2  4  8  7  7  9 -6] 
Dimension of first vector : 7
B :  [2 3 1 7 8] 
Dimension of second vector :  5


Outer Product as A.B :  [[  4   6   2  14  16]
 [  8  12   4  28  32]
 [ 16  24   8  56  64]
 [ 14  21   7  49  56]
 [ 14  21   7  49  56]
 [ 18  27   9  63  72]
 [-12 -18  -6 -42 -48]]
Outer product Dimensions :  (7, 5)


翻译自: https://www.includehelp.com/python/outer-product-properties.aspx

使用python学线性代数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值